- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 01:04 AM
Hi,
I have written script to auto populate assigned to based Business Unit. Now I want to auto populate business unit watchlist members to incident table watchlist based on Business Unit.
I written script include and client include.
script include
var BasedOnBuAutomatingAssignment = Class.create();
// Set the prototype of the class to extend the global.AbstractAjaxProcess object
BasedOnBuAutomatingAssignment.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
// Define a method to check if the class is public
isPublic: function() {
return true;
},
// Define a method to retrieve user attributes based on the provided business unit
getUserAttributes: function() {
var assign;
// Get the 'sysparm_deputedbu' parameter from the request
var dbu = this.getParameter('sysparm_deputedbu');
// Build a query to retrieve the primary internal DIP SPOC for the specified business unit
var query = 'u_primary_internal_dlp_spoc!=NULL^name=' + dbu;
// Create a GlideRecord object for the 'business_unit' table
var grBu = new GlideRecord('business_unit');
// Add the encoded query to the GlideRecord
grBu.addEncodedQuery(query);
// Execute the query
grBu.query();
// Check if a record was found and retrieve the 'u_primary_internal_dIp_spoc' field value
if (grBu.next()) {
assign = grBu.u_primary_internal_dlp_spoc;
}
// Return the assigned user value
return assign;
},
type: 'BasedOnBuAutomatingAssignment'
});
On Change client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// Check if the form is still loading
if (isLoading) {
return;
}
// Check if the new value is an empty string
if (newValue === '') {
// Clear the value of the 'assigned_to' field and return
g_form.clearValue('assigned_to');
return;
}
// Create a new GLideAjax instance for making server-side calls
var ga = new GlideAjax('BasedOnBuAutomatingAssignment');
// Add parameters for the server-side script
ga.addParam('sysparm_name', 'getUserAttributes');
ga.addParam('sysparm_deputedbu', newValue);
// Make an asynchronous server call and handle the response with the setAT function
ga.getXMLAnswer(setAT);
}
// Callback function to set the value of 'assigned_to' based on the server response
function setAT(answer) {
g_form.setValue('assigned_to', answer);
//this is for testing
}
Note: I want to auto populate u_backup_team_memebers (Wathclist) to incident table watchlist(watchlist).
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 01:57 AM
in the client script you have written assigned to then how the watchlist will be populated
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 01:57 AM
in the client script you have written assigned to then how the watchlist will be populated
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 02:04 AM
Where did you add this? In your script include? What is your current there?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 02:08 AM
yes, I have added it in script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:24 AM
From where is the script include triggered? What are you passing as current? You will need to return something to somewhere. I think, also looking at the other answers, that we are missing logic. Can you give us your requirement instead of the solution you came up with?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark