- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 03:53 AM
I have created a catalog item for new hire on ESC portal and have configured an inbound action to create request using the email. I want to map the fields/values in the email body with various fields(variables) on the catalog item. How can I Map the fields in the email body to the variables on the RITM?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 05:21 AM - edited ‎12-20-2023 05:23 AM
For extracting the values , you can use the indexOf function to make sure the values for each statement exists in the email body text:
Ex:
var text = "Hello world, welcome to the universe.";
var result = text.indexOf("Welcome");
After using indexof you can use substring function to extract the values. OR if the email content is always going to be same you can directly use substring function, but this would not be a very sustainable solution in case if the content of email changes in future you need to re-write the substring function.
In your case you can extract values in separate variables and use the code shared below to create the request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 03:59 AM - edited ‎12-20-2023 04:03 AM
HI @Maulik_Akut ,
Assuming you are creating the request inside your inbound action , you can try to use the Cart API to place the order for the request. In this API you have set function to set up the variable values on the catalog item. Also you start with specifying the sys_id of the catalog item using addItem function.
Sample Code :
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//below is sys id of your catalog item
var catItem = cart.addItem('1e6079721b18b4502083c1f61a4bcb51', 1);
cart.setVariable(catItem, 'u_requested_for', item.u_requested_for);
cart.setVariable(catItem, 'u_location', item.u_location);
cart.setVariable(catItem, 'u_bus_desc', item.u_bus_desc);
var rc = cart.placeOrder();
Please mark correct/helpful if my response helped you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 04:43 AM
The values in the above example email need to be mapped to the RITM variables. So once the User sends an email with this details the request is supposed to be created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 05:21 AM - edited ‎12-20-2023 05:23 AM
For extracting the values , you can use the indexOf function to make sure the values for each statement exists in the email body text:
Ex:
var text = "Hello world, welcome to the universe.";
var result = text.indexOf("Welcome");
After using indexof you can use substring function to extract the values. OR if the email content is always going to be same you can directly use substring function, but this would not be a very sustainable solution in case if the content of email changes in future you need to re-write the substring function.
In your case you can extract values in separate variables and use the code shared below to create the request