populate message if selected user is "inactive" from list field on the form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2024 11:59 PM
Hello,
i have a requirement , if the selected user is "Inactive" from list datatype field then message should be displayed saying "selected user is inactive (along with name of the selected user)". using script include and client script
the "Member list" Refers to "sys_user" table.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2024 12:53 AM
Hi @lakshmi_laksh ,
I tried your problem in my PDI and it works for me please refer below code
Create OnSubmit Client script and add below code
function onSubmit() {
//Type appropriate comment here, and begin script below
alert("watch List = " + g_form.getValue("watch_list"));
var ga = new GlideAjax('getUserWatchList');
ga.addParam('sysparm_name', 'userHandler');
ga.addParam('sysparm_watchList', g_form.getValue("watch_list"));
ga.getXML(updateCampus);
function updateCampus(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert('answer = ' + answer);
if(answer == false || answer == 'false'){
alert('User selected is inactive ');
}
}
}
Create Script include which is client callable and add below code
var getUserWatchList = Class.create();
getUserWatchList.prototype = Object.extendsObject(AbstractAjaxProcessor, {
userHandler: function(){
gs.log('here');
var watchList = this.getParameter('sysparm_watchList');
gs.log('watchList = ' + watchList);
var userGr = new GlideRecord('sys_user');
userGr.addQuery('sys_idIN'+ watchList);
userGr.query();
while(userGr.next()){
gs.log("Inside while ");
if(userGr.active == false){
return false;
}
}
},
type: 'getUserWatchList'
});
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2024 11:47 PM
Hi @lakshmi_laksh ,
Is my answer helps you?
If this helps if mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2024 01:09 AM
For this query, I created one field(List) on Incident table and applied onChange client script which is given below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-06-2024 11:53 PM
Hi @lakshmi_laksh,
If this helps please mark my answer correct and helpful if this works for you.
Thanks
Jitendra