Form builder - Select component - Custom Data Source Type - trying to get data into field

I have a form  with a select component. In this select (dropdown) i want show the users being managed by a centain manager (initiator).

I'm using this DAL-query:

In the JS Editor i have this:

async function getUsersManagedBy() {
return await IDVault.get(IDVault.globalQuery('IDM','/rest/access/query/global','ManagerProjectAccounts', [Object.entries(requestPayload.data[2])[1][1][0]])
.then(function (data){
    return data; //Pass the data that you want to set in the field as a parameter to this function.
})
.catch(function (error){ return error;})
}

The select component looks like this:


With this i get the error in my console saying the function data.getUsersByManager is not defined.

Any tips how to fix this?

  • 0

    Hello,

    I have solved this by setting the data type to "Raw JSON" and populating the field from "CustomDefaultValue" function. You can populate it from other functions as well. Function setFieldValue() is your friend. Documentation of the function - https://www.netiq.com/documentation/identity-manager-48/form_builder/data/form_builder.html.

    Best regards,
    Nik

  • 0 in reply to 

    When I run this part:

    function getManagedBy(){
        IDVault.globalQuery('IDM','/rest/access/query/global','ManagerProjectAccounts', ['GivenName','sn'], {'Manager':initiator})
            .then(function(data) {
                return data;
            })
            .catch(function(error) {
                return error;
            })
    }

    I get this error in my console:

    Uncaught (in promise) ReferenceError: IDVault is not defined

  • 0 in reply to 

    Where and when are you calling "getManagedBy()" function? Please try the most basic scenario first. Create a new hidden field and make the IDVault.globalQuery from CustomDefaultValue() function of the field.

  • Suggested Answer

    0 in reply to 

    I've got it working! The problem was in the Entity behind the Query in which the manager attr was not enabled for search.

  • 0 in reply to 

    Hi Wikash,

    I am running on the same issues. I check the Entity and is already enabled for search.

    Please could you share your example of the select component (data-source = custom)?

    I could not fill in the select component with data, although the IDVault.globalQuery is returning data. 

    Many thanks in advance, 

    best regards,

    Evanela 

  • 0 in reply to 

    Hi evanela,

    here is an example of populating the select component with values. Under Data tab, select Data Source Type to be "Custom" and put the following code in the Custom Values field.

    IDVault.globalQuery("IDM", "/rest/access/query/global", "GetAllOrganizations", ["orgID", "orgName"])
    .then(result => {
      // console.log("ou query: ", result);
      var j = [];
      result.forEach(ou => {
        j.push({
          value: ou.orgID[0],
          label: ou.orgID[0] + " " + ou.orgName[0]
        });
      });
      
      instance.setFieldValue(j, "value", "label");
    });

    Do not forget to check "Enable Static Search" if you want to be able to search trough the values.

    This will suffice if you only want to search trough the values and select one. If you also want to set the values from elsewhere, you have to check "Allow the calculated value to be overriden manually". This would be the case, for example if you want to have this component in a datagrid. When you load values you want to populate existing select components with their corresponding values. But you also want to be able to select and search and change those values...

    Best regards, Nik