Microsoft Dynamics 365 Blog

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.

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!