I am looking for a way to implement to lookup search based on logged in user team in ONLOAD.
I am still looking for a workaround, that can i get control in ONLOAD.
*This post is locked for comments
I am looking for a way to implement to lookup search based on logged in user team in ONLOAD.
I am still looking for a workaround, that can i get control in ONLOAD.
*This post is locked for comments
I am looking to filter optionset, based on value in onload.
one of my function will give Lookupvalue1 as a value. //This is fine
I need to pass this to other function, something like
function filterLookup() {
//new_example is my lookup attribute name (lookup to Batch entity) on case entity.
if (Xrm.Page.getControl("new_example") != null ) {
Xrm.Page.getControl("new_example").addPreSearch(function () {
// I want to show only one lookup value(Example1) in the new_example. Stck here on where to give the info related to batch
var fetchQuery = "<filter type='and'><condition attribute='name' operator='like' value='example1%' /></filter>";
Xrm.Page.getControl("parentaccountid").addCustomFilter(fetchQuery);
});
}
}
Hi,
Try with below code, make sure you replace the lookup field name and in the fetch xml replace user field name.
function OnLoad(executionContextObj) {
var formContext = executionContextObj.getFormContext();
if (formContext.getControl("pit_recipient") != null) {
formContext.getControl("LookupFieldName").addPreSearch(
function () {
ApplyLookupFilter(formContext);
});
}
};
function ApplyLookupFilter(formContext)
{
var userSettings = Xrm.Utility.getGlobalContext().userSettings;
var userid = userSettings.userId; // get login user id
var filter = "<filter type='and'>" +
"<condition attribute='UseridfieldName' operator='eq' value='"+ userid+ "' />" +
"</filter>"; // Replace record userid field
formContext.getControl("LookupFieldName").addCustomFilter(filter);
};
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,403
Most Valuable Professional
nmaenpaa
101,156