- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 12:54 AM
Hi All,
We have a requirement. If a user selects an Application from 'app_service' then tags related to that application will populate in a different field. So, if an application has 3 tags, how to populate those 3 tags? If an application has 1 tag, it is populating fine but problem is with more than 1 tag.
Catalog Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var a = g_form.getValue('app_service');
alert(a);
var ga = new GlideAjax("TagPop");
ga.addParam("sysparm_name", "getTagName");
ga.addParam("sysparm_groupid", a);
ga.getXML(setTagName);
function setTagName(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.clearValue('subscription_name');
g_form.clearOptions('subscription_name');
alert(answer);
g_form.setValue('subscription_name', answer);
}
}
Script Include:
var TagPop = Class.create();
TagPop.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getTagName: function() {
var efg = '';
var nam = this.getParameter('sysparm_groupid');
//gs.log('h1' + nam);
//var t = nam.getDisplayValue();
//gs.log('h2' + t);
var abc = new GlideRecord('label_entry');
abc.addQuery('title', 'CONTAINS', nam);
//var vendors = [];
abc.query();
if (abc.next()) {
efg = abc.label.getDisplayValue();
//vendors.push(efg.getUniqueValue());
}
return efg;
//return 'sys_idIN'+vendors.toString();
},
type: 'TagPop'
});
Please help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 02:28 AM
Updated CLient Script code to be used here as below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue) {
var ga = new GlideAjax('getTags');
ga.addParam('sysparm_name', 'getTagsValue');
ga.addParam('sysparm_val', newValue);
ga.getXML(getTags);
}
function getTags(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
var splitAnswer = answer.split(',');
for(var i=0;i<splitAnswer.length;i++){
g_form.setValue('description',g_form.getValue('description') + '\n' + splitAnswer[i]);
}
}
//Type appropriate comment here, and begin script below
}
This will ensure that tags appear in different lines as you said, did not read it initially but have modified it. Let me know for an issue here.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 01:00 AM
Hi,
if subscription_name is reference type then it will hold only 1 value
what is the variable type for subscription_name?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 01:02 AM
Hi Ankur,
Type is Select Box.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 01:26 AM
Hi,
then it will be only 1 value.
select box will only show 1 value at a time.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 01:31 AM
Hi Ankur,
Got It. Then how to show multiple values?
Thanks!