Hello Bipin Kumar ,
Thank you for providing the API that will fetch both tables.
I have tried the below JS code based on Steve suggestions:
function _setFromUser(executionContext) {
//Get form context
var formContext = executionContext.getFormContext();
formContext.getControl("jul_tablename").removeOption(973470000);
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.2/EntityDefinitions?$select=MetadataId,LogicalName,DisplayName,PrimaryIdAttribute,ObjectTypeCode,IsCustomizable,OwnershipType,CanCreateAttributes,LogicalCollectionName&$filter=IsValidForAdvancedFind eq true and LogicalName eq 'account' or LogicalName eq 'contact'", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.onreadystatechange = function () {
if (req.readyState === 4) {
var jsonObj = JSON.parse(req.responseText);
console.log(jsonObj);
console.log(jsonObj[0].LogicalCollectionName);
for (i = 0; i < jsonObj.length; i++) {
alert("Nothing happening here");
formContext.getControl("jul_tablename").addOption({ value: jsonObj[i].MetadataId, text: jsonObj[i].LogicalCollectionName });
}
}
}
req.send();
}
However, I am still stuck on how to add the LogicalCollectionName of the retrieved data from the Web API as options directly to the field. Based on the code I provided nothing is happening to the field and it does not show the values that I need to extract from the array.
What am I doing wrong? Could you please provide the updated code?
Looking forward to your response.
Best regards,
EBMRay