send a notification once a variable is checked in catalog task using flow designer

AanchalS
Tera Contributor

I need to make a functionality that once a variable is checked true on a catalog task, there should be a notification sent, but how do i accomplish this using a flow since if I am placing this flow action below the create catalog task its not being run untill the task is complete as the wait field is checked on the task action, if I am running it on parallel its running once and returning false as initially the checkbox is unchecked, how to accomplish this.

4 REPLIES 4

pratikjagtap
Giga Guru

Hi @AanchalS ,

 

1.Go to Flow Designer > New Flow

2.Trigger:

  • Table: sc_task (Catalog Task)
  • Trigger: Updated
  • Filter:
  • Variable [your_variable_name] changes to true
  • Task state is not Closed (optional, based on your needs)

3.Actions:

  • Add a Send Notification action
  • Configure the notification (e.g., to a group, user, or requestor)

If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Pratik

sunil maddheshi
Tera Guru

@AanchalS 

You can try a Subflow with a Wait for Condition

Create a subflow that waits for the variable to be updated.

 Steps:

  1. Create a Subflow

    • Name: Wait for Checkbox on Catalog Task

    • Inputs:

      • Catalog Task (Type: Task [sc_task] Reference)

      • Variable name or hard-code the variable you're checking

  2. Add a "Wait for Condition" Action

    • Table: sc_task

    • Condition: YourVariableName is true

    • This waits until the variable is checked.

  3. Add a "Send Notification" Action

    • Trigger your email once the condition is met.

  4. Save and Publish the subflow.


 2. In Your Main Flow: Call This Subflow in Parallel

In your main flow (e.g., associated with the Catalog Item or Request):

  1. After creating the Catalog Task:

    • Use a Parallel branch:

      • Branch 1: Continue standard flow (e.g., wait for Catalog Task completion).

      • Branch 2: Call your "Wait for Checkbox on Catalog Task" subflow, passing the created task as input.


Please mark correct/helpful if this helps you

 

I am not able to set the condition since its only showing the fields of the sc_task table

Ankur Bawiskar
Tera Patron
Tera Patron

@AanchalS 

you can create a subflow which accepts few parameters such as TASK SysId etc

Then within that subflow have logic to send email to whoever you want with email body etc

Then have after update business rule on sc_task table

Condition: 

current.request_item.cat_item.name == 'Your Item Name' && current.variables.<variable_name>.changes()

Script:

// trigger your subflow from script

Scripting with Flows, Subflows, and Actions 

(function() {
 
try {
var inputs = {};
inputs['taskSysId'] = current.sys_id; 
 
// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
// sn_fd.FlowAPI.getRunner().subflow('subflow_name').inBackground().withInputs(inputs).run();
 
// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
var result = sn_fd.FlowAPI.getRunner().subflow('subflow_name').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
 
// Current subflow has no outputs defined.
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
 
})();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader