Hi,
Try to use this code
async function Getlookupvalue(executionContext){ var formContext = executionContext.getFormContext(); var XValue = formContext.getAttribute("column_name").getValue();
var sXId = XValue[0].id.slice(1,-1); var Xentitytype = XValue[0].entityType; var resultaccount = await Xrm.WebApi.retrieveRecord(siteentitytype ,XId,"?$select=_Column_name_value"); var lookupValuetable_name = new Array(); lookupValuetable_Name[0] = new Object(); lookupValuetable_name[0].id = "{"+ resultaccount["_Column_name_value"] +"}"; lookupValueAccount[0].name = resultaccount["_parentaccountid_value@OData.Community.Display.V1.FormattedValue"]; lookupValuetable_name[0].entityType = siteentitytype; formContext.getAttribute("yourcolumn").setValue(lookupValue table_name);}
X : name of your variable
Column name : The field or colum that you want to get
Your column : The column where you will get the data
Table name : Table from where you get data.
I hope that's helpful for you.
Please mark the answer as verified if that's resolve your problem.
The Lookup field is stored as an Array and each item in the array has three parameters(GUID, Name, Entity Name).
The following link will show more details about Lookup field.
How to set lookup field value using JavaScript Dynamics CRM - Microsoft Dynamics 365 Community
After looking at your code, did you want to set the FormNotification when the Look up filed shows “ inactive”?
Now I try to modify your code.
function getLookUp(e){ var formContext = e.getFormContext(); //get the Array of lookup field value var lookUpValue= formContext.getAttribute("ctp_ctpapplicantsappversion").getValue() //get the name of currently lookup field var isValue=lookUpValue[0].name; if(isValue=="inactive"){ //setFormNotification formContext.ui.setFormNotification("There is an update for cTP Applicants App","INFO"); } }
Hello Manth,
If you are using to get lookup details through JavaScript , Here is example :
if (Xrm.Page.data.entity.attributes.get("fieldname").getValue() != null) {
var CustomerId = Xrm.Page.data.entity.attributes.get("fieldname").getValue()[0].id;
var CustomerName = Xrm.Page.data.entity.attributes.get("fieldname").getValue()[0].name;
var CustomerType = Xrm.Page.data.entity.attributes.get("feildname ").getValue()[0].entityType;
}
//Display the lookup name
alert(CustomerName);
I hope this helps you replace fieldname with your lookup field name in Form
let me know if you find any errors.
Please mark the answer as verified if that's helpful for you.
function displaynotification(executionContext){
var formContext = executionContext.getFormContext();
debugger;
var conatt = formContext.getAttribute("ctp_ctpapplicantsappversion");
var conatt1 = formContext.getAttribute("ctp_ctpapplicantsappversion").getValue();
if( conatt && conatt1 != null){
var conID = conatt1[0].id;
var infoID = "info";
var warningid = "warning";
Xrm.WebApi.retrieveRecord("ctp_ctpapplicantsappversion", "cad0116f-ee80-ed11-81ad-000d3a565815", "?$select=statecode").then(
function success(result) {
var res = result.statecode().getValue();
if(res == "active" ){
formContext.ui.setFormNotification("Record ID of CTP Applicants APP is" + conID, "INFO", infoID);
);
What wrong in this code when i try to load this script on form onload i am getting below error
ReferenceError: Web resource method does not exist: displaynotification
at y._handleMethodNotExistError (ctp.crm.dynamics.com/.../app.js
at y.execute (ctp.crm.dynamics.com/.../app.js
at ctp.crm.dynamics.com/.../app.js
at i (ctp.crm.dynamics.com/.../app.js
at ee._executeIndividualEvent (ctp.crm.dynamics.com/.../app.js
at ee._executeEventHandler (ctp.crm.dynamics.com/.../app.js
at Object.execute (ctp.crm.dynamics.com/.../app.js
at N._executeSyncAction (ctp.crm.dynamics.com/.../app.js
at N._executeSync (ctp.crm.dynamics.com/.../app.js
at N.executeAction (ctp.crm.dynamics.com/.../app.js
at t.dispatch (ctp.crm.dynamics.com/.../app.js
at Object.dispatch (ctp.crm.dynamics.com/.../app.js
at dispatch (ctp.crm.dynamics.com/.../app.js
at It (ctp.crm.dynamics.com/.../17.js
at ctp.crm.dynamics.com/.../24.js
Error Details:
Event Name: onload
Function Name: displaynotification
Web Resource Name: ctp_configstatus
Solution Name: Active
Publisher Name: DefaultPublisherorg524de1c3
Please help me resolve it
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Rishabh Kanaskar 235
MVP-Daniyal Khaleel 177
Tom_Gioielli 156 Super User 2025 Season 2