This is a case worthy of Agatha Christie.
Starting conditions:
Error infolog appeared when saving an address for a vendor by a user, who has access to only a subset of virtual company's company set.
In other words: We have a virtual company that shares DirParty and Vendor tables. Let's say the companies in the virtual company are: 01,02,03,04,05. The user has permissions to access only 01 and 02.
The user creates a Vendor record. When adding the address, the error appears.
On a closer look, the DirParty class, method UpdateAddressFromDirParty has an interesting function: for a public address create address records in all the real companies which are the part of the virtual company. In our case 01,02,03,04,05.
So the conflict arises: The user only has permissions for 01 and 02, while the program wants to update more.
The solution is to introduce some sort of validation of whether the user has permission to the company, which AX is trying to update:
if(Sysdataarea::checkAccessible(dataAreaId)==false)
{
infolog.closeInfolog(100);
continue
}
That is a crude way to verify whether the user has access to the company Dynamics AX wants to update
an address in.
Place this code right after the following line:
dataAreaId = conpeek(addressDataAreaList,i);
Of course, test it out before applying to a production environment.