While working with the MS CRM customization, especially when developing custom HTML pages there is always required to show the default or out of the box lookup window and get the selected values in variable as well as pass the previous selected values etc.
We can achieve this using typescript or JavaScript where we have to create a URL with the required parameters for lookupinfo.aspx page.
The basic URL and the parameters details are listed below-
Parameter:
Parameter | Description | Default value |
DefaultType | ObjectType Code of the entity | |
DefaultViewId | Specify the view id with this parameter which you wanted to show with the lookup window | |
DisableQuickFind | If you want quick find set enable=1 or if not then set disable=0 | 0 |
DisableViewPicker | If you want quick view picker enable or not disable | |
IsInlineMultiLookup | ||
LookupStyle | Lookup Style(single/mutli) | |
ShowNewButton | if you want new button enable or not disable | |
ShowPropButton | if you want prop button enable or not disable | |
dType | 1 | |
Mrsh | False | |
Objecttypes | ObjectType Code of the entity | |
search | Provide a default search string if you want |
/**
* The method to Open CRM default lookup for the respective field
*/
public openLookupDialog() {
const myObject = new Object();
let lookupURL: any;
lookupURL = Globals.BaseURL + '/_controls/lookup/lookupinfo.aspx?LookupStyle=1&browse=0&showpropbutton=1&AllowFilterOff=1&objecttypes=10073';
const dialogwindow = new Mscrm.CrmDialog(Mscrm.CrmUri.create(lookupURL), myObject, 500, 650);
dialogwindow.setCallbackReference(function (result) {
if (result != null) {
this.value = result.items.length > 0 && result.items[0].id != null ?
result.items[0].id.replace(/[\])}[{(]/g, '') : null;
this.text = result.items.length > 0 ? result.items[0].name : '';
this.valueChanged.emit(this.value);
this.textChanged.emit(this.text);
this.cd.detectChanges();
}
}.bind(this));
dialogwindow.show();
}
The above code will generate the URL (I have removed actual server and organization name from the url.) and open the lookup dialog for the specified entity.
http://<server>/<organization>/_controls/lookup/lookupinfo.aspx?AllowFilterOff=1&LookupStyle=single&browse=0&dType=1&objecttypes=10073&showpropbutton=1
There is a method called dialogwindow.setCallbackReference above which will return the selected lookup values and you can store those values in your variables as shown in sample code
No comments:
Post a Comment