There are number of occasions where we have to access the fields of a lookup on a form and populate fields on the child form with the values that are coming from the parent lookup form fields. We use the sdk.rest.retreiverecord function to achieve this task with javascript.
For us to use this method the following javascript file has to be referenced before.
Then only we can call the function.
example of a function.
var accountLookUp = Xrm.Page.getAttribute("msdyn_account").getValue();
if (accountLookUp != null) {
var Id = accountLookUp[0].id.replace("{", "").replace("}", "");
SDK.REST.retrieveRecord(Id, "Account", "isv_ABC, isv_Country, isv_County", null, function (accountEntity) {
}, function (error) {
alert(error);
alert(error.message);
});
}
else {
}
A lot of issues are arising with the fields to be retrieved. The field name is case sensitive and if it's not properly given then an error will appear stating "Error: Error : 400: : Type 'Microsoft.Crm.Sdk.Data.Services.Account' does not have a property named 'isv_abc'."
We can find this easily by doing the following.
Paste the url of an account record in the browser and it will bring all the properties of the entity. You can find the field name from this list and refer it correctly. This has saved me a lot of time.
URL: https://crmresearch9.api.crm6.dynamics.com/XRMServices/2011/OrganizationData.svc/AccountSet(guid'ab132b6f-1101-e811-a832-000d3ab4f534')
The output will be like below. You will be able to pick the correct field name for the operation.
This blog describes mostly about the work (CRM 365, CRM 2016, CRM 2015, CRM2011, CRM 4.0, CRM 3.0, C#,Javascript and SQL Server) i do.
Subscribe to:
Post Comments (Atom)
Retrieving Calendar of a Bookable Resource in Dynamics
There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...
-
There is a bit of change in CRM 2011 than CRM 4. The code is below. Microsoft.Xrm.Sdk. EntityReference Moniker1 = new Microsoft.Xrm.S...
-
When you create a new security role from scratch and then assign only that role to a system user and when you log to the CRM site you might ...
-
There are occasions where we need to retrieve working days and working times of a resource in Dynamics grammatically. This is quite possible...
No comments:
Post a Comment