Hi Experts,
i have a requirement to open the lookup value in new window.
Requirements : Must be supported.
*This post is locked for comments
Do you know if there is a way to add the onclick functionality to the actual field rather than a ribbon button?
Hi,
I share you my code. Copy and paste it to your JS file.
function SetHyperlink()
{
var currentControl = Xrm.Page.ui.getCurrentControl();
if (currentControl == null)
{
alert("No controls currently have focus.");
}
else
{
if (currentControl.getControlType() == "lookup")
{
var controlname = currentControl.getName();
var controlvalue = new Array();
var EntityType ="";
var id= "";
controlvalue = Xrm.Page.getAttribute(controlname).getValue();
if(controlvalue !=null)
{
EntityType = controlvalue[0].entityType;
id = controlvalue[0].id;
var windowOptions = {openInNewWindow: true};
Xrm.Utility.openEntityForm(EntityType,id,null,windowOptions);
}
else
{
alert("Lookup field does not contain value, Please provide a value");
}
}
}
}
Hi
first learn how to create a button and associate to a JS inside a form.
[View:http://himbap.com/blog/?p=1473:750:50]
Next, learn how to get lookup id and entity name
[View:https://arunpotti.wordpress.com/2014/12/19/get-lookup-id-text-entityname-in-crm-using-javascript/:750:50]
After that, learn how to get field type
[View:https://msdn.microsoft.com/en-us/library/gg334266.aspx#:750:50]
finally, learn how to open record
[View:https://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenEntityForm:750:50]
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156