capturing onhold reason and duration in tow new fields

Mansi roy
Tera Contributor

Hello All,

 

Could anyone please help me how to acheive the below one.

 

I need to capture the onhold reason of catalog task so that the reason will not get clear after closed complete of task.And on hold duration.

 

There is a field in the form pending reason when the state is getting changed to pending.I need to copy this value in another new field 'hold reason' so that the value should not clear upon closed complete.I need to capture the onhold duration also.

5 REPLIES 5

Mark Manders
Mega Patron

Why not just copy it to the worknotes, so it will always stay in the activity log of the task? 

Since this is already custom (no on hold reason on catalog task OOB), you are now creating second field to capture the same data. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hello @Mark Manders,

 

actually the value from the new field is getting cleared once the state is getting to clsoed complete.I need to capture so that in report it will visible which tasks were in onhold ..this existing field was manual field not OOB one...I need for every table like incident problem change and task.

Mark Manders
Mega Patron

Then create your new field on the 'task' table, so you have it anywhere. And if your 'on hold' reason also is on task, you can easily create a BR on task level (so it is inherited down) to update the new field you are creating. If it's not the same field on all other tables, you will have to apply the BR on each table.

 

Trigger it on change of the 'on hold reason' field (and on hold reason is not empty) and set your script like

 current.[your_new_field] += current.on_hold_reason + '\n'; // where 'on hold reason' is the old field that is getting emptied now. This is assuming your new field is a string field. It will add the reason the first time a record goes on on hold and the next time it will enter the new reason below it. You could also apply it with timestamps if needed (current.on_hold_reason + ' ' + current.sys_updated_on + '\n';)


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

hello @Mark Manders ,

 

I have tried with below script but the value is not getting captured once the state is changing to resolved state.

 

(function executeRule(current, previous /*null when async*/ ) {
    var grIncident = new GlideRecord("incident");
    grIncident.query();
    while (grIncident.next()) {
        grIncident.setValue("u_inc_hold", grIncident.getDisplayValue("hold_reason"));
        grIncident.update();
    }

})(current, previous);