Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2021 02:33 AM
Hello!
I have a text field which the requester populates with a new hardware name.
Is there a way to check if this value exists against the Hardware table and show a message that the hardware name exists?
Thank you.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2021 02:43 AM
Sample script
Script Include:
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
var name = this.getParameter('sysparm_hardwareName');
var gr = new GlideRecord('alm_hardware');
gr.addQuery('display_name', name);
gr.query();
if(gr.next()){
return 'found';
}
return 'not found';
},
type: 'checkRecords'
});
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.hideFieldMsg('fieldName'); // give here field/variable name
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.addParam('sysparm_hardwareName', g_form.getValue('fieldName')); // give here field/variable name
ga.getXMLAnswer(function(answer){
if(answer == 'not found'){
var message = 'This hardware is not present';
g_form.clearValue('fieldName'); // give here field/variable name
g_form.showFieldMsg('fieldName',message,'error', true);
}
});
//Type appropriate comment here, and begin script below
}
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2021 04:39 AM
Request you to visit your older question and close by marking appropriate response correct and helpful.
Attaching a csv file to notification
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader