activity.result in workflow run script activity

Joshuu
Kilo Sage

Hi All,

 

I have written the below script in the workflow run script activity. The change is closed and it is successful but it is not moving further from this activity. what could be the reason? Could you please assist?

 

 

var CR = new GlideRecord('change_request');
var CR = new GlideRecord('change_request');
CR.addQuery('parent', current.sys_id);
CR.query();
if (CR.next()) {
    if (CR.state == '4') {
        activity.result == 'Canceled';
    } else if (CR.state == '3') {
        if (CR.close_code == 'successful')
            activity.result == 'Successful';
        else
            activity.result == 'Failed';
    }
}

 

 

Thanks & Regards.

7 REPLIES 7

Appanna M
Tera Guru

Hello @Joshuu ,

 

Can you try this below once.

var CR = new GlideRecord('change_request');
CR.addQuery('parent', current.sys_id);
CR.query();
if (CR.next()) {
    if (CR.state == '4') {
        activity.result = 'Canceled'; // Corrected assignment operator & use backend value of the activity condition
    } else if (CR.state == '3') {
        if (CR.close_code == 'successful') // Corrected variable name
            activity.result = 'Successful'; 
        else
            activity.result = 'Failed'; 
    }
}

 

Please Mark My Answer as Helpful and Accept as Solution, if you find this article helpful or resolves your issue.

Hi @Appanna M ,

 

Thanks for your response.

 

I have updated it, but still no luck. As per the below screenshot it is stuck in that activity.

 

priyarao_0-1715093162780.png

 

Hi @Joshuu ,

 

Can you confirm on below:

1. Which table is your workflow built on?  I am suspecting the issue is with line number 2 with your add Query here. Can you confirm the table name to help you further.

2. Also I do not think you need to validate state value within quotes, you can update your script to below:

var CR = new GlideRecord('change_request');
CR.addQuery('parent', current.sys_id);
CR.query();
if (CR.next()) {
    if (CR.state == 4) {
        activity.result = 'Canceled'; // Corrected assignment operator & use backend value of the activity condition
    } else if (CR.state == 3) {
        if (CR.close_code == 'successful') // Corrected variable name
            activity.result = 'Successful'; 
        else
            activity.result = 'Failed'; 
    }
}

 

 

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi @shloke04 , @Appanna M ,

 

It is in RITM table. Once the tasks are completed for RITM then a change request will be created.

I have removed the quotes and tried but still no luck.

Also, I have put some logs and checked and i don't even see anything under logs table.