how to Map the choice variable dynamically in flow designer

klavan32
Tera Contributor

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:

 

/*
**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;
var fte = 'full_time_employee';
var con = 'contractor';
var ctg = 'contingent';
if (get(empType)){
if(empType == "Employee"){
    return fte;
}else if(empType == "Contractor"){
    return con;
}else if(empType == "Contingent"){
    return ctg;
}
}
 
If i am trying to map directly as one of the choice value then its mapping but through script its not working
 
Can someone please help and suggest on the same.
12 REPLIES 12

@klavan32 

seems you have not configured the output variable correctly

the script step should also have an output variable and that needs to be mapped to the Outputs variable section

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

klavan32
Tera Contributor

Hi @Ankur Bawiskar in script step also, we have declared the variable and mapped the input but somehow the variable names are not matching with the one in script step and the one we created in outputs section, If i am trying to create new variable in script section, its not showing up in data pill ,even though i save and publish multiple times, so i am unable to map new one  to output variable

 

I have tried to map the input to already existing script variables just for testing, its working fine and returning the value in log 

@klavan32 

ensure variable name is consistent. I have seen sometimes issue when we capitalize the variable

give something like this employeetype

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader