- 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-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-30-2023 09:21 AM
Hi @Ankur Bawiskar,
In this case some user has more than 1 flash message in them but only the first message is getting displayed in case if they have 3 message all 3 needs to be displayed as annotations.
Can please help me for this modifications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 09:26 AM
update as this
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
var arr = [];
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();
while(gr.next()){
arr.push(gr.flashesField.getDisplayValue()); // use valid field name here
}
return arr.toString();
},
type: 'checkRecords'
});
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-30-2023 09:52 AM
Hi @Ankur Bawiskar ,
Thanks for the quick response...Is there a way to get the annotation separate. Now I can see all annotation, but it is coming in single like annotation1,annotation2
Is there way to get Annotation 1 in one blue box and annotation 2 in another.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 08:16 PM
I didn't get
are you saying you want color for those messages in infoMessage?
if yes then it's possible. you can use html tags in it
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader