Tuesday 5 January 2016

Pass entity reference attributes and other attribute to global action by calling action through Webapi in JavaScript Dynamics CRM 2016

In the following code actionName  is the name of action.
primarycontact and parentaccount is the entityreference attribute in action.
name and email is the string attribute in action


var oDataEndpointUrl = Xrm.Page.context.getClientUrl() + "/api/data/v8.0/actionName";
        var service = new XMLHttpRequest();
        service.open("POST", oDataEndpointUrl, false);
        service.setRequestHeader("Accept", "application/json");
        service.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        service.setRequestHeader("OData-MaxVersion", "4.0");
        service.setRequestHeader("OData-Version", "4.0");
        var parameter = { "name": "nizam",
                          "email": "syed.nizam69@gmail.com",
                          "primarycontact": { "contactid": "AEAD37F8-F39D-E511-80D3-2C59E5420648", "@odata.type": "Microsoft.Dynamics.CRM.contact" },
                          "parentaccount": { "accountid": "54AD37F8-F39D-E511-80D3-2C59E5420648", "@odata.type": "Microsoft.Dynamics.CRM.account" }
                         }

        service.send(JSON.stringify(parameter));
        if (service.readyState == 4 /* complete */) {
            if (service.status == 201 || service.status == 200) {
            }
        }

2 comments:

  1. Hi Syed,

    thanks for post. Unfortunately for Custom Entities it was not working on our end.

    var params {
    "inputparamname": {
    "": "",
    "@odata.type": "Microsoft.Dynamics.CRM."
    }
    }

    Found also some error reports/posts:
    https://community.dynamics.com/crm/b/dynamicscrmdevdownunder/archive/2015/02/21/bug-limitation-of-action-entityreference-input-argument

    Any idea here?

    ReplyDelete
  2. "parameterName
    ": { "lookupFieldName": "AEAD37F8-F39D-E511-80D3-2C59E5420648", "@odata.type": "Microsoft.Dynamics.CRM.EntityLogicalName" }

    Replace parameterName with your action parameter name

    lookupFieldName with your lookup field name

    EntityLogicalName replace with your custom entity logical name

    ReplyDelete

Numbering Table Parent group and child group ssrs report

 Recently I have faced a scenario to numbering parent group and subgroup in the following formate 10 parentGroupRow1    10.1 childGroupRow1 ...