Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Message by addErrorMessage() is not displayed when using Subflow from Business rule - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • Message by addErrorMessage() is not displayed when using Subflow from Business rule
KB0861735

Message by addErrorMessage() is not displayed when using Subflow from Business rule


885 Views Last updated : Dec 9, 2023 public Copy Permalink
KB Summary by Now Assist

Description

Customer define Flow action using addErrorMessage() in Paris to display custom error message.

=========================
Process Automation > Flow Designer > New > Action
Name : jw_1006_AddErrorMsg

Script
--------------
(function execute(inputs, outputs) {
gs.addErrorMessage(inputs.message);
})(inputs, outputs);
--------------
=========================

When customer call this FD action from business rule directly, custom error message is displayed as expected.
However, when they call this FD action from BR via subflow, custom error message is not displayed.

Steps to Reproduce

1.Create Flow Action using addErrorMessage(), then publish
  Process Automation > Flow Designer > New > Action

Name : jw_1006_AddErrorMsg
Accessible From : All application scopes
Application : Global

Inputs
Label | Name | Type | Mandatory
-----------------------------------------
Message | message | String | Yes

Script step
Input Variables
Name | Value
-----------------------------
message | action > Message

Script
--------------
(function execute(inputs, outputs) {
// ... code ...
gs.addErrorMessage(inputs.message);
})(inputs, outputs);
--------------

2.Create Business Rule to call FD Action
  System Definition > Business Rules

Name : jw_TestBR01
Table : Incident
Active : Yes
Advanced : Yes

When to run
When : before
Order : 10
Insert : Yes
Update : Yes
Filter Condition
Short description contains TestBR01

Advanced
Condition : (null)
Script
----------------------
(function executeRule(current, previous /*null when async*/ ) {
var inputs = {};
inputs['message'] = gs.getMessage('Test Message From jw_TestBR01'); // String
sn_fd.FlowAPI.executeAction('global.jw_1006_AddErrorMsg', inputs);

current.setAbortAction(true);
current.setWorkflow(false);
})(current, previous);
----------------------

3.Test to create a incident
Incident > Create New
Number : INC0010002
Short description : TestBR01
Save
==>
Test Message From jw_TestBR01
Invalid insert

The custom error message is displayed with "Invalid insert" as expected.
BR:jw_TestBR01 and FD Action:jw_1006_AddErrorMsg works normally.

4.Create Subflow to call FD Action
Process Automation > Flow Designer > New > Subflow

Name : jw_1006_Subflow_01
Application : Global
Accessible From : This application scope only
Run As : User who initiates session

Inputs
Label | Name | Type | Mandatory
---------------------------------------------------
03_sys_id | 03_sys_id | String | Yes
04_err_message | 04_err_message | String | Yes

Outputs
Label | Name | Type
-------------------------
result | result | String

Actions
1:jw_1006_AddErrorMsg
Action : jw_1006_AddErrorMsg
Message : Input > 04_err_message

2:Assign Subflow Outputs
Name | Data
----------------
result | NG

5.Create Business Rule to call Subflow
System Definition > Business Rules

Name : jw_TestBR02
Table : Incident
Active : Yes
Advanced : Yes

When to run
When : before
Order : 11
Insert : Yes
Update : Yes
Filter Condition
Short description contains TestBR02

Advanced
Condition : (null)
Script
----------------------
(function executeRule(current, previous /*null when async*/ ) {

var inputs = {};
var sys_id_03 = current.sys_id;

inputs['03_sys_id'] = sys_id_03; // String
inputs['04_err_message'] = gs.getMessage('Test Message From jw_TestBR02'); // String

var result = sn_fd.FlowAPI.getRunner().subflow('global.jw_1006_Subflow_01').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();

var answer =outputs['result'];

if(answer === 'NG'){
current.setAbortAction(true);
current.setWorkflow(false);
}

})(current, previous);
----------------------

6.Test to create a incident
Incident > Create New
Number : INC0010003 (Sys ID:59f4eff71b6fd810811c520d0a4bcb5a)
Short description : TestBR02
Save
==>
Invalid insert

The custom error message is NOT displayed, only "Invalid insert".

7.Check Flow engine context
Process Automation > Flow Administration > Today's Execution

Created : 2020-10-07 00:07:53
Name : jw_1006_Subflow_01
State : Complete
Runtime : 3
Created by : admin
Sys Id : 2725e33b316fd81075d1d5914dca84df

Open in Operations View

Subflow Input
VARIABLE NAME | TYPE | RUNTIME VALUE
------------------------------------------------------------
03_sys_id | String | 59f4eff71b6fd810811c520d0a4bcb5a
04_err_message | String | Test Message From jw_TestBR02

Subflow Output
VARIABLE NAME | TYPE | RUNTIME VALUE
----------------------------------------
result | String | NG

==>
Subflow set inputs correctly, but custom error message is not displayed
In this situation, FD Action:jw_1006_AddErrorMsg does not work as expected.

Workaround

Create a subflow output with the message to be displayed or status code. 

Pass this output back to the calling business rule who should really display the message anyway


Related Problem: PRB1437310

Potentially Seen In

There is no data to report.

Fixed In

Quebec

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.