- 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-08-2022 07:00 AM
Is the Incident creation automated or being performed manually?
If automated, the Short Description will be known to be the same every time and could be fairly easily scripted to do what you are wanting. If it is manually entered, there is no guarantee of formatting or position in the field so trying to perform scripted functions will be much harder.
- 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-10-2022 08:17 PM
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2022 10:03 PM
What is the format of the Short Description ?