Microsoft Dynamics AX Support

This blog contains posts by the Microsoft Dynamics AX Support teams Worldwide

Override AllowEditOnCreate when creating records through a service

Override AllowEditOnCreate when creating records through a service

Rate This
  • Comments 2

I had a case recently in which they were creating records using the DocuRefService. The problem was that an error occurred stating "Field <x>  must be filled in", even though the field mentioned had been specified in the code.

The error occurred on these fields...

RefCompanyId

RefRecId

RefTableId

 

As it turned out, all had a Mandatory property of Yes and had AllowEditOnCreate = No.

This could be worked around by changing the AllowEditOnCreate property to Yes for these fields but could have an impact on application functionality.

Instead, override the initFieldAccessOverrides method in AxdDocuRef

protected void initFieldAccessOverrides()

{

    this.overRideFieldAccess(tableNum(DocuRef), fieldNum(DocuRef, RefRecId),   AxdFieldAccess::AllowEditOnCreate, NoYes::Yes);

    this.overRideFieldAccess(tableNum(DocuRef), fieldNum(DocuRef, RefTableId),   AxdFieldAccess::AllowEditOnCreate, NoYes::Yes);

    this.overRideFieldAccess(tableNum(DocuRef), fieldNum(DocuRef, RefCompanyId),   AxdFieldAccess::AllowEditOnCreate, NoYes::Yes);


}

 

This way you are only changing the AllowEditOnCreate property while creating records through the service and not impacting other parts of the application.

Leave a Comment
  • Please add 4 and 5 and type the answer here:
  • Post
  • Thanks worked like a charm

  • Thank you.. You saved my day!

Page 1 of 1 (2 items)