Copy the task comments to the record producer request comments via UI Action

jkelvynsant
Tera Contributor

Hello everyone,

I'd like the last comment of my task to be sent to the request's commenters. Currently, it's only getting the string "Request for additional information:" but can't get the value.

 

Here's the script I created for the UI action:

if (gs.nil(current.comments)) {
gs.addErrorMessage("The 'Additional Comments' field is required");
current.setAbortAction(true);
}

current.state = '5';
current.update();

var num = current.parent;
if (num) {
var numGR = new GlideRecord('x_acel2_csc_register');
if (numGR.get(num)) {
numGR.u_stage = '4';
numGR.state = '5';

numGR.comments = "Request for additional information:" + current.comments;

numGR.update();
}
}
2 ACCEPTED SOLUTIONS

Chaitanya ILCR
Kilo Patron

Hi @jkelvynsant ,

 

try this

 

if (gs.nil(current.comments)) {
    gs.addErrorMessage("The 'Additional Comments' field is required");
    current.setAbortAction(true);
}

current.state = '5';
current.update();

var num = current.parent;
if (num) {
    var numGR = new GlideRecord('x_acel2_csc_register');
    if (numGR.get(num)) {
        numGR.u_stage = '4';
        numGR.state = '5';

        numGR.comments = "Request for additional information:" + current.comments.getJournalEntry(1);

        numGR.update();
    }
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

Bhimashankar H
Mega Sage

Hi @jkelvynsant ,

 

To get the comments you need to use getJournalEntry() function.

 

Replace the second last line of code with below code snippet.

 

numGR.comments = "Request for additional information:" + current.comments.getJournalEntry(1); //Latest comment
//If you want all the commnents then need to use .getJournalEntry(-1), when doing only once.

 

Thanks,

Bhimashankar

 

---------------------------------------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful'. Thanks!

View solution in original post

4 REPLIES 4

Chaitanya ILCR
Kilo Patron

Hi @jkelvynsant ,

 

try this

 

if (gs.nil(current.comments)) {
    gs.addErrorMessage("The 'Additional Comments' field is required");
    current.setAbortAction(true);
}

current.state = '5';
current.update();

var num = current.parent;
if (num) {
    var numGR = new GlideRecord('x_acel2_csc_register');
    if (numGR.get(num)) {
        numGR.u_stage = '4';
        numGR.state = '5';

        numGR.comments = "Request for additional information:" + current.comments.getJournalEntry(1);

        numGR.update();
    }
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Perfect! It worked, thank you very much

Bhimashankar H
Mega Sage

Hi @jkelvynsant ,

 

To get the comments you need to use getJournalEntry() function.

 

Replace the second last line of code with below code snippet.

 

numGR.comments = "Request for additional information:" + current.comments.getJournalEntry(1); //Latest comment
//If you want all the commnents then need to use .getJournalEntry(-1), when doing only once.

 

Thanks,

Bhimashankar

 

---------------------------------------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful'. Thanks!

Perfect! Thank you very much