Add worknote of sysapproval_approver record

Aruna Sree Yela
Tera Guru

Hi, I have a workflow where approval group activity was setup.

 

I need to put short description of group approval record[sysapproval_group] into approval record[sysapproval_approver] comments.

 

Tried with before insert Business Rule with the below code

 

 

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

    var grpRec = current.group;
    current.comments = "test1 " + grpRec + " end1";
    current.comments = "test2 " + grpRec.short_description + " end2";
    current.comments = "test3 " + current.state + " end3";

    current.update();

})(current, previous);

 

 

 

Output:

ArunaSreeYela_0-1709216274209.png

 

I can get the sys_id of the group record[sysapproval_group] but its not fetching thats short_description.

Note: group field is reference

 

Any guidance please!

 

Thanks

8 REPLIES 8

_Gaurav
Kilo Sage

Hi @Aruna Sree Yela 
Can you try the below code, I hope this might work for you.

 

 

 

 

var grpRec = current.group;
    current.comments = "test1 " + grpRec + " end1";
    current.comments = "test2 " + current.group.short_description + " end2";
    current.comments = "test3 " + current.state + " end3";

    current.update();

 

 

 

Or if not working just glide to the sysapproval_group table, get the short description value, and use it.

 

 

 

var sd='';
     var grpRec = current.group;
    current.comments = "test1 " + grpRec + " end1";
     var grpApp = new GlideRecord('sysapproval_group');
    if(grpApp.get(grpRec)){
           sd = grpApp.getValue('short_description');
     }
    current.comments = "test2 " + sd + " end2";
    current.comments = "test3 " + current.state + " end3";

    current.update();

 

 

 

 

Please mark this as helpful and accept it as a solution if this works for you.
Thanks!

No luck @_Gaurav 

 

Tried both, but short description was getting blank.

 

In the below code, I added one comment inside if, but I dint get that on worknote. Maybe its not entering inside that.

 

 var sd = '';
    var grpRec = current.group;
    current.comments = "test1 " + grpRec + " end1";
    var grpApp = new GlideRecord('sysapproval_group');
    if (grpApp.get(grpRec)) {
        current.comments = "inside if";
        sd = grpApp.getValue('short_description');
    }
    current.comments = "test2 " + sd + " end2";
    current.comments = "test3 " + current.state + " end3";

    current.update();

 

Output:

ArunaSreeYela_0-1709223805512.png

 

 

@Aruna Sree Yela 
Your group is referring to which table?

@_Gaurav 

Group field referring to - [sysapproval_group] table

 

Table [sysapproval_approver] is having group field referring to [sysapproval_group].

 

And both the tables are OOTB