Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to Update Value in Parental Relation in Work Order & Work Order Product?

Posted on by 431

Hi Dear,

 

I have one issue.

 

Problem - I have one Work Order, In the Work Order I want to update one field like "Work Order Type". 

 

Need to Achieve - when Value Updated as "Inspection" I need to Update One FIeld in "Work Order Product Entity" (Custom Field) /Or Any Field

pastedimage1587623890502v1.png

When  I am trying to create "Workflow" I can not see the "Work Order Product" Entity in Related Entity. Coz "Work Order" and "Work Order Product" Entity has a "Parental" relationship.

pastedimage1587623911341v2.png

Reference - of Workflow - 

 pastedimage1587623932615v3.png

So Please suggest me the way How can I update the value for Custome Field in "Work Order Product" Entity.

 

Thanks in advance.

  • Suggested answer
    LuHao Profile Picture
    LuHao 40,872 on at
    RE: How to Update Value in Parental Relation in Work Order & Work Order Product?

    Hi Vijay,

    In "Update a record" of "Apply to each", the Record identifier should be Work Order Product.

    pastedimage1587711601662v1.png

    In addition, I recommend that you use Common Data Service (not D365) When a record is updated as the trigger in the top of flow, the advantage is that we can define the updated field.

    The following are the complete steps of Flow. I have tested it and it runs successfully.

    pastedimage1587711821268v2.png

    pastedimage1587711838505v3.png

    pastedimage1587711875094v4.png

  • Vijay Tailor Profile Picture
    Vijay Tailor 431 on at
    RE: How to Update Value in Parental Relation in Work Order & Work Order Product?

    Hi Hao,

    Thanks for reply.

    I am doing exactly same in  Flow.

    But in my  "Work Order Product" Record is not Updated.

    See the reference.

    pastedimage1587636493046v1.png

    See the Configuration for my Flow.

    pastedimage1587636601009v2.png

    Getting below Error on the last Step.

    --batchresponse_6897f866-7211-4dcc-8dd7-efeae4879d66
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    HTTP/1.1 400 Bad Request
    REQ_ID: b6ac6b39-7226-448e-a96f-a30eb7ef5459
    Content-Type: application/json; odata.metadata=minimal
    OData-Version: 4.0

    {"error":{"code":"0x80040265","message":"Exception has been thrown by the target of an invocation.","innererror":{"message":"Exception has been thrown by the target of an invocation.","type":"System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]","stacktrace":" at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, InvocationContext invocationContext, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext, Dictionary`2 optionalParameters)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Upsert(Entity entity)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Update(Entity entity, UpdateOption updateOption)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.UpdateEdmEntity(CrmODataExecutionContext context, String edmEntityName, String entityKeyValue, EdmEntityObject entityObject)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.PatchEntityImplementation(String& entityName, String key, EdmEntityObject entityDelta)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.<>c__DisplayClass10_0`2.<InvokeActionAndLogMetric>b__0()\r\n at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}}}
    --batchresponse_6897f866-7211-4dcc-8dd7-efeae4879d66--

    So not Understanding where is the Issue. (All the steps trying on Trial Instance)

    Please let me know if you need my Flow. for test /Help, it would be a great help for me.

    Thanks

  • Verified answer
    LuHao Profile Picture
    LuHao 40,872 on at
    RE: How to Update Value in Parental Relation in Work Order & Work Order Product?

    Hi Vijay,

    Since Work Order is the primary entity and Work Order Product is the related entity, you cannot update Work Order Product in the Work Order workflow.

    This is by design. We can only update the primary entity record in the related entity workflow, but we cannot update the related entity record in the main entity workflow.

    Imagine this scenario, Work Order is a parent, Work Order Product Entity is children, a parent (Work Order) has many children (Work Order Product), and each child (Work Order Product) has only one parent (Work Order). So when a child wants to update a field of his parents, then it is natural to find his parents (because there is only one parent for him). When a parent wants to update a field of his child, he cannot choose which child (because there are many children).

    Solution: Step 1.  We first create a two-option field (default value is "No") for the Work Order to indicate whether to update the Work Order Product, and use the workflow to update this field to "Yes". The workflow is triggered when the field "Work Order Type" is changed and equals "Inspection".

    Step 2. Create Flow, the trigger condition is when the two-option field changes to "Yes", use "List records" to update Work Order Product cyclically. Finally, update the two-option field to "No".

    Please refer to https://community.dynamics.com/365/b/dynamics365enterprisecloudfronts/posts/update-child-records-when-parent-record-is-updated-using-microsoft-flow-for-d365-ce

    If you have any questions about the content of the blog, please feel free to ask here and I will help you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans