I have worked with a Microsoft employee during the GP Technical Airlift 2013 in Fargo, ND. What he found is this failure is likely a bug, which he is going to log internally. He did share a work-around with me by using the WorkOnBehalfOf property on the Context object. Here are my steps to set this up and code snippet.
- Create a new windows user "domainuser01"
- Assign domainuser01 to a role in the Dynamics Security Console which has the "Create GL Account Distributions Behavior" set to "Distributions Will Be Provided" on the "Create Receivables Invoice Policy".
- Grant domainuser01 Windows Authentication access to the GP databases and the Web Services database.
Code:
context.OrganizationKey = (OrganizationKey)companyKey;
receivablesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateReceivablesInvoice", context);
context.WorkOnBehalfOf = "<domain>\\domainuser01";
wsDynamicsGP.CreateReceivablesInvoice(newReceivablesDoc, context, receivablesInvoiceCreatePolicy);