I've tried customizing Email's regardingobjectid
lookup dropdown, using the following code:
var regardingobjectid = Xrm.Page.getControl("regardingobjectid");
/* The value of viewId is a dummy value,
and only needs to be unique among the other available views for the lookup. */
var viewId = '{00000000-0000-0000-0000-000000000001}';
var entityName = 'lu_service';
var viewDisplayName = 'service - custom view';
var fetchXml =
'<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" >' +
'<entity name="lu_service">' +
'<attribute name="lu_serviceid" />' +
'<attribute name="lu_name" />' +
'<attribute name="createdon" />' +
'<order attribute="lu_name" descending="false" />' +
'</entity>' +
'</fetch>';
var lookupService = new RemoteCommand("LookupService", "RetrieveTypeCode");
lookupService.SetParameter("entityName", "lu_service");
var result = lookupService.Execute();
var objectTypeCode = result.ReturnValue;
var layoutXml =
'<grid name="resultset" object="' + objectTypeCode + '" jump="lu_name" select="1" icon="1" preview="1">' +
'<row name="lu_service" id="lu_serviceid">' +
'<cell name="lu_name" width="300" />' +
'<cell name="createdon" width="125" />' +
'</row>' +
'</grid>';
regardingobjectid.addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
I thought that this code should do two things:
1. Customize the lookup dropdown, i.e., display the records of the required type (in my example: lu_service
) on the dropdown displayed when clicking the lookup field.
2. Add a custom view onto the window opened when clicking the "Look Up More Records" link (listed at the end of the lookup dropdown).
The result is that 1 doesn't work, and 2 works.
My question is: Should've 1 worked? If not, is it possible to achieve this?