How to show/hide fields based on the other list field reference table column which is true or false

Sagar S
Tera Contributor

Hi,

 

We have requirement in which on a form there is a  list collector field called 'policy' referencing to another table. In that reference table there is a 'info required'  field which is a true/false . We need show/hide another field 'MNP info' on a form based on the reference table field 'info required'. Any help on how to achieve this.

 

Regards,

Sagar

14 REPLIES 14

@Sandeep Rajput 

thank you for your reply, i probably will have to use Onchange client script since list collector field reference table field record has false and some has true values. Could you please help me with the code

@Sagar S Since the list collector field reference table field record has some false and some true records, how are you going to set the visibility of MNP field on the basis of these multiple values, ideally either you should have a true or a false value to show or hide field. 

The List collector policy field may contain one or more records, if one of the record has the "u_mnpi_info_required" column  is checked (true) then i should show the "u_was_the_information_mnpi" on the form . If none of the records in the list collector has not checked(true) the column "u_mnpi_info_required" , then i should hide the "u_was_the_information_mnpi" on the form

Sagar S
Tera Contributor

I have written onchange client script and script include as below and it is not working, please let me know if anything is wrong.

 

Onchange client script:

 

var userRequestor = g_form.getValue('u_policy');
    var MNPI = new GlideAjax('checkpolicy');
    MNPI.addParam('sysparm_name', 'getPolicyDetail');
    MNPI.addParam('sysparm_Requestor', userRequestor);
    MNPI.getXML(Result);

    function Result(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (answer == true) {
            g_form.setVisible('u_was_the_information_mnpi', true);
            g_form.setMandatory('u_was_the_information_mnpi', true);
        } else
            g_form.setVisible('u_was_the_information_mnpi', false);
    }

}
 
 
Script include:
 
var checkpolicy = Class.create();
checkpolicy.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getPolicyDetail: function() {
        var req = this.getParameter('sysparm_Requestor');
        var poli = new GlideRecord('u_policy');
        poli.addQuery('current.u_mnpi_info_required', true);
        poli.query();
        while (poli.next) {
            if (poli.u_mnpi_info_required == 'true') {
                return true;

            }
        }
    },
    type: 'checkpolicy'
});

Sagar S
Tera Contributor

@Ankur Bawiskar ,

could you please advise if this requirement is achievable. 

 

Regards, 

Sagar