How to get the value from the field and store in the variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2023 03:51 AM
Hi Community,
Im trying to get the value from the field and store it in the variable and reuse that variable in the script.
Basically, In sys_email table there is field called body text i want that value to be use in the description of the incident which is creating by this BR (written on sys_email table)....i tried something like email.body_text but didnt worked...so taught of gliding sys_email table and using encodedquery.
Idea of this BR is based on specific conditions incident record need to be created...which is working fine i did that but im struck with the description part.
Please provide any insights on this...how we can get the value of body text from the recieved-ignored email and use it in the description field of the incident.
Note : This needs to be achieved by Br or something but not with inbound email actions because incident needs to be created when emails are received-ignored type.
Thanks in advance
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2023 04:07 AM
Hello @suuriya,
The server name is present in the email body? Then you need to change your code.
Can you share your email body format? so I can help you in code.
Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Vaishnavi Shinde
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2023 04:16 AM
Hi @VaishnaviShinde ,
Yes server name is present in email body and in an incident configuration item (reference) in that table also the server name mentioned in email body is present in it.
I cant share the email body but it will look something like this
email body
59*****4**5
**-np-**
---------------------------------------------
i-05**********f
Name:servername
Apmid:*****
---------------------------------------------
Name:servername this is were the actual server name will be mentioned
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2023 06:04 AM - edited 12-22-2023 07:06 AM
If you don't know how to use INBOUND EMAIL ACTION properly & still want to use this BR only to create INC, you will have to share the BODY what you see in the sys_email table for this particular email.
My actual Email Body is something as follows -
However I need body which looks something as follows from the sys_email table record -
You can hide any sensitive data from that email & just share the format of it but don't remove any HTML tags. That body is required because when you do 'current.body', you are accessing the whole email-body including the HTML Tags as well.
Now if you notice, I have added 'Name:ServerName' based on your earlier format in my email and the ServerName is between 'Name:' & '</div>' strings
Based on this assumption I was able to fetch the ServerName using following script -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2023 07:07 AM - edited 12-22-2023 07:10 AM
Hello @suuriya
Try this code:
var string = "Name:*ANNIE-IBM\nApmid:" // Add your email body_text
var text1= string.replace(/\n/g, " ");
var serverName = string.split('Apmid:');
var servers = serverName[0];
var server = servers.toString();
var serv= server.split(':')
var serversName = serv[1].toString()
var result = serversName.trim();
var cmdbCi = new GlideRecord('cmdb_ci');
cmdbCi.addEncodedQuery('name='+result);
cmdbCi.query();
if(cmdbCi.next()){
sysId= cmdbCi.getUniqueValue();
}
replace inc.cmdb_ci = name with inc.cmdb_ci = sys_id
Please Mark my Solution as Accept✅ and Give me a thumbs up👍, if you find it Helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 09:42 PM
Hello @suuriya ,
If my answer solve your issue.
Please Mark my Solution as Accept✅ and Give me a thumbs up👍, if you find it Helpful.
Regards,
Vaishnavi Shinde