PaulNieuwelaar / alertjs

Dialog Builder allows you to create fully customisable dialogs and popups in Dynamics 365.
https://www.magnetismsolutions.com/our-products/alertjs-alert-popup-for-d365
Other
96 stars 38 forks source link

Issue with populating lookups in the new Dynamics 365 UCI (Unified Client Interface) #29

Closed Robimbrie closed 4 years ago

Robimbrie commented 4 years ago

Hi, Is the new Dynamics 365 UCI (Unified Client Interface) supported with version 3.0 of alert js? we currently have the 3.0.7 managed solution installed and have purchased a licence.

We are preparing for upgrade, and in our testing most things work, but we found that lookups are not behaving correctly, as the value selected is never getting populated, and always comes back as null in the response. As stated this is only happening in the new D365 UCI, and works in the old web UI in D365 v9.

The lookup prompt behaves the same and pops up correctly but nothing is ever returned: image

A code snippet of our JS is below:

        var options = getOptions();
        var fieldsArray = [
            new Alert.Lookup(
                {
                    id: "actionofficer",
                    entityTypes: ["systemuser"],
                    customFilters: ["<filter type='and'><condition attribute='isdisabled' value='0' operator='eq'/></filter>"]
                }, { style: "margin-top:20px" })];

        new Alert(options).showPrompt(fieldsArray);

 function successCallBack(responses){
    var user = responses[0].value;
}

When debugging we get null in the value:

image

PaulNieuwelaar commented 4 years ago

Hi, thanks for bringing this bug to my attention. I've just released an updated version which includes a fix for this. https://github.com/PaulNieuwelaar/alertjs/releases/download/v3.0/AlertJS_3_0_9_managed.zip

The LookupOptions work a little bit differently now, so I will be updating the Alert.js documentation to align with Microsofts (https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/lookupobjects).

Cheers, Paul

PaulNieuwelaar commented 4 years ago

Hi, the documentation has been updated to include these 2 new lookup options:

  • disableMru: bool. Decides whether to display the most recently used (MRU) items. Available only for Unified Interface.
  • filters: Array of Objects. Used to filter the lookup results. Each object in the array contains the following attributes:
    • filterXml: String. A FetchXML custom filter to apply on top of the lookup view filters. This should not be URL encoded.
    • entityLogicalName: String. The entity type to apply this filter to.

The customFilters (which previously did not work in the unified interface anyway) has also been deprecated and replaced by the new filters. However existing code using the old customFilters will continue to work (even in the unified interface), as it now just uses the new filters under the hood.

Cheers, Paul

Robimbrie commented 4 years ago

Hi Paul,

You're a Legend. Thanks so much for getting to this issue so quickly. I have tested in the UCI and now the response is coming back as expected.

One existing issue I still found was that the search field on the Alert was not getting copied to the lookup field. This was happening previously on the WebUI.

image

Is there a way to do this, or alternatively, have an option to disable the lookup field on the Alert so users cannot input text, and only allow them to click the lookup button.

Kind regards,

Rob

PaulNieuwelaar commented 4 years ago

Hi Rob, unfortunately the default search text is no longer a valid property of the lookup objects function in the unified interface. I'm currently looking at alternative solutions, with the simplest being just disabling the text box, however it should still allow clearing the lookup value, so it may not be a straight forward solution. Cheers, Paul

PaulNieuwelaar commented 4 years ago

Microsoft have added support for searchText, so this is working again with the CRM Online May update.