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

Creating a CRM entity record with Lookup

Hi,

 

I'm trying to create a Work Order record in the CRM using a flow, for some reason, it's not working, the error message is I'm not passing the required field, I'm doing that and here is my create record code 

{
    "inputs": {
        "host": {
            "connection": {
                "name": "@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$connections']['shared_dynamicscrmonline']['connectionId']"
            }
        },
        "method": "post",
        "body": {
            "ets_invoicestatus": 964720000,
            "ets_islocked": 964720000,
            "ets_isolddata": false,
            "ets_onetimewarrantywillstartfromthis": false,
            "_msdyn_pricelist_value": "@body('getWorkOrderType')?['_msdyn_pricelist_value']",
            "ets_revenuestatus": 964720000,
            "_msdyn_serviceaccount_value": "@triggerBody()?['entity']?['_ets_serviceaccount_value']",
            "ets_shift": 964720000,
            "_ets_subtype_value": "@{null}",
            "msdyn_systemstatus": 690970000,
            "msdyn_taxable": false,
            "ets_typeofbook": 964720002,
            "ets_visitdateavailable": false,
            "ets_visitvalue": 0,
            "msdyn_name": "-",
            "_msdyn_workordertype_value": "@body('getIncidentType')?['_msdyn_defaultworkordertype_value']",
            "ets_workordervalueaftervat": 0,
            "_msdyn_billingaccount_value": "@body('getServiceAccount')?['_parentaccountid_value']",
            "msdyn_billingaccount": "@body('getServiceAccount')?['parentaccountid']",
            "_ets_invoicestatus_label": "Not Invoiced",
            "_ets_islocked_label": "No",
            "_ets_revenuestatus_label": "New",
            "msdyn_serviceaccount": "@triggerBody()?['entity']?['_ets_serviceaccount_value']",
            "_ets_shift_label": "Day",
            "_msdyn_systemstatus_label": "",
            "_ets_typeofbook_label": "Service Report",
            "msdyn_workordertype": "@body('getIncidentType')?['msdyn_defaultworkordertype']",
            "msdyn_followuprequired": false,
            "ets_goingtobedonebeforecancelingthecontract": false,
            "msdyn_isfollowup": false,
            "_ets_isitlinkedwiththenextworkorder_label": "",
            "msdyn_ismobile": false,
            "_ets_noncompletionapproval_label": "",
            "_ets_noncompletionfinalapproval_label": "",
            "_ownerid_type": "",
            "_ets_shouldbecredit_label": "",
            "_statuscode_label": "",
            "_ets_visitfrequency_label": "",
            "_ets_visitvaluesettings_label": "Normal Calculation (Agreement Value)",
            "_msdyn_worklocation_label": "Onsite"
        },
        "path": "/datasets/@{encodeURIComponent(encodeURIComponent('org.crm4'))}/tables/@{encodeURIComponent(encodeURIComponent('msdyn_workorders'))}/items",
        "authentication": {
            "type": "Raw",
            "value": "@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"
        }
    },
    "metadata": {
        "flowSystemMetadata": {
            "swaggerOperationId": "PostItem"
        }
    }
}

you can notice I'm passing the _msdyn_serviceaccount_value, also I tried to pass the msdyn_serviceaccount, but still, once the request is made it's showing as null, here is my request 

image.png

items

{
  "ets_invoicestatus": 964720000,
  "ets_islocked": 964720000,
  "ets_isolddata": false,
  "ets_onetimewarrantywillstartfromthis": false,
  "_msdyn_pricelist_value": null,
  "ets_revenuestatus": 964720000,
  "_msdyn_serviceaccount_value": null,
  "ets_shift": 964720000,
  "_ets_subtype_value": "",
  "msdyn_systemstatus": 690970000,
  "msdyn_taxable": false,
  "ets_typeofbook": 964720002,
  "ets_visitdateavailable": false,
  "ets_visitvalue": 0,
  "msdyn_name": "-",
  "_msdyn_workordertype_value": null,
  "ets_workordervalueaftervat": 0,
  "_msdyn_billingaccount_value": null,
  "msdyn_billingaccount": null,
  "_ets_invoicestatus_label": "Not Invoiced",
  "_ets_islocked_label": "No",
  "_ets_revenuestatus_label": "New",
  "msdyn_serviceaccount": null,
  "_ets_shift_label": "Day",
  "_msdyn_systemstatus_label": "",
  "_ets_typeofbook_label": "Service Report",
  "msdyn_workordertype": null,
  "msdyn_followuprequired": false,
  "ets_goingtobedonebeforecancelingthecontract": false,
  "msdyn_isfollowup": false,
  "_ets_isitlinkedwiththenextworkorder_label": "",
  "msdyn_ismobile": false,
  "_ets_noncompletionapproval_label": "",
  "_ets_noncompletionfinalapproval_label": "",
  "_ownerid_type": "",
  "_ets_shouldbecredit_label": "",
  "_statuscode_label": "",
  "_ets_visitfrequency_label": "",
  "_ets_visitvaluesettings_label": "Normal Calculation (Agreement Value)",
  "_msdyn_worklocation_label": "Onsite"
}

body

{
  "status": 400,
  "message": "The Service Account is required.",
  "source": "org.crm4.dynamics.com",
  "errors": [],
  "debugInfo": "clientRequestId: d5d3b59b-df4f-4ae0-8f9f-53975a47e6fa"
}

any ideas,

 

1 REPLY 1
v-zhos-msft
Level 10

Re: Creating a CRM entity record with Lookup

Hi @aboodhamwi ,

Could you please share a screenshot of your flow's configuration?

As the error message shown, the Service Account is null.

So I am afraid the Service Account value from your trigger is null.

You can add a compose action below the trigger to check if the Service Account value is null from the record you have selected.

Capture3.PNG

Best Regards,

Community Support Team _ Zhongys

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,750)