We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Need to populate RITM's Approver names on reference field

cp10
Tera Contributor

Hi @Ankur Bawiskar 

 

I have catalog form and need to populate the RITM's approvers on refrence field. Created two fields on form.
1) Ritm Number (Ref. to sc_req_item table)
2)Approver (Ref.to sys_user table)

I want to show only the names of Approver which is triggered for the Ritm request. I have created script include and reference qualifier but its not working. could you please help me on this I am new to this code.

 

cp10_0-1722354119062.png

 

cp10_1-1722354348386.png

Script Include:

getApprover: function(cur) {
                var store = [];
                var gr = new GlideRecord('sc_req_item');
                gr.addQuery('sys_id', cur);
                gr.query();
                if (gr.next()) {
                    var assignee = gr.number;
                    gs.info('test' +assignee);

                }
                if (assignee != '') {
                    var GlideCatg = new GlideRecord('sysapproval_approver');
                    GlideCatg.addQuery('sysapproval', assignee);
                    GlideCatg.query();
                    if (GlideCatg.next()) {

                        var sysApp = GlideCatg.approver;
                        if (sysApp != '') {
                            var store = sysApp.split(",");
                            for (i = 0; i < sysApp.length; i++) {
                                var GlideApp = new GlideRecord('sys_user');
                                GlideApp.addQuery('name', sysApp);
                                GlideApp.addQuery();
                                while (GlideApp()) {
                                    store.push = GlideApp.sys_id;
                                }

                            }
                        }
                    }
                }
             return 'sys_idIN' + store;      
                },

                type: 'GetApporverDetails'
            });

Reference qualifier :

 

cp10_2-1722354615599.png

 

 

Thanks.

 

 

 

1 REPLY 1