Help mapping Interaction from REQ down to sc_task

Andrew Meza
Tera Expert

Hey all,

In our system, REQs are mapped to Interactions. For some reason, on certain records only the REQ itself is mapped — the related RITMs and sc_tasks don’t get it.

I was able to figure out how to link the REQ’s Interaction to all of its child RITMs, and that works fine. Now I’m trying to do the same for the sc_task records under those RITMs, but my Flow keeps running into errors.

The goal:

  • Target all sc_task records whose parent REQ has an Interaction

  • Map that same Interaction onto the sc_task

Has anyone else run into this or built something similar? Does my approach sound off, or would you recommend a different way of handling it?

Screenshots of my Flow and error messages are attached for reference.

Thanks in advance for any ideas!

 

AndrewMeza_0-1755706045175.png

 

3 REPLIES 3

Rafael Batistot
Tera Sage

Hi @Andrew Meza 

May you try those option to solve your issue

A)

  • After your “Update RITMs with Interaction” step, add:

    1. Get Related Records → Table sc_task, condition request_item = current RITM.sys_id.

    2. For Each → loop those tasks.

    3. Update Record → set Interaction field = Interaction from the REQ.

Watch out: if you’re processing a REQ with 100s of tasks, the Flow can become heavy.


B)

This is often cleaner and more performant than Flow if you need it to happen consistently:

 
(function executeRule(current, previous /*null*/) {
    // Business Rule on sc_req_item (after update, when Interaction changes)
    if (current.interaction.changesToNotEmpty()) {
        var taskGr = new GlideRecord('sc_task');
        taskGr.addQuery('request_item', current.sys_id);
        taskGr.query();
        while (taskGr.next()) {
            taskGr.interaction = current.interaction;
            taskGr.update();
        }
    }
})(current, previous);

 

will this BR you provided go back and find all the records that need to be fixed?

larias
Tera Contributor

Thanks for posting this.