Search code examples
javascriptdynamics-crmcrmdynamics-crm-365unified-service-desk

CRM 9 - Fetch records from a CRM entity based on ID using JavaScript WebResource


I have a entity with multiple records in it. The entity contains 3 fields Parameter Name, Parameter Value, and Contact ID. Contact ID is a lookup field. There are multiple records for a same Contact ID in my CRM Entity.

Now I want to fetch all Parameter Name and Parameter Value from CRM Entity based on the Contact ID.

I am using following code,

var Query = "$select=vrp_parametername&$filter= vrp_contactid eq '" + contactid + "'";
 XrmSvcToolkit.retrieveMultiple({
    entityName: entity ,  
    odataQuery: Query,
    async: false,
    successCallback: successCallback,
    errorCallback: errorCallback
});

But I am getting following error,

Error has occurred in retrieving Response - Error: 400: Bad Request: No property 'vrp_contactid' exists in type 'Microsoft.Xrm.Sdk.Entity' at position 1


Solution

  • I was mixing the Schema Name with Logical Name in CRM in this case. I was using Schema Name in CRM which was why this error was coming.

    What I did was simply used the Logical Name in this case and was able to achieved the desired result.

    Thank you all for the help