- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We are currently facing an issue where duplicate options are being displayed in a dropdown/select field, even though the values are being set through a combination of Script Include and Client Script from a specific table. The expectation is that once an option is selected or populated via script, it should not appear again as a duplicate in the list.
client script:
please help me
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
The main issue is here because of setting the displayValue instead of the record sys_id. Updated the while loop below, try this:
while (relGR.next()) {
var recordSysID = relGR.child.getValue('sys_id');
gs.info("Nikhitha" + displayValue + " " + recordSysID);
results.push(recordSysID);
}
After testing you can remove the comments and can directly push the value into results array.
Also, remember whenever you're inserting the values into list_collector via script you need to make sure to set bothe the value (sys_id) and display value of the record. Refer below screenshot:
Hope this resolves your issue
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
it returns only one value like this i want 2 if 2 values was there
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
so it's list collector with choices?
Script Include: check before adding if already present
var QuestDataDomainHelper = Class.create();
QuestDataDomainHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getChildCIsByDomains: function() {
var parentSysId = this.getParameter('sysparm_parentSysId');
var domainMap = {
va: QuestCMDBConstants.DATA_DOMAIN_LOCATION_OF_INDIVIDUALS,
ta: QuestCMDBConstants.DATA_DOMAIN_CATEGORIES_OF_DATA,
qa: QuestCMDBConstants.DATA_DOMAIN_DATA_STORAGE_LOCATION,
ka: QuestCMDBConstants.DATA_DOMAIN_INTERNAL_DATA_PROCESSING,
la: QuestCMDBConstants.DATA_DOMAIN_DATA_SHARING,
wa: QuestCMDBConstants.DATA_DOMAIN_DATA_ACCESS,
oa: QuestCMDBConstants.DATA_DOMAIN_TYPE_OF_DATA,
aa: QuestCMDBConstants.DATA_DOMAIN_QUEST_CORPORATE_DATA,
ba: QuestCMDBConstants.DATA_DOMAIN_AI_MACHINE_LEARNING,
ca: QuestCMDBConstants.DATA_DOMAIN_EXTERNAL_DATA,
da: QuestCMDBConstants.DATA_DOMAIN_TRANSFER_SHARE_ACCESS,
za: QuestCMDBConstants.DATA_DOMAIN_INDIVIDUALS,
};
var allResults = {};
for (var key in domainMap) {
var domainId = domainMap[key];
var results = [];
var relGR = new GlideRecord("cmdb_rel_ci");
relGR.addQuery("parent", parentSysId);
relGR.addEncodedQuery("child.ref_cmdb_ci_information_object.sn_apm_data_domain=" + domainId);
relGR.query();
var valuesSeen = {};
while (relGR.next()) {
var value = relGR.getValue('child');
var displayValue = relGR.child.getDisplayValue();
if (!valuesSeen[value]) { // Deduplication
results.push({
value: value,
label: displayValue
});
valuesSeen[value] = true;
}
}
allResults[key] = results;
}
return JSON.stringify(allResults);
},
type: 'QuestDataDomainHelper'
});
Client Script: No change
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader