Posts

Showing posts from September, 2022

Server Scripts

  GlideRecord var count = 0; var gr = new GlideRecord('pm_project');  gr.addQuery('state', 2);   //Active gr.addQuery('number', 'PRJ0146055');   gr.addEncodedQuery('u_sap_stateIN30^u_sap_state=30');  gr.query(); //gs.info("Records in Project table: " + gr.getRowCount()); while(gr.next()){     count++;     gr.u_sap_state = 90;    // gr.update();     gs.print (gr.sys_id); } gs.print ("DONE " + count); Calling Script Include from Server     var getEDP = new BS_Company();     var orgInfo = getEDP.getUsersCompanyExtendedDemandProcess(gs.getUserID());     if (orgInfo == true) {      } GlideDateTime and GlideDate To get this black background put the script into a background script and copy it  #### Using GlideDateTime and GlideDate var todaydt1 = new GlideDateTime (); Result :   2023 - 07 - 11 13 : 48 : 32   // This is todays date and time var gdt = ne...

Client Scripts

  Replace String within a String or find something within a String const p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?'; alert (p.replace('dog', 'monkey')) ; <- This is not working in a UI Action Use: if (mainString.includes(searchString)) { } indexOf https://www.w3schools.com/jsref/jsref_indexof.asp const str = 'Mozilla'; console.log(str.substring(1, 3)); // Expected output: "oz" console.log(str.substring(2)); // Expected output: "zilla" Lovely Dates in Client scripts GlideDateTime is only for the Server so heres a client script to populate with todays date and time.. This helps: https://www.freecodecamp.org/news/javascript-date-now-how-to-get-the-current-date-in-javascript/ --> Script 1 function  onLoad() {      // This code will set the field end_date style to Orange if the task is due to finish within 7...