Updated date field into a date variable on task

Darlene York
Tera Contributor

Good Evening,

 

I have a requirement to put the updated date into a task variable when all the approvals of a request are all approved and the task is created.  

 

I need to take the updated date from the RITM and put in the Approved date field on the task.  

 

Thank you

 

 

1 ACCEPTED SOLUTION

rohansargar
Kilo Guru

Hello @Darlene York,

try to create After Update business rule for this on sc_req_item table,

condition = current.approval == 'approved'

// Check if all approvals are approved
if (current.approval == 'approved') {
    
    // Query associated tasks (e.g., Catalog Tasks)
    var taskGR = new GlideRecord('sc_task');
    taskGR.addQuery('request_item', current.sys_id);
    taskGR.query();

    while (taskGR.next()) {
        // Assuming 'approved_date' is a variable or field on the task
        // Use the RITM's updated date (last update timestamp)
        taskGR.approved_date = current.sys_updated_on;
        taskGR.update();
    }
}

 

Mark Helpful if you issue got resolved,

Regards,

Rohan

View solution in original post

2 REPLIES 2

rohansargar
Kilo Guru

Hello @Darlene York,

try to create After Update business rule for this on sc_req_item table,

condition = current.approval == 'approved'

// Check if all approvals are approved
if (current.approval == 'approved') {
    
    // Query associated tasks (e.g., Catalog Tasks)
    var taskGR = new GlideRecord('sc_task');
    taskGR.addQuery('request_item', current.sys_id);
    taskGR.query();

    while (taskGR.next()) {
        // Assuming 'approved_date' is a variable or field on the task
        // Use the RITM's updated date (last update timestamp)
        taskGR.approved_date = current.sys_updated_on;
        taskGR.update();
    }
}

 

Mark Helpful if you issue got resolved,

Regards,

Rohan

Rohan,

 

Thank you very much!