SCTASK Fields to Update a Record on a ServiceNow Table

JerickA
Tera Contributor

Hello everyone, I am currently developing a catalog item containing these 5 SCTASKs. The requestor specified what will each SCTASK will contain which are fields that differ from the other per SCTASK. Every SCTASK contains different fields.

They also requested that this fifth or final SCTASK will have to update a target record on a ServiceNow table when the state was changed to Closed Complete. 

I would like to kindly seek everyone's recommendations and expert judgement as to how to execute or configure this, if ever this is possible. 

Thank you in advance.

2 REPLIES 2

vaishali231
Kilo Sage

Hey @JerickA 

Yes, this requirement is achievable in ServiceNow.

Since the target record should only be updated when the final (5th) SCTASK reaches Closed Complete, there are a couple of approaches available.

Option 1: Flow Designer 

If your catalog item uses Flow Designer:

  1. Create the five Catalog Tasks as part of the fulfillment process.
  2. Wait for the final SCTASK to reach the Closed Complete state.
  3. Use an Update Record action to update the target record in the required table.

This is a low-code and maintainable solution that keeps the logic within the catalog fulfillment flow.

Option 2: Business Rule on sc_task

If you want the update to occur regardless of how the task is completed (UI, API, Flow, Import, etc.), a Business Rule on the sc_task table is a reliable option.

Example After Update Business Rule

Table: sc_task

When: After Update

Condition:

State changes to Closed Complete

Task is the designated final SCTASK

Script :

(function executeRule(current, previous) {
    // Verify task has been moved to Closed Complete
    if (!current.state.changesTo('3')) { // Replace 3 with your Closed Complete value if different
        return;
    }
    // Identify the final SCTASK
    // Use a custom flag, task definition, or unique short description
    if (current.short_description != 'Final Approval Task') {
        return;
    }
    // Update target record
    var targetGR = new GlideRecord('u_target_table');
    // Example reference field on the task that stores the target record
    if (targetGR.get(current.u_target_record)) {
        targetGR.u_status = 'Completed';
        targetGR.u_completion_date = gs.nowDateTime();
        targetGR.update();
    }
})(current, previous);

 

************************************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh

Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb



pr8172510
Tera Guru

Hey @JerickA,

Yes, this is definitely possible. 

You Can Use Flow Designer 

 

  1. Trigger: Use "Record Updated" on the sc_task table.

  2. Condition: State changes to Closed Complete AND the Task is the 5th one. You can identify this by the task's Short Description, a specific Assignment Group, or a Custom Field you populate via catalog variables.

  3. Action: Add an "Update Record" action.

  4. Target: For the Record field, click the data pill picker, then "Dot-walk" (navigate) from your trigger record to the specific target table record you want to update. For example: Trigger Record → Parent Request Item → Your Target Record's field.

    Or  You Can use 
    Business Rule (Server-Side)

     

     

    Field Value
    TableCatalog Task [sc_task]
    WhenAfter
    Update✓ (checked)
    Conditioncurrent.state == '3' && current.short_description == 'Your Fifth Task Name' (Use 3 for Closed Complete)
(function executeRule(current, previous /*null when async*/) {
    // Get a reference to the specific record you need to update
    // For example, getting the parent RITM:
    var parentRitm = current.request_item.getRefRecord();
    
    // Or, if you need a different custom table record:
    // var targetRecord = new GlideRecord('your_custom_table');
    // targetRecord.get('target_record_sys_id');

    // Update the record
    if (parentRitm) {
        parentRitm.setValue('field_to_update', 'new_value');
        parentRitm.update();
    }
})(current, previous);