concept on g_scratchpad

Rajkumar Bommal
Tera Contributor

Hi 
How would i Show Alert message on creating an incident record it should display the caller's location. By using g_scratchpad in BusinessRule and client script..

1 ACCEPTED SOLUTION

@Rajkumar Bommal - ah apologies, it was the caller's location not the current user.šŸ˜…

 

If so, you can update the BR to 

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

    var userGr = new GlideRecord("sys_user"); 
    userGr.get(current.getValue('caller_id'));
    g_scratchpad.currentLocation = userGr.getDisplayValue('location');

})(current, previous);

View solution in original post

18 REPLIES 18

James Chun
Kilo Patron

Hi @Rajkumar Bommal,

 

You would first create a Business Rule as the following:

  • Table: incident
  • When: display
  • Script:
(function executeRule(current, previous /*null when async*/ ) {

    var userGr = new GlideRecord("sys_user"); 
    userGr.get(gs.getUserID());
    g_scratchpad.currentLocation = userGr.getDisplayValue('location');

})(current, previous);

 

And the client script will be:

  • Table: Incident
  • Type: onLoad
  • Script:
function onLoad() {
   alert(g_scratchpad.currentLocation );
}

 

Cheers

 

Rajkumar Bommal
Tera Contributor

Hi @James Chun 
its not working however its just displaying a blank error 

RajkumarBommal_0-1711620187705.png

 

Does the user have a location associated with the account?

Works fine in my PDI

JamesChun_0-1711620461297.png

 

Rajkumar Bommal
Tera Contributor

Yes User have location