April 17, 2015

If caller is a form then disable field on the Customform in Ax 2009


You can achieve this, by 2 ways

1. Using form args
2.Using Menuitem

1.Using Form -  Write the code  in form init()

public void init()
{
    super();  
    if(element.args().caller())
    {
         // Cast the caller and make sure it is the right form.
         callerForm = element.args().caller();

         if (callerForm.name() == formstr(CustTable))
         {
            CustomerInterface_AccountNum.allowEdit(false);
     }
  }
}

2.Using Menuitem- Create a menuitem and assign the object as custom form and Write the code  in form run()

public void run()
{
    super();
   if (element.args().menuItemName() == menuitemdisplaystr(InterfaceMenuItemNoFilter))
  {
    InterfaceTab_ds.filter      (fieldnum(InterfaceTab,CustAccount),InterfaceTab_CustAccount.valueStr());
    InterfaceTab_ds.object(fieldnum(InterfaceTab,CustAccount)).allowEdit(false);
}

}

No comments:

Post a Comment