web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Opening Main Form Dialog from a lookup field using navigateTo and OnLookupClickTag method

AaronRic Profile Picture AaronRic 10,035

With the 2020 Release Wave 1 update, a new method was introduced to open a new or existing record in a Main Form Dialog. There is an existing blog post from our Product Group that introduced the feature HERE, as well as details in our Docs site HERE. Since it is already covered there, I won't go into the details of the method itself. 

 

 

One example I did not see, was how you could do this from the click event of a lookup field. For example, there are many times it would be nice to open the record from a lookup field for a quick reference or overview of the record, without actually leaving the form you are on. It wasn't too long ago that this wasn't possible. Now, you can do this by using the OnLookupClickTag event documented HERE

 

Using a very simple example, I did this to the Regarding field of the Task form below

 

 

function taskLookupModalDialog(executionContext){
	regardingLookup(executionContext);
}

function regardingLookup(executionContext){

	formContext = executionContext.getFormContext();
	formContext.getControl('regardingobjectid').addOnLookupTagClick(context => {
    context.getEventArgs().preventDefault();
	const tagValue = context.getEventArgs().getTagValue();

    Xrm.Navigation.navigateTo({
        pageType: "entityrecord",
        entityName: tagValue.entityType,
        formType: 2,
		entityId: tagValue.id
    }, {
        target: 2,
        position: 1,
        width: {
            value: 80,
            unit: "%"
        }
    });
})

}

 

This event is added as an OnLoad event to the form where the lookup field exists.

 

8611.pastedimage1586782356531v1.png

 

0763.pastedimage1586782365024v2.png

 

6366.pastedimage1586782372810v3.png;

 

Now, when you click on the Regarding field on the Task form, the record opens in a Dialog instead of navigating away from the Task form.

 

pastedimage1586782932127v4.png

 

Thanks for reading!

 

Aaron Richards

Comments

*This post is locked for comments