- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:07 PM - edited 08-18-2023 04:39 AM
Hi,
I have a requirement, In user form there is related list called flashes and it contains records in it. (only few users has flash records/message)
In call table, in the onbehalf field when the user is selected, who has flashes then the highlighted message should display as pop up or annotation kind of.
Example OLA SNOW has flash in his profile so on selecting this user profile, then the flash details need to display as pop up or annotation.
Please help me how we can achieve this....Provide the script as well.
Thanks in Advance.
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 01:40 AM
update as this
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
var id = this.getParameter('sysparm_userID');
var gr = new GlideRecord('flashes table'); // use valid table name here
gr.addQuery('user', id); // use valid field name here
gr.query();
if(gr.next()){
return gr.flashesField.getDisplayValue(); // use valid field name here
}
return '';
},
type: 'checkRecords'
});
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearMessages();
if(oldValue != newValue){
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.addParam('sysparm_userID', newValue);
ga.getXMLAnswer(function(answer){
if(answer != ''){
g_form.addInfoMessage(answer);
}
});
//Type appropriate comment here, and begin script below
}
}
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:42 PM
you can use onChange client script + GlideAjax and get the message from that table
then use g_form.addInfoMessage() to show that
what did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:52 PM
Hi @Ankur Bawiskar ,
Thanks for the response....Im new to script so i have not started yet.
It could be helpful if you provide the entire script.
Note: each users have different flash messages in their profile
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 12:09 AM
Below is the sample. I hope you will be able to enhance it further
create client callable script include
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
var id = this.getParameter('sysparm_userID');
var gr = new GlideRecord('flashes table'); // use valid table name here
gr.addQuery('user', id); // use valid field name here
gr.query();
if(gr.next()){
return gr.flashesField; // use valid field name here
}
return '';
},
type: 'checkRecords'
});
onChange client script on User field on Call table
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(oldValue != newValue){
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.addParam('sysparm_userID', newValue);
ga.getXMLAnswer(function(answer){
if(answer != ''){
g_form.addInfoMessage(answer);
}
});
//Type appropriate comment here, and begin script below
}
}
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 01:32 AM
HI @Ankur Bawiskar ,
I used the above script it worked but it is displaying the sysid in annotation.... need the message value to be displayed.....can you let me know what change is needed here.
And one thing i noticed if i select user with flash message the annotation displays if i change the user with no flashes still old annotation is showing in form is there any way we can work on this
Thanks