How to pass a string input in a flow designer to a reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 08:38 AM
Hi Team,
I have a requirement where i have a subflow that will be used in a scripted restAPI. in the subflow we have defined a input "Assigned_to" as string. expectation is that if the user passes the assigned to value via API, it should updated the corresponding assigned to field in an incident. As assigned to in incident form is a reference field and the input is string, the value passed by API is not updating in the incident. how can i achieve this?
any help on this is greatly appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 08:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 08:31 AM
Yes @manjusha_
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 08:58 AM
Hi @Atheher Fathima ,
Hope you are doing great.
To achieve this, you can use a combination of Flow Designer and a Scripted REST API. Here are the steps you can follow:
-
Create a Flow in Flow Designer:
- Add an input variable named "Assigned_to" of type string.
- Add an action to retrieve the incident record based on your criteria.
-
Add a Scripted Action:
- After retrieving the incident, add a Scripted Action.
- Use JavaScript to convert the string input into a reference field value. You'll need to query the User table to get the sys_id of the user based on the provided string.
// Assuming 'assignedToString' is the string input from the API var userGR = new GlideRecord('sys_user'); userGR.addQuery('name', assignedToString); userGR.query(); if (userGR.next()) { var assignedToSysId = userGR.sys_id; current.incident_field = assignedToSysId; // Set the incident field to the sys_id }
-
Use a Flow Designer action to update the incident record. Set the "Assigned to" field to the sys_id obtained from the User table.
-
Expose the Flow via Scripted REST API:
- Create a Scripted REST API that triggers the Flow you've just created.
- Make sure to map the input from the API request to the "Assigned_to" variable in your Flow.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 08:28 AM
Hi Riya,
I did give it a try, i have a input variable defined as "Assigned To" . In Create incident i tried to add the scripted action,but getting an error that assigned to is not defined.
I tried using the script in step 3 Create incident record
Please advise