Using DAL Queries in Form Builder

Hello,

does someone know how to use DAL Queries in Form Builder?

Actually I am looking for an example similar as shown in the Documentation, but using Form Builder. I wonder why the Documentation still refers the old forms???

Any input is very appreciable:)

Many thanks in advance und best regards,

Evanela

Tags:

Parents
  • Suggested Answer

    0

    Information about form builder is found in Administrator’s Guide to Form Builder but it is still not complete.

    First you have to setup the query in DAL and deploy it. If it returns some errors when being called later, try flushing the cache on IA.

    On the form builder you have 2 options: DN Query component or query from code. I rarely use the first one.

    The code is as follows. Note that if your query has no parameters, do not pass the last parameter at all. Passing empty braces wont work {}.

    IDVault.globalQuery("IDM", "/rest/access/query/global", "<dal_query_key>", [<list_of_return_attr>], {<json_of_query_parameters>})

    Real example:

    IDVault.globalQuery("IDM", "/rest/access/query/global", "CheckMail", ["CN"], {"mailToCheck": input, "username": currentUserCN})
    .then(result => {
        console.log(result);
    })

    I hope this answers your question.

    Best regards, Nik

  • 0 in reply to 

    Hi Nik,

    thanks a lot for your answer. This is very helpful. 

    One more question:

    I was thinking to use the "Select" component of Form Builder and populating it with users from a global query and than be able to search by user name or userId.

    How to configure such component and populate with query data?

    Thanks and best regards,

    Evanela

  • Verified Answer

    +1 in reply to 

    Hi,


    Either you calculate the display value in a dalCalculatedAttribute on the entity, and then you can set the value like this:

    function yourSelectField_CustomDefaultValue () {
            IDVault.globalQuery('IDM', '/rest/access/query/global', 'getUsers', ['DALCalculatedAttribute'], { 'department': data.departmentField })
                .then(function (resp) {
                    instance.setFieldValue(resp, 'dn', 'DALCalculatedAttribute')
                })
                .catch(function (error) { console.log(error) })
    }

    You could also use the dynamic entity component if you don't need any query parameters.

    Or you can calculate the display value in the form like this:

    function yourSelectField_CustomDefaultValue () {
            IDVault.globalQuery('IDM', '/rest/access/query/global', 'getUsers', ['FullName', 'userID'], { 'department': data.departmentField })
                .then(function (resp) {
                    resp = resp.map(user => ({
                        dn: user.dn,
                        displayValue: (user.FullName + " - " + user.userID )
                    }))
                    instance.setFieldValue(resp, 'dn', 'displayValue')
                })
                .catch(function (error) { console.log(error) })
    }

    Best regards,
    Philip

Reply
  • Verified Answer

    +1 in reply to 

    Hi,


    Either you calculate the display value in a dalCalculatedAttribute on the entity, and then you can set the value like this:

    function yourSelectField_CustomDefaultValue () {
            IDVault.globalQuery('IDM', '/rest/access/query/global', 'getUsers', ['DALCalculatedAttribute'], { 'department': data.departmentField })
                .then(function (resp) {
                    instance.setFieldValue(resp, 'dn', 'DALCalculatedAttribute')
                })
                .catch(function (error) { console.log(error) })
    }

    You could also use the dynamic entity component if you don't need any query parameters.

    Or you can calculate the display value in the form like this:

    function yourSelectField_CustomDefaultValue () {
            IDVault.globalQuery('IDM', '/rest/access/query/global', 'getUsers', ['FullName', 'userID'], { 'department': data.departmentField })
                .then(function (resp) {
                    resp = resp.map(user => ({
                        dn: user.dn,
                        displayValue: (user.FullName + " - " + user.userID )
                    }))
                    instance.setFieldValue(resp, 'dn', 'displayValue')
                })
                .catch(function (error) { console.log(error) })
    }

    Best regards,
    Philip

Children