- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 12:08 AM
I want to store a variable value in a new variable to use it in further workflow.Help me?
Solved! Go to Solution.
- 1,061 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 12:15 AM
Hi @brahmandlapally ,
you can use the workflow_scratchpad to pass data between workflows in ServiceNow. The scratchpad allows you to store temporary data that can be accessed by the same workflow or passed to another workflow when calling it.
Steps to Use workflow_scratchpad:
Set Data in the Scratchpad:
- In your first workflow, use a Set Value activity to assign data to the workflow_scratchpad. For example:javascript
- In your first workflow, use a Set Value activity to assign data to the workflow_scratchpad. For example:
workflow_scratchpad.variableName = "your_value";
Call Another Workflow:
- Use a Run Workflow activity to call the second workflow. In the configuration, you can pass the scratchpad variable as an input:
- Input the scratchpad variable where required.
- Use a Run Workflow activity to call the second workflow. In the configuration, you can pass the scratchpad variable as an input:
Access the Scratchpad in the Second Workflow:
- In the second workflow, you can access the passed value from the scratchpad:javascript
- In the second workflow, you can access the passed value from the scratchpad:
var receivedValue = workflow_scratchpad.variableName;
This method enables you to transfer data between workflows effectively.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.
Thank you!
Moin Kazi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 12:16 AM
To store a variable value in a new variable in ServiceNow for a workflow:
1. Add a Script Activity to the workflow.
var sourceValue = current.source_variable; // Get original
variablecurrent.new_variable_name = sourceValue; // Set new variable
2. Save and publish the workflow.
Now you can use new_variable_name in subsequent workflow activities.
Thanks, and Regards
Vishaal
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 12:26 AM
- Depending on how you are creating the workflow, you can use either a Scripted Workflow or a Flow Designer to store a variable value in a new variable in ServiceNow for use in a workflow.
It is possible to directly assign the value of one variable to another within a workflow script or business rule. An illustration of storing a variable value in a new variable is provided here:
var originalVariableValue = current.variables.your_variable_name;
var newVariable = originalVariableValue;
If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 12:15 AM
Hi @brahmandlapally ,
you can use the workflow_scratchpad to pass data between workflows in ServiceNow. The scratchpad allows you to store temporary data that can be accessed by the same workflow or passed to another workflow when calling it.
Steps to Use workflow_scratchpad:
Set Data in the Scratchpad:
- In your first workflow, use a Set Value activity to assign data to the workflow_scratchpad. For example:javascript
- In your first workflow, use a Set Value activity to assign data to the workflow_scratchpad. For example:
workflow_scratchpad.variableName = "your_value";
Call Another Workflow:
- Use a Run Workflow activity to call the second workflow. In the configuration, you can pass the scratchpad variable as an input:
- Input the scratchpad variable where required.
- Use a Run Workflow activity to call the second workflow. In the configuration, you can pass the scratchpad variable as an input:
Access the Scratchpad in the Second Workflow:
- In the second workflow, you can access the passed value from the scratchpad:javascript
- In the second workflow, you can access the passed value from the scratchpad:
var receivedValue = workflow_scratchpad.variableName;
This method enables you to transfer data between workflows effectively.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.
Thank you!
Moin Kazi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 12:16 AM
To store a variable value in a new variable in ServiceNow for a workflow:
1. Add a Script Activity to the workflow.
var sourceValue = current.source_variable; // Get original
variablecurrent.new_variable_name = sourceValue; // Set new variable
2. Save and publish the workflow.
Now you can use new_variable_name in subsequent workflow activities.
Thanks, and Regards
Vishaal
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 12:26 AM
- Depending on how you are creating the workflow, you can use either a Scripted Workflow or a Flow Designer to store a variable value in a new variable in ServiceNow for use in a workflow.
It is possible to directly assign the value of one variable to another within a workflow script or business rule. An illustration of storing a variable value in a new variable is provided here:
var originalVariableValue = current.variables.your_variable_name;
var newVariable = originalVariableValue;
If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.