Inbound action to pull text from subject and enter into field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2019 03:41 AM
Hi All,
I have some inbound actions set up for till alerts that we receive. An example of the subject is 'POS:SELF-T1183-9999-843-HTTP Connector'
I need to extract the 'T1183' from the subject and enter it into the the Configuration Item field on the Incident table. The 'POS:SELF-' should always remain the same. The rest of the subject will change depending on the till and alert.
Can anyone help with the scripting please?
Kind regards,
Hinakshi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2019 06:30 AM
hey hi ,
Please use below code , i have tested this and works fine
var str="POS:SELF-T1183-9999-843-HTTP Connector";
var keyword="SELF-";
var len = keyword.length;
var key = str.indexOf(keyword);
if(key > 0 || key == 0){
var num = str.substring(key+len,key+len+5);
//below code is to query cmdb table and get the sys_id of the ci then update incident field
var ch=new GlideRecord('cmdb_ci');
ch.query('name',num);
ch.query();
while(ch.next())
{
gs.log('change sys id is:'+ch.sys_id);// this will give you sys_id of CI
current.setValue('cmdb_ci','ch.sys_id');
}
}
output SS:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2019 07:34 AM
I tried this, but it is not putting the T number (T1183) into the config item (cmdb_ci) field.