Remote catalog variable update in provider task

supriyapriy
Tera Contributor

In a Service bridge Provider instance publish a remote catalog item and consumer can raise a request from consumer instance and create a provider task and that provider task reflect on the provider instance now in a provider task record parent contain RITM
My requirement is if any  catalog variable update in the RITM (parent field refers in provider task) it should update provider task also help me with the logic to achieve this

1 REPLY 1

pr8172510
Kilo Guru

Hi @supriyapriy,

Good question — this is a common requirement when working with Service Bridge and syncing data between RITM and Provider Task.

 Recommended Approach

Since your Provider Task has a reference to RITM (parent field), you can sync catalog variables using a Business Rule on RITM.


🔹 Step 1: Create Business Rule on RITM

  • Table: sc_req_item
  • When: after update
  • Condition: Check if relevant variables changed (optional but recommended)

🔹 Step 2: Script Logic

You need to fetch the related Provider Task(s) and update them.

Example:

(function executeRule(current, previous) {

    // Example: variable name = "u_field1"
    var newValue = current.variables.u_field1;

    var gr = new GlideRecord('your_provider_task_table'); // replace with actual table
    gr.addQuery('parent', current.sys_id);
    gr.query();

    while (gr.next()) {
        gr.u_field1 = newValue; // map accordingly
        gr.update();
    }

})(current, previous);

🔹 Step 3: Important Notes

✔ Catalog variables are accessed using:

current.variables.variable_name

✔ Make sure:

  • Field mapping exists on Provider Task (e.g., u_field1)
  • Variable names match correctly

🔹 Optional (Better Design)

If you have multiple variables:

  • Use a mapping table or
  • Store variables in JSON and sync dynamically

🔹 Alternative Approach

If near real-time sync is not mandatory:

  • Use Flow Designer
  • Trigger: RITM updated
  • Action: Update Provider Task

Best Practice

Avoid syncing all variables blindly.
Only sync required fields to keep performance optimal.