cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
eauerbach
Level: Powered On

Patch Throwing Error For Field On Different Entity

I have this simple patch statement, which had been working fine, creating an activity. The patch is called from a custom button on the parent work order entity, which is in read-only when this call is made:

UpdateContext(
    {
        patchResult: Patch(
            'Work Activities',
            Defaults('Work Activities'),
            {
                Regarding: ActiveWorkOrder,
                Subject: ActiveWorkOrder.'Customer Request',
                'Current Status': 'Work Activity Status'.'In Transit',
                'Status Reason': 'Status Reason (Work Activities)'.'In Transit',
                'Start Schedule': currentDateTime,
                'Start Travel': currentDateTime,
                'End Schedule': endDateTime
            }
        )
    }
);

 Sometime in the last week, an update I pushed caused this call to start failing with an error of: 

"body": {
    "error": {
      "code": "0x80040265",
      "message": "Attribute 'e8s_sourcefailure' cannot be NULL",
      "innererror": {
        "message": "Attribute 'e8s_sourcefailure' cannot be NULL",

The field mentioned is not on the activity entity being created. The entity where this patch is being called from does have the field, but it doesn't become required until much later in the process, and has nothing to do with the patch. 

 

Why would I be getting such a failure when I'm not modifying the entity the attribute references?

1 ACCEPTED SOLUTION

Accepted Solutions
eauerbach
Level: Powered On

Re: Patch Throwing Error For Field On Different Entity

Closing this out due to user error. We had a background validation task checking to ensure the field was populated before closing that had reversed logic. The error threw me off because I didn't see adding a related record as an update to the Work Order. Job is fixed and work flows are as expected.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Patch Throwing Error For Field On Different Entity

Hi @eauerbach ,

Is there some relationship between the "Work Order" Entity and the "Work Activities" Entity?

Is there some column in your "Work Activities" Entity reference values from the "e8s_sourcefailure" column in your "Work Order" Entity?

 

Based on the formula that you mentioned, I think the ActiveWorkOrder variable returns a record value, is it true? Please make sure the "e8s_sourcefailure" column within the ActiveWorkOrder variable is not Blank.

 

You could also consider take a try to modify your formula as below:

UpdateContext({
              patchResult: Patch(
                                 'Work Activities',
                                 Defaults('Work Activities'),
                                 {
                                   Regarding: LookUp('Work Orders', 'Unique Identifier Column' = ActiveWorkOrder.'Unique Identifier Column'),
                                   Subject: LookUp('Work Orders', 'Unique Identifier Column' = ActiveWorkOrder.'Unique Identifier Column', 'Customer Request'),
                                   ...
                                   ...
                                 }
                           )
})

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
eauerbach
Level: Powered On

Re: Patch Throwing Error For Field On Different Entity

There is a many-to-one relationship between the entities: Work Orders can have multiple Work Activities and there's a field on WA for setting the relationship, using the ActiveWorkOrder assignment.

 

WO does have e8s_SourceFailure referenced in the error, however, it is expected to be blank at the time of WA creation and isn't referenced in the activity at all. The functionality around the field wasn't changed between when this was working and when it broke. 

eauerbach
Level: Powered On

Re: Patch Throwing Error For Field On Different Entity

Closing this out due to user error. We had a background validation task checking to ensure the field was populated before closing that had reversed logic. The error threw me off because I didn't see adding a related record as an update to the Work Order. Job is fixed and work flows are as expected.

View solution in original post

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,838)