Announcements
Hi Experts,
i have a requirement to open the lookup value in new window.
Requirements : Must be supported.
*This post is locked for comments
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]
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);
alert("Lookup field does not contain value, Please provide a value");
Do you know if there is a way to add the onclick functionality to the actual field rather than a ribbon button?
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.
Jump in, show your community spirit, and win prizes!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.