Ultimate goal: To create a receivables document in Dynamics GP using web services having the option to provide distributions or not from a C# application.
What I am attempting: Retrieve a policy for a specific role where the account distributions behavior is set to "Distributions will be provided"
I've included a code snippet below. If I remove the setting of the context.RoleKey property everything works fine with the default role and a transaction is created with automatic distributions. However, setting the RoleKey property results in an unhandled script exception at the GetPolicyByOperation method call. I've tried using the Superuser - as indicated below. I've also tried a new role giving it access to everything. Both these roles have been used to create new versions of the Create Receivables Invoice Policy in the security console.
context.OrganizationKey = (OrganizationKey)companyKey;
RoleKey roleKey = new RoleKey();
roleKey.Id = "Superuser";
context.RoleKey = roleKey;
receivablesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateReceivablesInvoice", context);