- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2024 11:48 PM
Hi
I have created a flow (with subflow) that creates a request item (sc_req_item) for ordering IT Equipment for new hires (triggered from the HR Profiles table).
Flow loops through all new hires, finds out if a request for hardware has already been made and if not, create the request. All of this works perfectly.
What I would like at the end is to send an email where the body has some information about the requests that has been created, eg
RITM00123456 - <<user name1>> - <<hire date1>> - <<manager name1>>
RITM00123457 - <<user name2>> - <<hire date2>> - <<manager name2>>
RITM00123458 - <<user name3>> - <<hire date3>> - <<manager name3>>
You get the picture 🙂
What I would like to capture is above information for each request created somehow and use that in the email body.
I have searched and searched but have not been able to find something useful
Kind Regards
Søren
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 01:20 AM
Here are the steps you can follow to achieve this:
1. Create a variable to store the information for each request. This could be a string variable that you append to for each new hire processed. For example, you could name this variable emailBody.
2. In your flow, after creating the request item (sc_req_item), append the necessary information to the emailBody variable. You can use the + operator to append strings in ServiceNow. For example:
emailBody = emailBody + 'RITM' + ritmNumber + ' - ' + userName + ' - ' + hireDate + ' - ' + managerName + '\n';
Replace ritmNumber, userName, hireDate, and managerName with the appropriate variables or field values from your flow.
3. After your loop finishes processing all new hires, you can use the emailBody variable in your email notification. In the email notification record, you can insert the variable into the message body using the ${emailBody} syntax.
4. To ensure that the email is sent only once after all the requests have been created, place the email notification action outside the loop, after all the processing is done.
5. Test your flow to ensure that the email is sent correctly and contains the expected information for each request.
Remember to reset the emailBody variable to an empty string at the start of your flow to ensure that it doesn't contain information from previous runs.
nowKB.com
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/
For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 01:23 AM
@s_renjarnbo Following are the supported flow variable types.
Since JSON is also supported, you can add a key value pair in your flow variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 01:20 AM
Here are the steps you can follow to achieve this:
1. Create a variable to store the information for each request. This could be a string variable that you append to for each new hire processed. For example, you could name this variable emailBody.
2. In your flow, after creating the request item (sc_req_item), append the necessary information to the emailBody variable. You can use the + operator to append strings in ServiceNow. For example:
emailBody = emailBody + 'RITM' + ritmNumber + ' - ' + userName + ' - ' + hireDate + ' - ' + managerName + '\n';
Replace ritmNumber, userName, hireDate, and managerName with the appropriate variables or field values from your flow.
3. After your loop finishes processing all new hires, you can use the emailBody variable in your email notification. In the email notification record, you can insert the variable into the message body using the ${emailBody} syntax.
4. To ensure that the email is sent only once after all the requests have been created, place the email notification action outside the loop, after all the processing is done.
5. Test your flow to ensure that the email is sent correctly and contains the expected information for each request.
Remember to reset the emailBody variable to an empty string at the start of your flow to ensure that it doesn't contain information from previous runs.
nowKB.com
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/
For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 01:33 AM - edited ‎01-19-2024 02:00 AM
Thanks @Rajdeep Ganguly
Very helpful 🙂
Just a few more questions:
Where should I put the "emailBody = emailBody + 'RITM' + ritmNumber + ' - ' + userName + ' - ' + hireDate + ' - ' + managerName + '\n';" ???
In the scripted data:
or directly in the "text" line:
Kind Regards
Søren
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2024 02:28 AM
The line of code you provided is used to concatenate or add together strings and variables to form a larger string, which in this case, is used to form the body of an email. This line of code should be placed in a script where you are creating or modifying an email notification in ServiceNow. Here's a general example:
1. Navigate to the Email Notifications module in ServiceNow.
2. Open the email notification you want to modify or click New to create a new one.
3. In the Message HTML field or the Message field, you can use this line of code to form the body of the email.
4. However, you need to ensure that the variables ritmNumber, userName, hireDate, and managerName are defined and have values before this line of code.
5. If these variables are not defined, you can use GlideRecord queries to get the necessary data from the relevant tables in ServiceNow.
6. After defining the variables and forming the email body, you can use the emailBody variable in the body of the email notification.
Please note that this is a general example and the exact steps may vary depending on your specific requirements and the version of ServiceNow you are using.
nowKB.com
For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - https://nowgpt.ai/
For the ServiceNow Certified System Administrator exams try this :
https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2024 07:02 AM
I managed to find a solution based on all the replies in the thread, hence sharing for helping out others if need be.
So I have created a flow variable of type string.
In my workflow - after creating the request - I am setting flow variable "emailBody" as below:
Here is the excact code:
Here is the result:
Hope it help others
Regards
Søren