Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Answered

RESCO : Set Look Up view dynamically on a lookup field on change of a field on the form using JSBridge

(0) ShareShare
ReportReport
Posted on by 95

Hi Resco Experts,

I am trying to set a view for a lookup field in Resco using JSBridge But the code does not work. Can you please point out where i am going wrong.

Below is my code --

onLoad: function () {

     MobileCRM.UI.EntityForm.requestObject(function (entityForm) {

     var detailView = entityForm.getDetailView("Booking");
     var customXMLView = '<fetch version="1.0"><entity name="msdyn_workordersubstatus">' +
     '<filter type="and"><condition attribute="msdyn_workordersubstatusid" operator="eq" value="{90F7A06F-CA1C-EA11-A811-000D3A6AACAF}"/></filter></entity></fetch>';


    inlineSetup = new MobileCRM.UI.DetailViewItems.LookupSetup();
    inlineSetup.addFilter("msdyn_workordersubstatus", customXMLView);
    var dialogSetup = new MobileCRM.UI.DetailViewItems.LookupSetup();
   dialogSetup.addView("msdyn_workordersubstatus", "WorkOrderSubStatusList", true);
   var dialogOnly = false; // Allow both inline lookup and expanded lookup dialog
   detailView.updateLinkItemViews(0, dialogSetup, inlineSetup, dialogOnly);

  }); 
 }

Not sure what is the first parameter in the below code - 

 detailView.updateLinkItemViews(0, dialogSetup, inlineSetup, dialogOnly);

 Also tried LookupForm, the code works but not sure how to bind this to the field- 

ShowLookUp: function () {

var lookupForm = new MobileCRM.UI.LookupForm();
var customXMLView = '<fetch version="1.0"><entity name="msdyn_workordersubstatus">' +
'<filter type="and"><condition attribute="msdyn_workordersubstatusid" operator="eq" value="{90F7A06F-CA1C-EA11-A811-000D3A6AACAF}"/></filter></entity></fetch>';
lookupForm.addEntityFilter("msdyn_workordersubstatus", customXMLView)
lookupForm.addView("msdyn_workordersubstatus", "WorkOrderSubStatusList", "true");
lookupForm.allowNull = true;
lookupForm.show(FS.BRB.onLookupFinished, MobileCRM.bridge.alert, null);

},

onLookupFinished: function () {

MobileCRM.UI.EntityForm.requestObject(
function (entityForm) {

},
MobileCRM.bridge.alert
);

}

Any suggestions would be appreciated.

Thanks in Advance

  • crm_fan Profile Picture
    crm_fan 95 on at
    RE: RESCO : Set Look Up view dynamically on a lookup field on change of a field on the form using JSBridge

    Hey thank you for asking. I solved it finally

  • Verified answer
    crm_fan Profile Picture
    crm_fan 95 on at
    RE: RESCO : Set Look Up view dynamically on a lookup field on change of a field on the form using JSBridge

    Hi All,

    So i found the answer to my above query. Below is the working code to set lookup view dynamically in resco. 

    Posting it so that it helps others.

    onLoad: function () {

    MobileCRM.UI.EntityForm.requestObject(function (entityForm) {

    var detailView = entityForm.getDetailView("Booking");

    var itemIndex = detailView.getItemIndex("vWO.msdyn_substatus"); //Not required, Used this to get the index of my lookup control on the form


    var customXMLView = '<fetch version="1.0"><entity name="msdyn_workordersubstatus">' +
    '<filter type="and"><condition attribute="msdyn_workordersubstatusid" operator="eq" value="{90F7A06F-CA1C-EA11-A811-000D3A6AACAF}"/></filter></entity></fetch>';

    /// Create inline lookup setup (This shows when you click inside lookup without opening the dialog)
    inlineSetup = new MobileCRM.UI.DetailViewItems.LookupSetup();
    inlineSetup.addFilter("msdyn_workordersubstatus", customXMLView);

    //Dialog Look Up (This shows when we click on the plus button)
    var dialogSetup = new MobileCRM.UI.DetailViewItems.LookupSetup();
    dialogSetup.addView("msdyn_workordersubstatus", "WorkOrderSubStatusList", true);


    var dialogOnly = false; // Allow both inline lookup and expanded lookup dialog


    detailView.updateLinkItemViews(11, dialogSetup, inlineSetup, dialogOnly); //here the first parameter is the index of the  lookup field


    });
    },

    Mistake i did was, i did not write the correct index number of the control in line 

     detailView.updateLinkItemViews(0, dialogSetup, inlineSetup, dialogOnly);

    Correction : detailView.updateLinkItemViews(11, dialogSetup, inlineSetup, dialogOnly);

  • LuHao Profile Picture
    LuHao 40,876 on at
    RE: RESCO : Set Look Up view dynamically on a lookup field on change of a field on the form using JSBridge

    Hi partner,

    Did you see any error messages?

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.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,403 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans