Thursday, 16 April 2015

Show lookup view dialog and Schedule engine

Following is UNSUPPORTED, and was used to work to elemenate some of the user clicks. I had a requirment to select the service on service activity form and then show schedule engine once the service been selected. function PrepoulateService() { if(Xrm.Page.getAttribute(serviceFieldName).getValue()!=null){ return;} var fetchXml = GetServicesQuery(validServices); var data = GetOrganisationService().Fetch(fetchXml); var canCreate = false; Xrm.Page.getAttribute(serviceFieldName).addOnChange(showScheduleEngine); if (data != null && data.length == 1) { if (data[0].attributes.serviceid.value != null) { Xrm.Page.getAttribute(serviceFieldName).setValue(data[0].attributes.serviceid.value); } } else { //select service by showing service lookup document.getElementById(serviceFieldName).click(); } //show schedule engine setTimeout("showScheduleEngine", 500); } function showScheduleEngine() { Type.registerNamespace("Mscrm"); Mscrm.Form_onload = function () { InitCalendar(USER_DATE_FORMATSTRING, USER_DATE_SEPARATOR, USER_DATE_START_DAY, _dCalMinDate); _oServiceRetrieveCommand = new RemoteCommand("Service", "Retrieve"); window.setTimeout("ScheduleActivity($get('crmFormSubmit').crmFormSubmitId.value, ServiceAppointment, !IsNull(location.search.match(/autoSearch=([^&]*)/)))", 100) }; Mscrm.Form_onsave = function (context) { CustomFormSubmit($find("crmForm"), context.getEventArgs()) }; Mscrm.serviceid_onchange = function () { ServiceLookupChanged() }; Mscrm.isalldayevent_onchange = function () { Mscrm.FormControlInputBehavior.GetBehavior("scheduledstart").set_forceSubmit(true); Mscrm.FormControlInputBehavior.GetBehavior("scheduledend").set_forceSubmit(true) } var eventObj = Xrm.Page.ui; var eContext = Mscrm.FormUtility.constructExecutionObject(eventObj, 0, null, null); eContext = Mscrm.FormUtility.constructExecutionObject(eventObj, 0, null, eContext); var t_s = new Date().getTime(); Mscrm.Form_onload(eContext); }

No comments:

Post a Comment