Adding this post for someone who needs it and for my own reference.
In Java Script lookup can be populated in one of three ways depending on requirements:
- Query lookup data to set in form
- Get lookup details from data available in form (from other fields)
- Hard code lookup values
This is example using second option. It uses logged in user’s id and name to populate lookup. A lookup can be populated by providing its id (GUID) , name and entity type.
var approver = new Array();
approver[0] = new Object();
approver[0].id = Xrm.Page.context.getUserId(); // Guid as "{a004b16f-4bae-4445-9b15-438449a170d3}";
approver[0].name = Xrm.Utility.getGlobalContext().getUserName();
approver[0].entityType = "systemuser";
Xrm.Page.getAttribute("sofhof_approvedby").setValue(approver);
I hope it is helpful.
Let’s Connect
*This post is locked for comments