Client script

Ram012
Tera Contributor

when the user create the problem record , you should show the message of total number of records created by the currently log in user for the problem table using OOB problem table ?

 

Using the  After BR but i need to same scenaior  build the client side script.

 

// Get the current user's ID
  var currentUser = gs.getUserID();
 
  // Get the total number of problem records created by the current user
  var gr = new GlideRecord('problem');
  gr.addQuery('opened_by', currentUser);
  gr.query();
  var totalRecords = gr.getRowCount();
  {
 
  gs.print('You have created a total of ' + totalRecords + ' problem records.');   // Show the message
}
 
Any idea help me.
6 REPLIES 6

Ram012
Tera Contributor

Hi Tripu,

 

Same code i have write already but where i can check its working not or not as per the requirement.

Community Alums
Not applicable

Hi Amar,

 

You can go through below script whenever record insert or update business rule will show the info message.

 

(function executeRule(current, previous /*null when async*/) {

// Get the currently logged-in user

var userID = gs.getUserID(); // Query the Problem table to count the number of records created by this user

var problemGR = new GlideRecord('problem');

problemGR.addQuery('opened_by', userID);

problemGR.query(); // Count the records

var recordCount = problemGR.getRowCount(); // Display a message to the user

gs.addInfoMessage('You have created a total of ' + recordCount + ' problem records.');

})(current, previous);

 

 

Thanks!

 

 

KishoreT_0-1724057388691.pngKishoreT_1-1724057449395.png