Help with Workflow + Subflows + Catalog Variables - Using custom table

barbaratosetto
Tera Contributor

Hi everyone,

I need some help designing a flow that combines approvals and task creation, using custom tables in ServiceNow. Here’s the scenario:

  • Tables

    • LU DH (parent table)

    • LU DT Offering (child of LU DH)

    • The key fields in LU DT Offering are:

      • Owner (who will approve)

      • Flag1 to Flag6 (booleans)

      • Text1 to Text6

      • Assignment Group1 to Assignment Group6

Business rule:
If, for example, Flag1 is checked in LU DT Offering, then a Task must be created (via Workflow):

  • Task description should be populated with Text1

  • Task assignment group should be populated with Assignment Group1

  • The same logic applies to Flags 2 to 6, respectively.


What I have built so far

  • My flow trigger is Service Catalog (I don’t have the plugin "Flow Designer support for the Service Catalog " to directly trigger on sc_req_item).

  • I created a subflow called Get LU DT Catalog Variables, intended to pull Catalog Variables from the RITM (since the end user selects the sub_business_area variable, which is stored on the RITM). The link between these should be through the requested_item_sys_id and the sub_business_area.

    Inside the action I built (called Get LU DT Catalog Variables Action), there is a Script step to get the sub_business_area sys_id:

Inputs for the Script Step:

  • requested_item_sys_id (String)

Outputs:

  • sub_business_area (via data pill)

  • sub_business_area_sys_id (via data pill)
    Script Step:

    (function execute(inputs, outputs) {
    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(inputs.requested_item_sys_id)) {
    var vars = ritm.variables;

    outputs.sub_business_area = vars.sub_business_area_1 ? vars.sub_business_area_1.toString() : '';
    outputs.sub_business_area_sys_id = vars.sub_business_area_1 ? vars.sub_business_area_1.sys_id.toString() : '';

    } else {
    gs.warn('RITM not found in Action Get Catalog Variables: ' + inputs.requested_item_sys_id);
    }
    })(inputs, outputs);

     

    I also created a subflow to request approval from the DT Owner. This subflow expects:

    • lu_dt_offering (Reference to LU DT Offering)

    • requested_item (Reference to Requested Item)

    • output: rejected (string)
      When I test this subflow by itself, it works fine as long as I manually select a valid LU DT Offering.

 

The current problem

In my main flow, I try to wire things up in this order:

  1. Call the action Get LU DT Catalog Variables Action

  2. Then call the subflow Get LU DT Catalog Variables

  3. Then call the subflow DT Owner Approval

At runtime, when I pass the sub_business_area (or its sys_id) as the reference input for the DT Owner Approval subflow, I get the following error: "is not a valid record" as well in the log: "Encountered error executing instruction: ActionErrorEvalInstruction{id=4, conditions=[], statusKey=c1o.__action_status__, dontTreatAsErrorKey=c1o.__dont_treat_as_error__}, errorMessage: is not a valid record., errorCode:1"

and: "com.snc.process_flow.exception.OpException: is not a valid record"

 

Because the flow stops at the DT Owner Approval step, I have not even been able to test the task creation logic yet.

 

Is there a better way to pass the sub_business_area variable from the RITM so I can identify the correct LU DT Offering in the approval subflow?
Is the architecture of linking requested_item with LU DT Offering based on the sub_business_area even correct?
Also, I am not sure if this entire design (Catalog Variables + subflows + Workflow to create tasks) is the best pattern — I’d be very open to suggestions for a better approach.
Finally, when adding the DT Owner Approval subflow to the main flow, I’m not confident about populating the inputs correctly (especially reference fields vs sys_id).

 

 

0 REPLIES 0