Want to show RITM variable in the sysapproval_approver .

NeethuB
Tera Contributor

Want to show RITM variable in the sysapproval_approver.
For that i have created a feild called description (u_description).
I want to show data inside that feild.
eg:
Title:xyx
requestot:ghi 

22 REPLIES 22

Jaspal Singh
Mega Patron
Mega Patron

Hi Neethu,

Do you mean all variables to be shown in the field? Is there any specific need for it? Also, what have you tried would you mind sharing for a quick review.

NeethuB
Tera Contributor

ys i want to display all variable in this feild as :
question1: value1
question2: value2
.

.

.

etc
i want to show this variable data with to the approver .
i just created a feild u_description in the sysapproval_approver table

 

Ankur Bawiskar
Tera Patron
Tera Patron

@NeethuB 

why to store it in separate field when you can see it by expanding the Summary here?

The approver can also view the RITM

if you still require then you can use before insert BR on sysapprroval_approver table with this

Condition: current.source_table == 'sc_req_item'

Script:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var arr = [];
    var ritm = new GlideRecord('sc_req_item');
    ritm.get('sys_id', current.sysapproval);
    var variables = ritm.variables.getElements();
    for (var i = 0; i < variables.length; i++) {
        var question = variables[i].getQuestion();
        var label = question.getLabel();
        var value = question.getDisplayValue();
        if (label != '') {
            arr.push('  ' + label + " = " + value + "\n");
        }
    }
    current.u_descriptio = 'Variable Summary\n' + arr.toString();

})(current, previous);

AnkurBawiskar_0-1747652691812.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 
Not working,
can we use sc_item_option_mtom table ?
By using above code still the description feild is empty