Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
insert() does not work in workflow if there is a timer activity before the script activity - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • insert() does not work in workflow if there is a timer activity before the script activity
KB0782902

insert() does not work in workflow if there is a timer activity before the script activity


626 Views Last updated : Sep 21, 2024 public Copy Permalink
KB Summary by Now Assist

Issue

insert() doesn't work in workflow if there is a timer activity before the script activity in New York.

 

In the below workflow, query a non-admin user and try to add the "admin" role to the user in the "script" activity using "gr.insert()" on "sys_user_grmember" table.

It will fail to add an admin role since the "timer" activity changed "run by" from Login-use to SYSTEM.

This was working fine on London.

 

Cause

Admin now contains protected role "sn_templated_snip.template_snippet_admin" and thus timer run by a SYSTEM and then try to add role which assigns role such as admin (inherited) that contain protected role, then add fail.

Resolution

Possible workaround is to impersonate to another admin user before "insert()".

=====
Sample Only
--------
var myUser = gs.getSession().impersonate('user_sys_id');
gs.getSession().impersonate(myUser);
=====

 

 


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.