- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2023 11:29 PM - edited 12-26-2023 11:30 PM
Hi Experts,
I have a requirement to copy date and time provided in email body and update a hardware asset table depretiation start date field.
I have created a inbound email action to parse email body but struck at trimming date and time from recieved email body.
Can you please help me with the coding pls.
Sent mail will be like below.
from above mail i need to copy date and time and update a date time type field.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 01:15 AM
Thank you...
Fixed it using below code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 01:03 AM
It because the str (gr.body) doesn't contain a datetime string .
Should put some null check logic before using the match result.
str2 = str.match(/[0-9][0-9][0-9][0-9]\-[0-1][0-9]\-[0-3][0-9]\s[0-2][0-9]\:[0-6][0-9]\:[0-6][0-9]/);
if(str2){
gs.info(str2[0])
}else{
gs.info("can't match !")
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 01:54 AM
can you help me with running below code for all hardware assets with recieved mail in servicenow inbox.
Because cant find a unique value in alm_hardware table and sys_email table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 02:07 AM
@ROS4349
I cant understand your problem clearly..
Do you mean the email is binding to some hardware,but there isn't enought information to find the hardware from the email ?
And what you are trying to do is to update the hardware's depreciation_date from the email body?
I'm sorry , it's 18:00 here , and i will come back after 16 hours...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 02:44 AM
Sure Thank you... I will be waiting for your response.
Requirement is :
Configured a email to ask accept the depritiation date or propose a new date instead of. So below is the email notification i got in my inbox
Here user can click on defer button to compose a mail with new date and time as below
once servicenow got this email inbound email action should read the email body and update given date and time in depreciation date field.
So below background script need to write in inbound action script
=====================================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 07:12 PM
@ROS4349
I got it.
1.when using inbound email action ,check if the 【When to run】 tab is defined correctly。
2. You don't need to query the email table to get the email body .
Use email obecjt to get the information (exp: var bodyText = email.body_text;)
3. I found that asset tag (p1000092) is included in the eamil title.
use asset tag to query the alm_hardware table maybe the correct way.(you can use match function to extract the asset tag from the email title)