When Acumatica released version 2020R2, one significant change for developers is a refactoring of the OwnerID field. This refactoring extends also to other fields such as ProductManagerID which are related to the GUID field OwnerID. The refactoring changes the relation of the GUID User ID to the INT ContactID. The change enables far more flexible assignment of an owner to a record.
Completing the refactoring in your own customizations requires 3 steps.
- Use a stored procedure built within SQL to rename OwnerID used in 2020R1 to OldOwnerID (or whatever you want to name it). Likewise, rename any other related field, such as ProductManagerID. In this same step or as an additional step, add the new INT field OwnerID which will be used by 2020R2.
- Lookup the contact related to the user specified in the OldOwnerID field to populate the new OwnerID (int?) field.
- Update your customization (DAC’s, graphs, etc.) to utilize the new int? OwnerID.
The sample below assumes the database name is MyDatabase and the table name is XXMyTable. The following script will rename OwnerID to OldOwnerID and then add the new INT column OwnerID. The ProductManagerID field is also renamed and re-added as an INT field as an example.
The following uses a subquery to lookup the Contact and populate the new OwnerID field with the ContactID of the Contact record to complete the data portion of the refactor. As before, ProductManagerID has been updated as well.
With the database changes applied, all custom DAC’s must be changed to support the new field type. Acumatica added a new OwnerAttribute to simplify the definition of the field. Also note that OwnerID is an implement of IAssign, and therefore, the implement must be changed from guid? to int? as well.
To complete the refactoring, the development instance should undergo the following sequence:
- Unpublish customization projects
- Upgrade the instance to 2020R2
- Apply the database and code updates described in this post
- Compile the updated extension library of the project
- Update the Customization Project with the new DLL
- Publish the updated customization project
The refactoring of OwnerID is not the only noteworthy update in 2020R2, so be sure to review the Release Notes for Developers to complete your own upgrade.