I am trying to achieve the following; A user updates a specific Product line in a quote, after this has been done a second Product line (if it exists) should be updated with some values. To achieve this I have created a Workflow in my Dynamics environment; the workflow targets the quotedetail entity and gets triggered when the quantity of an existing product changes and the product is a product A. If the above condition is true then my custom workflow/CodeActivity (created in C#) gets activated. My idea was to retrieve the ID of the quote in which the quotedetail is being changed and then retrieve all the related quotedetail records and update the right one. I can't retrieve the ID of the quotedetail itself because the record being changed in the quotedetail is not the record which needs to be updated in code. To achieve the above I have set it up as follows: [Input("QuoteID")] [ReferenceTarget("quote")] public InArgument SourceQuoteID { get; set; } protected override void Execute(CodeActivityContext executionContext) { //Create the context IWorkflowContext context = executionContext.GetExtension (); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension (); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); Entity regQuote = service.Retrieve("quote", context.PrimaryEntityId, new ColumnSet(new string[] { "name", "ownerid" })); string quoteName = (string)regQuote.Attributes["name"]; } If I am not mistaken, a quotedetail is linked with a quote based on the name of the quote (not sure)? Though the field name in quotedetail is called quoteid, while the value of it is a quote name, which is a bit confusing since you would assume it targets the quoteid of the quote entity and not it's name. When above code is executed I get the following error; quote With Id = 67ea974c-6449-e811-a831-000d3ab4b197 Does Not Exist I suspect that the (input) value, in the workflow of dynamics (my custom workflow) is wrong. It retrieves / uses the quote of the quotedetail record as input of my custom codeactivity; Property name: QuoteID Data type: lookup Required: Optional Value: {Quote(Quotedetail)} The above uses quotedetail as the entity (as mentioned earlier). The question is, how can I retrieve the right ID which connects the quote to the linked quotedetail records using the quotedetail as target entity in my Dynamics workflow, and which field is that in the quote entity?
↧