Execute a Glide Record insert via a Record Producer Script or a Script include as Admin

Tom Siegel
Kilo Guru

Hello - I have a record Producer Script with a function that does a glide record insert gr.insert() on the Group Member table (sys_user_grmember). I am having an issue inserting a record that has one particular group but not a different group.

I tried implementing the function that does the insert in a script include, then having the script include do the gr.insert(). This also behaves the same way.

For the group that is working, the record created on the group member table is showing the User who executed the Record Producer, as the "Created by". I am now trying to have the record created on the Group Member table created under the Admin account.

In other words I want to have the gr.insert() executed as the admin account.

 

Any suggestions would be appreciated.

1 ACCEPTED SOLUTION

Tom Siegel
Kilo Guru

We figured out a way to do this by creating an "Event Registration" and a "Script Action". The event is "created" by a call in the Record Producer. When the event is processed the parameters are passed to the Script Action which writes the Record. The record shows as created by "system", which for our case works as we needed.

The Record Producer contains the following Call to the Event

 

 

var itilGrp = "50be8f9edb1af114a46c6f8b13961995";
var userID = gs.getUserID();
gs.eventQueue('add_user_to_case_write_access_group', null, userID, caseGrp);
//The arguments are (Event Name, Glide Record, parm1, parm2)

 

 

Here is the EventEvent.PNG

and here is the Script Action

ScriptAction.PNG

I hope this saves someone some time!!!

View solution in original post

4 REPLIES 4

harshav
Tera Guru

In your script, add another line gr.sys_created_by = gs.getUser().getUserByID('admin');  inplace of admin pass your admin account id. If it doesn't work you can also use gr.setWorkflow(false) and give a try it might execute because if there are any business rules this will stop running them.

Tom Siegel
Kilo Guru

Harshav - Thanks for the reply but that didn't work. I also have gr.setWorkflow(false); set.

 

Thanks...

Tom Siegel
Kilo Guru

Please note - I have also tried "gs.getSession().impersonate("admin sys_id'). Which did not work.

Thanks....

Tom Siegel
Kilo Guru

We figured out a way to do this by creating an "Event Registration" and a "Script Action". The event is "created" by a call in the Record Producer. When the event is processed the parameters are passed to the Script Action which writes the Record. The record shows as created by "system", which for our case works as we needed.

The Record Producer contains the following Call to the Event

 

 

var itilGrp = "50be8f9edb1af114a46c6f8b13961995";
var userID = gs.getUserID();
gs.eventQueue('add_user_to_case_write_access_group', null, userID, caseGrp);
//The arguments are (Event Name, Glide Record, parm1, parm2)

 

 

Here is the EventEvent.PNG

and here is the Script Action

ScriptAction.PNG

I hope this saves someone some time!!!