문제

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);
도움이 되었습니까?

해결책

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.

  1. Create a new windows user "domainuser01"
  2. 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".
  3. 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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top