- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2022 06:01 AM
If the short description filed contains the name of CI, the business rule will automatically enter that CI into the incidents form, can you guide me script on this we have total 472 incidents CI exist.
while creating incident we will enter CI name in short description based on this information CI should pop on Configuration Item filed on incident form could you please guide me what script should i used in business rule
It could be great if some one help on this
Regards,
Janardhana
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2022 10:57 AM
Hi Janardhan,
You can try below script in before insert business rule on incident table.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gr = new GlideRecord('cmdb_ci');
gr.query();
cmdb_array = [];
while(gr.next())
{
var temp= gr.getDisplayValue('name');
if(gr.getDisplayValue('name') != 'Unknown')
{
cmdb_array.push(temp);
}
}
var cmdb;
var temp2;
var desc = current.short_description;
for(i=0;i<cmdb_array.length;i++)
{
temp2 = desc.includes(cmdb_array[i]);
if(temp2 == true)
{
cmdb = cmdb_array[i];
break;
}
}
gs.log(cmdb);
var grCmdb = new GlideRecord('cmdb_ci');
grCmdb.addQuery('name',cmdb);
grCmdb.query();
var sysId;
if(grCmdb.next())
{
sysId = grCmdb.getValue('sys_id');
}
current.cmdb_ci.setValue(sysId);
})(current, previous);
Please feel free to mark my response correct if it answered your query!
Thanks and Regards,
Rahul
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2022 03:13 AM
some one posted and removed this one ..its working fine for me thanks for the great help who posted this script
gr = new GlideRecord('cmdb_ci');
gr.query();
cmdb_array = [];
while(gr.next())
{
var temp= gr.getDisplayValue('name');
if(gr.getDisplayValue('name') != 'Unknown')
{
cmdb_array.push(temp);
}
}
var cmdb;
var temp2;
var desc = current.short_description;
for(i=0;i<cmdb_array.length;i++)
{
temp2 = desc.includes(cmdb_array[i]);
if(temp2 == true)
{
cmdb = cmdb_array[i];
break;
}
}
gs.log(cmdb);
var grCmdb = new GlideRecord('cmdb_ci');
grCmdb.addQuery('name',cmdb);
grCmdb.query();
var sysId;
if(grCmdb.next())
{
sysId = grCmdb.getValue('sys_id');
}
current.cmdb_ci.setValue(sysId);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2022 03:16 AM
gr = new GlideRecord('cmdb_ci');
gr.query();
cmdb_array = [];
while(gr.next())
{
var temp= gr.getDisplayValue('name');
if(gr.getDisplayValue('name') != 'Unknown')
{
cmdb_array.push(temp);
}
}
var cmdb;
var temp2;
var desc = current.short_description;
for(i=0;i<cmdb_array.length;i++)
{
temp2 = desc.includes(cmdb_array[i]);
if(temp2 == true)
{
cmdb = cmdb_array[i];
break;
}
}
gs.log(cmdb);
var grCmdb = new GlideRecord('cmdb_ci');
grCmdb.addQuery('name',cmdb);
grCmdb.query();
var sysId;
if(grCmdb.next())
{
sysId = grCmdb.getValue('sys_id');
}
current.cmdb_ci.setValue(sysId);
})(current, previous);
Welcome Janardhan!
Good to know it helped you!
Happy to help:)
Can you please mark my answer correct so this thread can be closed, which will help future visitors!!
Thanks in Advance
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2022 06:41 PM
can you please tell me where to enter this scrip ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 01:38 AM
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 11:30 PM
Hi Janardhan,
Seems like you marked my answer correct and unmarked it,
Are you looking for something more!
Please let me know
Thanks and Regards
Rahul
Thanks and Regards,
Rahul