
Best Practice Supporting Documentation
Definition: Invalid Column in Flow or Action
Reasoning for Best Practice: When scripting is used within flows, an object named “fd_data“ is used to reference data from previous steps. It is possible for the person writing the script to accidentally use an incorrect object name or field name. This will result in undefined data if the field does not exist in the table.
Bravium Lab's Best Practice Rationale: Using scripting within flows in ServiceNow requires a clear and accurate reference to objects and fields to ensure that the intended data is properly utilized throughout the flow. The object "fd_data" serves as a crucial tool for referencing data from previous steps, but if an incorrect object name or field name is introduced in the script, it could lead to unexpected behavior, such as undefined or erroneous data being passed along.
Implementing a best practice that flags invalid column names or references within flow scripts ensures that flows are both reliable and maintainable. By catching these errors early, we can avoid operational disruptions, prevent data inconsistencies, and reduce time spent troubleshooting issues related to incorrect references. This helps maintain the integrity of business processes and improves the overall quality of automated workflows.
Additionally, adherence to this best practice encourages more careful script development, fosters consistency across flows, and promotes better collaboration between developers by ensuring that scripts behave as expected when working with flow data.
Helpful Information: https://docs.servicenow.com/bundle/washingtondc-build-workflows/page/administer/flow-designer/concept/inline-scripts.html#d106167e250
Definition: FD_DATA References Non-Existent Fields or Objects
Reasoning for Best Practice: When scripting is used within flows, an object named fd_data references data from previous steps. A person can add more steps before the current step, which could render the previously used step number incorrect, requiring the person to update the step number in the script. This will result in redundant and incorrect data retrieval.
Bravium Lab's Best Practice Rationale: In flows that use scripting, the "fd_data" object is a critical mechanism for referencing data from earlier steps in the flow. However, changes to the flow, such as adding or reordering steps, can cause the script to reference non-existent fields or objects from the "fd_data" object. This commonly happens when a step number changes but the script isn't updated accordingly, leading to incorrect data retrieval or redundant operations.
This best practice serves to identify and flag references to non-existent fields or objects in "fd_data" to ensure the accuracy and integrity of the flow's logic. By catching these issues early, we can avoid inefficiencies, data corruption, and errors that would disrupt the flow’s execution. This safeguard prevents unnecessary troubleshooting and improves the maintainability of workflows by ensuring that scripts continue to point to valid, up-to-date data.
Enforcing this best practice encourages developers to regularly review and update scripts when making adjustments to flows. This leads to higher quality, more reliable automation and ensures smoother execution of business processes across the platform.
Helpful Information: https://docs.servicenow.com/bundle/washingtondc-build-workflows/page/administer/flow-designer/concept/inline-scripts.html#d106167e129