how to Map the choice variable dynamically in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 08:33 PM
Hi All,
I am trying to map the choice field of a snow user profile through flow designer. we get user data through an integration and value should be mapped to field in snow user profile dynamically based on the input we receive as we have different choice values in snow end. trying with below script but it is returning empty value:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 08:38 PM
I believe you are writing that in the inline script section of that field
try this
/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**Order number is offset by +1 in Error Handling Section.
**Available options display upon pressing "." after fd_data
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/
var empType = fd_data._1__get_employee_data__snaplogic.employee_type.toString();
var fte = 'full_time_employee';
var con = 'contractor';
var ctg = 'contingent';
if(empType == "Employee"){
return fte;
}else if(empType == "Contractor"){
return con;
}else if(empType == "Contingent"){
return ctg;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-23-2025 08:44 PM
Hi @Ankur Bawiskar Thank for the reply.
Tried that way as well, but still its returning empty value in logs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 08:47 PM
please share the logs and screenshot of the field script
the field where you are writing is choice with these values
full_time_employee,contractor and contingent
what came here?
var empType = fd_data._1__get_employee_data__snaplogic.employee_type.toString();
var fte = 'full_time_employee';
var con = 'contractor';
var ctg = 'contingent';
gs.info('employee type' + empType); //what came here in log
if(empType == "Employee"){
return fte;
}else if(empType == "Contractor"){
return con;
}else if(empType == "Contingent"){
return ctg;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-23-2025 08:50 PM
Hi @klavan32
Please check the following points:
1. Remove if (get(empType)) from your script.
2. What is the value being returned by employee_type variable. For that, please check the flow execution context and see the value. Compare the value being returned with your if-else logic.
3. If the empType variable is being set properly, check for the choice field values. As per your script, your choice field has values like full_time_employee etc. Please cross-verify the same.
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.