Business Rule not triggering subflow when “Assigned To” (reference field) changes — only works cmnt

Satyam123
Tera Contributor

Hi everyone 👋

I’m working on a Business Rule that triggers a subflow (global.update_jira_ticket) whenever either:

  • Jira Communication (u_communication) changes, or

  • Case Owner (assigned_to) changes.

The subflow should receive:

  • input2 → Reference to sys_user (from assigned_to)

  • input5 → String (u_jira_id)

  • jira_communication → String (optional comment text)

    (function executeRule(current, previous /*null when async*/) {
    try {
    gs.addInfoMessage("From BR start");

    // Skip if Jira ID is empty
    if (!current.u_jira_id) {
    gs.info("BR: Skipping flow because Jira ID is empty");
    return;
    }

    var inputs = {};

    // Jira ID (string)
    inputs['input5'] = current.u_jira_id + '';

    // Case Owner (Assigned To) - Reference.User
    if (current.assigned_to.changes()) {
    inputs['input2'] = current.assigned_to; // passes sys_id reference
    gs.info("Assigned To changed: " + current.assigned_to.getDisplayValue());
    } else {
    inputs['input2'] = '';
    }

    // Jira Communication
    if (current.u_communication.changes()) {
    inputs['jira_communication'] = current.u_communication.getDisplayValue() || '';
    gs.info("Jira Communication changed: " + inputs['jira_communication']);
    } else {
    inputs['jira_communication'] = '';
    }

    gs.info("Inputs sent to flow: " + JSON.stringify({
    input2: '' + inputs['input2'],
    input5: inputs['input5'],
    jira_communication: inputs['jira_communication']
    }));

    // Trigger subflow asynchronously
    sn_fd.FlowAPI.getRunner()
    .subflow('global.update_jira_ticket')
    .inBackground()
    .withInputs(inputs)
    .run();

    gs.info("Subflow triggered successfully");

    } catch (ex) {
    gs.error("Error in BR: " + ex.message);
    }
    })(current, previous);

     

    🔍 What I’ve Tried

    • Passing current.assigned_to directly (sys_id)

    • Passing current.assigned_to.toString()

    • Verified input2 in subflow is Reference.User

    • Verified the BR “When to run” condition includes Case Owner changes

    • Tested with inForeground() instead of inBackground() — same result




    Property Value
    Tablesn_customerservice_case
    Whenafter
    Insert
    Update
    Delete
    Advanced
    Filter conditionJira Communication changes OR Case Owner changes AND Jira ID is not empty
0 REPLIES 0