We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

I have to add conference tag in incident.

niveditakumari
Giga Sage

Hi, 

 

Whenever an incident is assigned from abc to xyz we would like to add "Conference Room Issue" tag to the incident along with the existing configuration in flow and we are having flow for that catalog item. 

niveditakumari_0-1770719785868.png

 

Can anyone please help me how to add conference tag in incident. 

 

Regards, 

Nivedita 

 

 

31 REPLIES 31

Hi @Ankur Bawiskar

 

(function executeRule(current, previous /*null when async*/) {

// Comma seperated list of Tags
var tagsArr = 'Conference Room Issue';

// Iterate thru the Array and create the Tags and Label Entries
tagsArr = tagsArr.split(',');

for(var i = 0; i < tagsArr.length; i++) {
var tagSysId = '';

var grTag = new GlideRecord('label');
grTag.addActiveQuery();
grTag.addQuery('name', tagsArr[i]);
grTag.addQuery('type', 'standard');
grTag.addQuery('viewable_by', '!=', 'me');
grTag._query();

if(grTag._next()) {
tagSysId = grTag.getUniqueValue();
} else {
grTag.initialize();
grTag.setValue('name', tagsArr[i]);
grTag.setValue('viewable_by', 'everyone');
grTag.insert();

tagSysId = grTag.getUniqueValue();
}

var grTagEntry = new GlideRecord('label_entry');
grTagEntry.initialize();
grTagEntry.setValue('label', grTag.getUniqueValue());
grTagEntry.setValue('table', current.getTableName());
grTagEntry.setValue('table_key', current.getUniqueValue());
grTagEntry.insert();
}

})(current, previous); 
 
Can you please confirm where to add table name and record sysId. 
 
Regards, 
Nivedita 
 
 

@niveditakumari 

run the code in scripts background

var tagsArr = 'Conference Room Issue';

// Iterate thru the Array and create the Tags and Label Entries
tagsArr = tagsArr.split(',');

for(var i = 0; i < tagsArr.length; i++) {
var tagSysId = '';

var grTag = new GlideRecord('label');
grTag.addActiveQuery();
grTag.addQuery('name', tagsArr[i]);
grTag.addQuery('type', 'standard');
grTag.addQuery('viewable_by', '!=', 'me');
grTag._query();

if(grTag._next()) {
tagSysId = grTag.getUniqueValue();
} else {
grTag.initialize();
grTag.setValue('name', tagsArr[i]);
grTag.setValue('viewable_by', 'everyone');
grTag.insert();

tagSysId = grTag.getUniqueValue();
}

var grTagEntry = new GlideRecord('label_entry');
grTagEntry.initialize();
grTagEntry.setValue('label', grTag.getUniqueValue());
grTagEntry.setValue('table', 'incident'); // here
grTagEntry.setValue('table_key', 'incidentSysId'); // here
grTagEntry.insert();
}

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar

 

I have run above code in background script and given incidentSysId it is not adding conference tag to that incident. 

 

niveditakumari_5-1770831779708.png

 

 

niveditakumari_4-1770831680695.png

 

I'm try both approach flow designer first and then business rule whichever will work I can show that. 

Can you please help me to correct that. 

 

Regards, 

Nivedita 

 

 

Hi, 

 

Can you please help me to correct business rule to add conference tag to that incident. 

var tagsArr = 'Conference Room Issue';

// Iterate thru the Array and create the Tags and Label Entries
tagsArr = tagsArr.split(',');

for(var i = 0; i < tagsArr.length; i++) {
var tagSysId = '';

var grTag = new GlideRecord('label');
grTag.addActiveQuery();
grTag.addQuery('name', tagsArr[i]);
grTag.addQuery('type', 'standard');
grTag.addQuery('viewable_by', '!=', 'me');
grTag._query();

if(grTag._next()) {
tagSysId = grTag.getUniqueValue();
} else {
grTag.initialize();
grTag.setValue('name', tagsArr[i]);
grTag.setValue('viewable_by', 'everyone');
grTag.insert();

tagSysId = grTag.getUniqueValue();
}

var grTagEntry = new GlideRecord('label_entry');
grTagEntry.initialize();
grTagEntry.setValue('label', grTag.getUniqueValue());
grTagEntry.setValue('table', 'incident'); // here
grTagEntry.setValue('table_key', 'incidentSysId'); // here
grTagEntry.insert();
}

 

Regards, 

Nivedita 

 

 

Hi @Ankur Bawiskar

 

Can you please confirm how to test in background script what changes I have to do in that. 

 

Regards, 

Nivedita