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 :
Customer experience | Sales, Customer Insights,...
Answered

Set custom view as default for lookup in Business Process Flow via JavaScript (Unified Interface)

(0) ShareShare
ReportReport
Posted on by

Hey guys,

I am currently working on a requirement regarding the Business Process Flow in the new Unified Interface.
I need to add a custom view I create with JavaScript to a lookup field in the BPF.

So in JS, I create a custom FetchXML for the filtering and also create custom FetchXML for the layout.
Once I got both get the control via the formContext and add the custom view.
So far so good: The view is added to the list of views when I click on "Change View" on the lookup in the BPF.
But unfortunately it is not applied by default, so a user wouldn't need to click on "Change View".

I have tried to use the "setDefaultView" function right after I add the custom view but unfortunately that does not work.
It worked a couple of weeks ago actually only by using the "addCustomView" function but now it does not set it to default anymore.

Does anyone experience the same issue or came across something familiar?

Here is my code:

//Create FetchXML and GridXML for CustomView in BPF
 var consultantFetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"+
        "<entity name='systemuser'>"+
          "<attribute name='fullname' />"+
          "<attribute name='systemuserid' />"+
          "<order attribute='fullname' descending='false' />"+
          "<link-entity name='teammembership' from='systemuserid' to='systemuserid' visible='false' intersect='true'>"+
            "<link-entity name='team' from='teamid' to='teamid' alias='ad'>"+
              "<filter type='and'>"+
                "<condition attribute='teamid' operator='eq' uiname='Consulting' uitype='team' value='{269FDEA7-EAF0-E911-A812-000D3AB958AA}' />"+
              "</filter>"+
            "</link-entity>"+
          "</link-entity>"+
        "</entity>"+
      "</fetch>";
//Create custom FetchXML for the layout
 var consultantLayout = "<grid name='resultset' jump='fullname' select='1' icon='1' preview='1'>"+
                   "<row name='result' id='systemuserid'>"+
                     "<cell name='fullname' width='300' />"+
                   "</row>"+
                 "</grid>";
//Add the custom view to the control
 formContext.getControl("header_process_new_consultant").addCustomView("{00000000-0000-0000-0000-000000000002}", "systemuser", "Consultant View", consultantFetch, consultantLayout, true);
//Try to set the view default
 formContext.getControl("header_process_new_consultant").setDefaultView("{00000000-0000-0000-0000-000000000002}");
I have the same question (0)
  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi,

    Change form to formContext in  form.getControl("header_process_new_consultant").setDefaultView("{00000000-0000-0000-0000-000000000002}");

  • Community Member Profile Picture
    on at

    Hey,

    sorry, I copied the wrong line from the original code. It actually is formContext in my code. So this is not the issue

  • gdas Profile Picture
    50,091 Moderator on at

    Are you getting any error ? According to you  , you have not change anything recently  , so might be some other issue.  Could you please apply "addCustomView" in different lookup to confirm the environment related issue.

  • Community Member Profile Picture
    on at

    @Goutam I am not getting any errors. Neither on the form nor in the developer console. Whats weird about the whole thing: The custom view is added to the list of views on that lookup in the BPF. So when I click on "Change View", my custom view ("Consultant View") is at the top of the list. So the function "addCustomView" does work and adds the view to the list but it is not set as default.

    And it actually does not work on any lookupfield in the BPF anymore. Is it possible that a recent service update brought changes to the BPF controls?

  • Verified answer
    ajyendra Profile Picture
    1,738 on at

    Put the field to your form not in BPF  then check the code work for not . If it still not working then might be not an issue of BFP . It might be issue of addcustomfunction. If issue persist even when lookup field is in form then

    Raise a ticket to Microsoft Support . It might be mistake from their end.

  • Community Member Profile Picture
    on at

    @Ajyendra

    I've adjusted the code and applied it onto a lookup on the form and it works perfectly as anticipated. So it only does not work in the Business Process Flow. I guess I will need to raise a ticket to Microsoft Support.

    Thanks for advice.

  • BharatPremji Profile Picture
    2,485 on at

    Hi,

    I've come across a similar problem today.  

    My scenario is that we have some JavaScript that filters a lookup which was working up until today.  I deactivated the Business Process Flow and reactivated it and now the filtering has stopped working.

    We have an environment where I haven't deactivated the BPF and the filtering is still working in that one with the same JavaScript

    Did you get a response from Microsoft as to if this is a bug on their end?

    Regards

  • Community Member Profile Picture
    on at

    Hey Bharat,

    sorry for the delayed response.

    Unfortunately I have no solution to this issue and could not file a proper Ticket to MS since the customers instance I had this issue on had no support contract with Microsoft at that moment.

    I solved the issue for this customer with a workaround adjusting the filtering on the default lookup view for the entity I needed it on.

    Maybe somebody else has come across a similar issue and already had the chance to talk to Microsoft about it?

  • BharatPremji Profile Picture
    2,485 on at

    Hi,

    I have managed to replicate the issue and log a ticket with Microsoft.

    The filtering seems to work unless you deactivate the BPF and then turn it back on.  The filtering will work in the old UI but not the unified interface.

    The version of Dynamics I am on is:

    2020_2D00_01_2D00_29_5F00_6_2D00_42_2D00_50.png

    I'll update the thread once I have a reply back from Microsoft

    Regards

    Bharat

  • BharatPremji Profile Picture
    2,485 on at

    So Microsoft have come back after looking at the issue and suggested a few fixes:

    • Re-create the BPF and don't have any special characters in the Name of the stage (I added a full stop into my stage name)
    • Remove the field from the BPF, save it and then re-add the field.

    However I have logged back into my Sandbox environment this morning and the filtering seems to be working again without have to make any changes.  I did notice the version of my instance has been updated to:

    2020_2D00_02_2D00_07_5F00_6_2D00_52_2D00_49.png

    Hope this helps you guys

    Bharat

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 81 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans