Warm tip: This article is reproduced from stackoverflow.com, please click
axapta x++ microsoft-dynamics

Change allowedit on statement

发布于 2020-03-31 22:57:05

I'm trying to change allowedit value on a single field but can't get into it. This is my actuall code but I get error: Okay did rebuild the models and it's fine

  [ExtensionOf(formStr(ProdParmReportFinished))]
  final class ProdParmReportFinishedWG_Extension
 {
public void init()
{
    next init();

    ProdTable prodTable;


    select firstOnly RecId from prodTable
        where prodTable.InventRefType != InventRefType::None
           && prodTable.ProdId == prodTable.InventRefId
           && prodTable.ProdStatus != ProdStatus::ReportedFinished;

    prodParmReportFinished_ds.object(fieldNum(ProdParmReportFinished, EndJob)).allowEdit(prodTable.RecId != 0);
}

 }
Questioner
Radosław Mierzejewski
Viewed
30
Jonathan Bravetti 2020-01-31 23:38

if you are working with extension try something like this

[PostHandlerFor(formStr(YourForm), formMethodStr(YourForm, YourMethod))]
    public static void YourForm_xxx(XppPrePostArgs args)
    {
        FormRun sender = Args.getThis();
        sender.control(sender.controlId(formControlStr(YourForm, YourDatasource_Field))).allowEdit(false);
    }

With the right click and select copy event handler method the correct structure of the method is copied to you, then you enter your code