- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 08:24 AM
Hi Team,
I need all the incident number which are assigned to logged in user, and all the incident's it should be populated in of the custom field.
Please help me with solution. Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 08:43 AM
Hi @Feroz1 ,
var comm =[];
var perInc = new GlideRecord('incident');
perInc.addQuery('opened_bt,gs.getUserID());
perInc.query();
while(perInc.next()){
comm.push(perInc.number.toString());
}
perc.u_personal_comments = comm.toString();//change the field name
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 09:07 AM
Hi @Feroz1 ,
You can create BR (can be at When: Display), with the script below:
(function executeRule(current, previous /*null when async*/ ) {
var arr = [];
var inc = new GlideRecord('incident');
inc.addQuery('assigned_to', gs.getUserID());
inc.query();
while (inc.next()) {
arr.push(inc.sys_id.toString());
}
if (arr.length) {
current.u_count = arr.toString(); // replace u_count with your custom field's name
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 10:31 AM
HI @Feroz1 ,
I trust you are doing great.
Please find below code for the same:
var GetUserIncidents = Class.create();
GetUserIncidents.prototype = {
initialize: function() {
},
getIncidentsForCurrentUser: function() {
var currentUser = gs.getUserID(); // Get the sys_id of the current user
var incidentList = []; // Initialize an array to hold the incident numbers
var gr = new GlideRecord('incident'); // Query the incident table
gr.addQuery('assigned_to', currentUser); // Filter incidents assigned to the current user
gr.query();
while (gr.next()) {
incidentList.push(gr.getValue('number')); // Add the incident number to the array
}
return incidentList; // Return the array of incident numbers
},
type: 'GetUserIncidents'
};
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 08:43 AM
Hi @Feroz1 ,
var comm =[];
var perInc = new GlideRecord('incident');
perInc.addQuery('opened_bt,gs.getUserID());
perInc.query();
while(perInc.next()){
comm.push(perInc.number.toString());
}
perc.u_personal_comments = comm.toString();//change the field name
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 09:07 AM
Hi @Feroz1 ,
You can create BR (can be at When: Display), with the script below:
(function executeRule(current, previous /*null when async*/ ) {
var arr = [];
var inc = new GlideRecord('incident');
inc.addQuery('assigned_to', gs.getUserID());
inc.query();
while (inc.next()) {
arr.push(inc.sys_id.toString());
}
if (arr.length) {
current.u_count = arr.toString(); // replace u_count with your custom field's name
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 10:31 AM
HI @Feroz1 ,
I trust you are doing great.
Please find below code for the same:
var GetUserIncidents = Class.create();
GetUserIncidents.prototype = {
initialize: function() {
},
getIncidentsForCurrentUser: function() {
var currentUser = gs.getUserID(); // Get the sys_id of the current user
var incidentList = []; // Initialize an array to hold the incident numbers
var gr = new GlideRecord('incident'); // Query the incident table
gr.addQuery('assigned_to', currentUser); // Filter incidents assigned to the current user
gr.query();
while (gr.next()) {
incidentList.push(gr.getValue('number')); // Add the incident number to the array
}
return incidentList; // Return the array of incident numbers
},
type: 'GetUserIncidents'
};
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi