Get Catalog Variable action not working for Variable set Choice Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 12:51 AM
Hello Community,
I am using get Catalog Variable out of the box action of flow designer. I am giving the Variable set name in this action.
I am facing issue with choice variable of the Variable set.
When I am selecting that variable choice is coming as none.
Can anyone please help me in this? if we need to create the custom action, can anyone please guide me on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 12:54 AM
Hi @Community Alums
Please share some screenshot.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 01:20 AM
Sure, I can guide you on how to create a custom action in ServiceNow Flow Designer. Here are the steps:
1. Navigate to Flow Designer in ServiceNow.
2. Click on "New" and select "Action".
3. Provide a name for the action and select the application scope.
4. In the "Inputs" section, define the inputs required for your action. In your case, it would be the sys_id of the catalog item and the variable set name.
5. In the "Steps" section, you can add the logic for your action. You can use the scripting APIs provided by ServiceNow to fetch the catalog variable. Here is a sample code snippet:
javascript
(function execute(inputs, outputs) {
var gr = new GlideRecord('item_option_new');
gr.addQuery('cat_item', inputs.sys_id);
gr.addQuery('variable_set', inputs.variable_set_name);
gr.query();
if (gr.next()) {
outputs.choice = gr.choice;
} else {
outputs.choice = 'None';
}
})(inputs, outputs);
6. Once you have added the logic, you can save the action.
7. Now, you can use this custom action in your flow. When you add an action in your flow, you can select this custom action from the list.
Please note that the above code is a sample and might need to be adjusted based on your exact requirements. Also, make sure to test the custom action thoroughly before using it in production.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 01:29 AM
@Community Alums
no custom action required.
Please share the RITM submitted screenshot. Did you verify if that variable has value in it?
Please share screenshot of the flow step
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 01:36 AM
Sure, I can guide you on how to create a custom action in ServiceNow Flow Designer. Here are the steps: 1. Navigate to Flow Designer in ServiceNow. 2. Click on "New Action" on the top right corner. 3. Provide a name and description for the action. 4. In the "Inputs" section, define the inputs required for the action. In your case, it would be the variable set name. 5. In the "Steps" section, click on "Add Step" and select the appropriate action. You can use the "Script" action to write custom scripts. 6. In the script, you can use the GlideRecord API to query the variable set and get the choice variable. Here is a sample code: javascript var gr = new GlideRecord('item_option_new'); gr.addQuery('variable_set', inputs.variable_set); gr.query(); while(gr.next()) { if(gr.type == 'choice') { // your logic here } } 7. After writing the script, define the outputs of the action in the "Outputs" section. 8. Click on "Save" to save the action. Please note that the above script is a sample script and you might need to modify it according to your requirements. Also, the 'item_option_new' table is used to store catalog item variables and 'variable_set' is the field that stores the variable set of the variable. The 'type' field stores the type of the variable. Regarding the issue with the choice variable coming as none, it might be because the choice variable is not properly defined in the variable set or there are no choices defined for the variable. You can check this in the variable set record.