- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 12:59 PM
Hello,
I'm having trouble handling a list-type input in the Decision table.
In the decision table, the "type" column receives a sys_id. This sys_id must be checked in the "check rules" of the flow design. Here is the script for this verification:
try{
var group = fd_data.trigger.current.assignment_group.getRefRecord();
return String(group.getValue("type"));
}
catch(error){
return "";
}
However, the value is not being found in the list, and the flow is not following the correct path. Can anyone help?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 01:28 PM
Hi @Paulo Machado,
I am not sure whether I understood the requirement but can you try the following script instead:
try{
return fd_data.trigger.current.assignment_group.type.toString();
}
catch(error){
return "";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 01:10 PM
Hi @Paulo Machado
It seems like you're encountering an issue with retrieving the value of the "type" field from the list in ServiceNow. Here are a few steps you can take to troubleshoot and potentially resolve the issue:
1. Verify Field Existence**: Double-check that the "type" field exists on the Assignment Group table and is populated with the correct sys_ids.
2. Check Field Permissions**: Ensure that the user executing the flow has the necessary permissions to access the "type" field on the Assignment Group table.
3. Debugging Script**: To debug the script, you can add some logging statements to see what values are being retrieved and processed. For example:
try {
var group = fd_data.trigger.current.assignment_group.getRefRecord();
var typeValue = String(group.getValue("type"));
gs.info("Type value: " + typeValue);
return typeValue;
} catch (error) {
gs.error("Error occurred: " + error.message);
return "";
}
```
By checking the logs, you can see if the "type" value is being retrieved correctly or if there's an error occurring.
4. Check List Field Configuration**: Ensure that the "type" field on the Assignment Group table is configured correctly as a reference field to the appropriate table and has appropriate reference qualifier if needed.
5. Verify Data Consistency**: Check if the "type" field on the Assignment Group table is populated consistently and accurately. There might be instances where the field is empty or contains incorrect values.
Please hit helpful and accept this as a solution if solves your queries.
Regards: Raja Aqib
6. Test Manually**: Test the script manually by executing it in the background script or script editor and passing sample data to see if it retrieves the expected values.
7. Review Flow Design**: Double-check the flow design to ensure that the conditions and paths are configured correctly based on the "type" field value returned by the script.
By following these steps and debugging the script, you should be able to identify the cause of the issue and resolve it accordingly. If the problem persists, you may need to involve your ServiceNow administrator or consult the ServiceNow documentation for further assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 01:28 PM
Hi @Paulo Machado,
I am not sure whether I understood the requirement but can you try the following script instead:
try{
return fd_data.trigger.current.assignment_group.type.toString();
}
catch(error){
return "";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 04:19 AM
Hi, @James Chun !
I tried this way for the first time and didn't work. I tried again and worked.
Well, I think the problem was my instance cache.
Thanks 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2024 01:30 PM
Hi @Paulo Machado ,
To handle a list-type input in the Decision table in ServiceNow, particularly when the "type" column receives a sys_id and needs to be checked in the "check rules" of the flow design, you can use a server-side script action. Here's how you can accomplish this:
(function executeRule(current, previous /*null when async*/) {
try {
var typeSysId = current.type; // Assuming "type" is a reference field storing the sys_id
var typeRecord = new GlideRecord('type_table'); // Replace 'type_table' with the actual table name
if (typeRecord.get(typeSysId)) {
// Check conditions based on the type record retrieved
if (typeRecord.getValue('some_field') == 'some_value') {
// Perform actions based on the condition
gs.info('Type record matches criteria');
} else {
gs.info('Type record does not match criteria');
}
} else {
gs.info('Type record not found');
}
} catch (ex) {
gs.error('An error occurred while checking type: ' + ex);
}
})(current, previous);
```
Replace type_table with the actual table name where the "type" sys_id is stored. Also, adjust some_field and some_value to the specific field and value you want to check against in the type record.
Ensure that the script action is correctly configured within the Flow Designer's decision table, and it's set to run in the "check rules" phase.
This script retrieves the record from the specified table using the sys_id provided in the "type" column. It then checks conditions based on the retrieved record's field values and performs actions accordingly.
Make sure to handle errors appropriately within the try-catch block to provide better error handling and logging in case of any issues during execution.
Please hit helpful and accept this as a solution if solves your queries.
Regards: Raja Aqib