Search code examples
axaptamicrosoft-dynamicsx++

Change allowedit on statement


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);
}

 }

Solution

  • 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