I have entities called RegisteredUser and RegisteredApplication. RegisteredUser has a required field called new_applicationid that is populated using a Lookup that targets the RegisteredApplication entity.
So, when I'm creating a new user using the form in CRM I have to click on the lookup, find the relevant application and then Click on OK.
My problem is: there is only one RegisteredApplication at the moment and I would like to have the Lookup prepopulated when the form loads.
I guess I'm looking for something along the lines of
function FormLoad()
{
var app = GetApplications()[0];
//Set a lookup value
var value = new Array();
value[0] = new Object();
value[0].id = app.id; // is this right?
value[0].name = app.name; // is this right?
value[0].entityType = "new_registeredapplication"; // is this right?
Xrm.Page.getAttribute("new_applicationid").setValue(value);
}
function GetApplications()
{
// what do I need to do in here to get a list of
// all the registered applications
}
Can anyone suggest how I might approach something like this?