Announcing the Global SNUG Board of Directors. Learn more here

ServiceNow Community servicenow community

  • English (US)
  • English (UK)
  • Portuguese (Brazilian)

developer

  • ServiceNow Community
  • IT Operations Management

Auto-assign assignment groups

  • Subscribe to RSS Feed
  • Mark Question as New
  • Mark Question as Read
  • Float this Question for Current User
  • Printer Friendly Page

ethal

  • Mark as New
  • Report Inappropriate Content

‎08-09-2007 04:58 PM

  • Service Mapping
  • 1,758 Views
  • All forum topics
  • Previous Question
  • Next Question

Chris York

‎08-09-2007 06:47 PM

‎08-13-2007 10:46 AM

‎08-13-2007 11:04 AM

‎08-13-2007 03:50 PM

  • Assignment Group Duration of Incident Excluding OnHold Time in ITOM forum a week ago
  • Set Support Group From discovery schedule to CMDB CI field. in ITOM articles 2 weeks ago
  • Create report for all Change Requests that have touched or assigned to my list of assignment groups in ITOM forum 03-18-2024
  • Notify the group based on Assignment group change in incident. in ITOM forum 03-18-2024
  • Remediation tasks when a cloud catalog item fails in ITOM forum 01-15-2024

set assignment group client script servicenow

mtcoffee

A ServiceNow and DevOps enthusiast. I use this blog to share ideas and learn from others.

  • Custom Social Profile Link

ServiceNow Automatically set Assignment Group

1 minute read

This is a useful tidbit for auto populating assignment groups. ServiceNow does have a few features that make it possible to auto assign groups based on criteria such as:

  • Assignment Lookup Rules
  • Data lookup definitions

However, sometimes a simple client script can offer less overhead. In this case I had the following requirements.

  • When a requester picks a group it will auto set the assignment group to the Configuration Item approver group
  • The requester can accept this or choose to override it
  • If a group is not found on the CI, a pop up will alert them to select it manually

To accomplish this the client script was as follows:

Name : Populate Assignment Group Type : onChange Field Name : cmdb_ci (Configuration Item)

Set that on your table (incident/change etc) and your all set!

Why not Assignment Rule?

I was asked, why not create an assignment rule, after all its built into the product. For example a simple rule under System Policy -> Assignment, defined using this script snippet will work.

Sample snippet:

However it is server side and does not set until after the user saves the record. This would be ideal if you wanted to “Hard enforce” that the assignment group must be set by the CI, however if your requirement is to allow the user to override then a client script is the preferred route.

Leave a comment

You may also enjoy, kubernetes servicenow discovery - the better way using cno for visibility.

3 minute read

Summary Recently I put together a walk through of Kubernetes ServiceNow Discovery using traditional Discovery Schedules. This works but is not a great method...

GitOps with ArgoCD on K3s

2 minute read

Summary For my ServiceNow readers, this post will not touch on ServiceNow but if you like Kubernetes and are interested in Continuous Deployment, read on! Fi...

Kubernetes Demystified and ServiceNow Discovery part1

Summary What is Kubernetes exactly? If you’re not in the DevOps space it can sound like voodoo. Let’s start with a little history.

Kubernetes Demystified and ServiceNow Discovery part2

Now that we have a Kubernetes Cluster to Discover, lets dive into ServiceNow Kubernetes Discovery. This example assumes you have a MID Server that can conne...

ServiceNow: Building Powerful Workflows by Tim Woodruff, Ashish Rudra Srivastava, Martin Wood

Get full access to ServiceNow: Building Powerful Workflows and 60K+ other titles, with a free 10-day trial of O'Reilly.

There are also live events, courses curated by job role, and more.

Setting the Assignment group with Assignment Rules

Assignment Rules are a simpler alternative to Data Lookup. While Data Lookup is very powerful, allowing you to set any field, it does involve a quite a bit of configuration, including creating a new table.

In contrast, an Assignment Rule uses the simpler condition builder to specify when it should run. If it matches, then it'll either populate the Assigned to and Assignment group fields with a hardcoded value, or you can use a script. We have got the group we want to use in a property, so this option is perfect. Follow these steps:

  • Name : Assign to External Team
  • Table : Maintenance [x_hotel_maintenance] ...

Get ServiceNow: Building Powerful Workflows now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.

Don’t leave empty-handed

Get Mark Richards’s Software Architecture Patterns ebook to better understand how to design components—and how they should interact.

It’s yours, free.

Cover of Software Architecture Patterns

Check it out now on O’Reilly

Dive in for free with a 10-day trial of the O’Reilly learning platform—then explore all the other resources our members count on to build skills and solve problems every day.

set assignment group client script servicenow

Advance Your Career

GlideForm (g_form) Cheat Sheet

GlideForm (g_form) Cheat Sheet

Glideform (g_form) cheat sheet for servicenow devs, below is a list of commonly used glideform (g_form) client side code that you can come back to daily while writing scripts in servicenow., the examples are grouped by:.

  • Field based Methods
  • Related List Methods
  • Section based methods
  • Decoration methods
  • HTML based methods

Some good places to use these are:

  • Client Scripts
  • Catalog Client Scripts
  • UI Policies

Field-based Methods:

Related list methods:, section-based methods:, decoration methods:, html-based methods:, action methods:, looking for something else check out our other cheat sheets below.

  • User Object Cheat Sheet

GlideRecord Cheat Sheet

  • Release / Version Cheat Sheet
  • How to find a background script that you lost
  • How to add a hyperlink to an addInfoMessage
  • CIS - SAM Exam Study Guide

Interested in making more money as a ServiceNow developer? We're here to help. We're launching a set of courses, 1:1 mentorship and a community to help you increase your earnings.

To learn more, sign up here:  make more money as a servicenow developer.

set assignment group client script servicenow

How To Get Certified In ServiceNow

set assignment group client script servicenow

How To Move Updates Between Update Sets In ServiceNow

set assignment group client script servicenow

How To Add A Hyperlink To A Notification In ServiceNow

set assignment group client script servicenow

How To Script In Flow Designer

set assignment group client script servicenow

How To Dot-Walk Inside of a Client Script in ServiceNow

© Snowycode 2022. All rights reserved.

ServiceNow Guru Logo

Change Form View Client Script

S ervice-now allows administrators a lot of flexibility in defining which elements appear on a particular form or list. The set of fields and related lists that appear are collectively defined as a View. One common configuration task is to somehow limit access to a particular view based on a user role or some information on the record being viewed. Instructions for working in some of these scenarios can be found here…

— View Rules — Restricting Form Views by Role

Neither of these methods work if you need to change the view of a form from a client script or a UI action. In order to do that, you can call the ‘switchView’ function as follows…

The table and view parameters should be self explanatory. The ‘type’ parameter is either ‘list’ (to redirect to a list view) or ‘section’ (to change to a form view). Here’s an example client script that shows how you could use ‘switchView’ to change the incident form view to ‘ess’ if the ‘Category’ field changed to a value of ‘hardware’.

set assignment group client script servicenow

Mark Stanger

Date Posted:

July 23, 2010

Share This:

25 Comments

' src=

I want to change the form view based on the role of user, severity and particular assignment group entered on incident form.

I can not use view rule, as there is no scripting space in view rule to check desired role of user. I want similar functionality as “view rule” where on change of severity, group and based on user role form view should be changed.

I tried to use switchview() method on submit of incidnet form for form section of incident table but observed that it changes the list view and not the existing form view. For all the existing incident records which matches to the conditions I’m not able to see the changed view.

Also, not able to use business rule – incident functions, this BR changes the view for the first time but on change of severity and assignment group it doesn’t change to desired view. Can you please suggest how to change form view based on user role with changes in incident fields?

' src=

It sounds like the function is working then, but you’re triggering it at the wrong time. Based on what you’ve explained, It sounds like you should be triggering the script in an ‘onChange’ or ‘onLoad’ client script.

Thanks for your quick response. I have tried to use switchView in an onLoad script. I have created views in global domain and scripts are domain specific. For onLoad, switchView loads the page again and goes into infinite loop and it changes the list view but not the form view. View change should be only to specific incident record for which condition matches and not for all. In view rule, it changes the view only if condition matches for form section and not for the list. Here is the code snippet for onLoad script –

Please let me know if I need to handle this by any other way.

I think you’ll need to check for the view as part of your conditions to prevent the endless loop. Something like this should allow you to detect the view and only switch the view if it needs switching.

Thanks Mark, now I can change the form view based on condition on load of form but it changes the list view as well. I need to change only the form section view for particular incidents where conditions matches. I am passing ‘section’ as parameter to method but it still changes the list view. Can we restrict view change to the form only?

The list view on a redirect will always be the same as the form view you’re coming from. You’ll need to set that view back to the original view in an onSubmit client script (using the ‘switchView’ function) or a business rule (using ‘gs.setRedirect()’). http://wiki.service-now.com/index.php?title=Navig …

switchView method saves the data before changing the view therefore when onLoad script tries to switch view, it calls the onSubmit script where I need to reset the list view to default and that doesn’t change the form view to desired one and changes it to default one. Also, with the business rule tried to create it after update on incident table to redirect it to default list view by passing sysparam_view as blank – gs.setRedirect(‘incident_list.do?sysparm_view= ‘); this doesn’t change the list view.

This seems to work just fine for me in an ‘after’ business rule. Try it out on the Service-now demo site to confirm.

Business rule works only if there is no onLoad script to change the form view. I have onLoad script which changes form view, when I update that record it redirects it to list view but view is not getting set to default. I have tried this on demo as well. Please see client script – force default view and BR – Force default view. In client script I’m setting form view to ess and in business rule I want to set list view to default. Once the list view gets set by switchView method business rule is not able to reset it. Please let me know if there is any other way to set the list view to default view.

I’m not sure what else to tell you. The only other thing I can think of is that your system has this property set under ‘System Properties->System UI’. I noticed that was the case in demo this morning even though I couldn’t find your scripts.

It looks like this property… ‘When a user changes the view used for a list or for a record, continue to use that view for future displays.’…needs to be set to ‘false’ for this to work.

If this doesn’t work, then you may need to ask on the Service-now forums. I’ve been able to get this to work several times without issue and I don’t have any other suggestions to give.

I’ve been working with this today, couldn’t understand why ITIL user wasn’t switching….

Until I checked the various roles in the system, added ‘view_changer’ to my ITIL user and now everything seems peachy…

I have a requirement from a business unit that a form not be visible to certain personnel, unless actually assigned to them. Any way to easily script a rule like this?

You could script it using something like this, but it would probably be pretty clunky. What I would probably do is leave the form alone and set up ACLs so that users couldn’t see the data in the record. It’s probably not the form that people are concerned about, but the information displayed on it.

I can not change the view for an ESS user.

Seems that the system prevents this and allows only default or ess view for an self-service user.

Even when they are coming from different companies and we have domain separation by company.

The behavior you are seeing is caused by the ‘incident functions’ business rule. It forces users with no role to always see the ‘ess’ view for incident records. What you’ll want to do is modify the script in that business rule so that it allows users to see the ‘ess’ view or your new view. Here is a wiki article explaining the details. http://wiki.service-now.com/index.php?title=Restr …

You can either make sure your new view name starts with ‘ess’ or you can modify this portion of the script to allow for both views…

(With a UI Action form button) I’ve tried the following and other variations to switch the view for a project record. The goal to to give the Project User the ability to toggle back and forth between the “project_report” view and the “default” view. It is not yet working.

//switchView('section','pm_project','project_report'); //gs.setRedirectURL("pm_project.do?" + current.sys_id + "&sysparm_view=project_report");

action.setRedirectURL("pm_project.do?sysparm_sys_id=" + current.sys_id + "&sysparm_view=project_report");

I have the requirement to hide the filter on the basis of view for e.g I want to hide filter for every user on the ess view. I wrote a script include i.e: function incidentDisplayFilter() { if (view.startsWith(“ess”)) { answer = false; } else { answer = true; } return answer; }

But my problem is that it’s working fine only for incident if I apply this for any other table it hides the filter for every view.

HI, Is there a way to force the list view like there is for forms by using the View Rules module? Thanks Peter

Not with view rules. View rules are based on the conditions of a specific record, which you can’t determine on a mixed result set in a list. You can force a view in a list view only by using the ‘sysparm_view=’ parameter in the URL that points to that list.

Thank you for the reply. The list view can be specipied from the navigation panel modules, the Homepage filters but the URL is left open to manipulation. Does it mean changing the Script Include: ViewManager, _listSelected function if you want to force a change to a list view ? Say for a particular type of non-roled user, similar to what sys_script_ajax does for HomeScripts, homeGetViewName Thanks Peter

Role-based view rules for entire tables can be accomplished for lists in the system. An example of this is forcing non-roled end users to the ‘ess’ view of the incident table. You can check out the ‘incident functions’ global business rule to see how this is done and apply it to other tables as needed.

Not having script in View Rules is a major oversight in the product, in fact the whole view management is poor IMHO. It works well as long as you want to have one view for every end user and one for ITIL users and nothing else – everything else is a clunky kludge.

Is there anyway to force a view on to a record in a related list? For example, if I’m in a view called ‘test’ for a company record and click on a company a related list, i don’t want to see the ‘test’ view, I want to see ‘default’ view.

Thanks, John

Check out this article. Your mileage may vary depending on the ServiceNow version you’re using but I’ve used this method successfully in the past.

https://servicenowguru.com/scripting/client-scripts-scripting/overriding-servicenow-form-view-inheritance/

That worked. Thanks!

Comments are closed.

set assignment group client script servicenow

Randall King says:

  • Business rules
  • Client scripts
  • Content management
  • Email Notifications
  • General knowledge
  • Graphical workflow
  • Integration
  • Knowledge Management
  • Miscellaneous
  • Relationships
  • Script includes
  • Service Portal
  • Single Sign-on
  • System Definition
  • Web Services

Related Posts

Adding Icons to UI Action Buttons in ServiceNow

Adding Icons to UI Action Buttons in ServiceNow

Client Side Dates in ServiceNow

Client Side Dates in ServiceNow

Granular Control of Form Tab Toggle Behavior via Client Scripts

Granular Control of Form Tab Toggle Behavior via Client Scripts

Fresh content direct to your inbox.

Just add your email and hit subscribe to stay informed.

set assignment group client script servicenow

Since 2009, ServiceNow Guru has been THE go-to source of ServiceNow technical content and knowledge for all ServiceNow professionals.

  • Application Portfolio Management (APM) assessment challenges
  • Knowledge Translation using Localization Framework and Azure
  • Localization framework fulfillment (LP, LRITM, LFTASK)

© Copyright 2009 – 2024 | All Rights Reserved

web analytics

developer portal logo

Your browser or one of your plugins is not allowing JavaScript to be run. This is a bummer since the ServiceNow Developers Site is dynamic and depends on JavaScript to function. If you want to visit this site, please disable the plugin, activate this site for JavaScript or use another browser.

IMAGES

  1. ServiceNow Client Script Tutorial Part -2

    set assignment group client script servicenow

  2. Client Script ServiceNow

    set assignment group client script servicenow

  3. Test Your Client-side Scripting Knowledge

    set assignment group client script servicenow

  4. ServiceNow

    set assignment group client script servicenow

  5. #7 Create Client Script in ServiceNow

    set assignment group client script servicenow

  6. Client Script Types

    set assignment group client script servicenow

VIDEO

  1. Enterprise Asset Management

  2. Client script in #servicenow

  3. onSubmit client script in #servicenow

  4. onchange client script servicenow|ServiceNow OnChange Client Script Tutorial with Demo in Hindi

  5. ServiceNow

  6. ServiceNow

COMMENTS

  1. Auto-assign assignment groups

    Condition: Assignment is [blank] Script: current.request_item.request.requested_for.location.u_default_site_group If the Delivery Plan set a specific group, this rule did not run. For the cases where we wanted the Local Assignment Group to get the task, we just made sure the Delivery Plan had a NULL Value for the Group.

  2. servicenow

    current.task_fulfillment_group.setValue(assignment_group); as that would be a Sys ID and not the display value of the location. The script would be running on the current task record, so it's accessed using current. Also, take steps to verify that the field name is indeed task_fulfillment_group.

  3. ServiceNow Automatically set Assignment Group

    This is a useful tidbit for auto populating assignment groups. ServiceNow does have a few features that make it possible to auto assign groups based on criteria such as: Assignment Lookup Rules. Data lookup definitions. However, sometimes a simple client script can offer less overhead. In this case I had the following requirements.

  4. Client Script To Update Assignment Group from Short description

    Quick rundown on a client script to update your assignment group from keywords in the short description.Community Articlehttps://www.servicenow.com/community...

  5. Configure group types for assignment groups

    Configure group types for assignment groups - Product Documentation: Tokyo - Now Support Portal. Use the Type field to define categories of groups. Once defined, you can use these categories to filter assignment groups based on the group type using a reference qualifier. For example, when selecting.

  6. Client Script Type

    For example, one onChange() Client Script populates the 'Assignment group' field if the value in the Configuration item (cmdb_cil field changes, while a second onChange() Client Script populates the Watch List if the value of the 'Priority' field changes to 1. An onChange() Client Script runs when a particular field value changes on the form.

  7. r/servicenow on Reddit: Update assignment group based on a script on a

    Update assignment group based on a script on a record producer. Description: I currently have a script on our user facing service portal that changes the assignment group based on the incident type selected. I currently have it assigning to one group if the "policy" type is selected, however, I would like to add an additional section to this ...

  8. ServiceNow Developers

    Building strong functionality in ServiceNow begins with writing high-quality code. Take steps to make your code manageable, efficient, and scalable from the early stages. ... Set Client Script Order. ... //Set Assignment Group to CI's support group if assignment group is empty function onChange(control, oldValue, newValue, isLoading, isTemplate ...

  9. Setting the Assignment group with Assignment Rules

    In contrast, an Assignment Rule uses the simpler condition builder to specify when it should run. If it matches, then it'll either populate the Assigned to and Assignment group fields with a hardcoded value, or you can use a script. We have got the group we want to use in a property, so this option is perfect. Follow these steps:

  10. Client Script Types

    Use onSubmit Client Scripts to validate field values. For example, if a user submits a Priority 1 record, the script can generate a confirmation dialog notifying the user that the executive staff are copied on all Priority 1 requests. NOTE: The Type field has a fourth option: onCellEdit. The onCellEdit Client Script type is for lists rather ...

  11. Create an assignment rule

    Script. A script to specify advanced assignment rule functionality. The current.variable_pool set of variables is available. Note: Make sure the input in the script is correct, and that the input type matches the field type in the Assignment Rule script. For example, if the assignment rule script sets the value of an Integer field, and the ...

  12. GlideForm (g_form) Cheat Sheet

    GlideForm (g_form) Cheat Sheet for ServiceNow Devs. ‍. Below is a list of commonly used GlideForm (g_form) client side code that you can come back to daily while writing scripts in ServiceNow. The examples are grouped by: Field based Methods. Related List Methods. Section based methods. Decoration methods.

  13. User Object Cheat Sheet

    To get any additional information about the currently logged-in user from a client-script or UI policy, you need to use a GlideRecord query. If at all possible, you should use a server-side technique described above since GlideRecord queries can have performance implications when initiated from a client script.

  14. Change Form View Client Script

    Neither of these methods work if you need to change the view of a form from a client script or a UI action. In order to do that, you can call the 'switchView' function as follows…. switchView(type,table,view); The table and view parameters should be self explanatory. The 'type' parameter is either 'list' (to redirect to a list ...

  15. Declarative Actions in ServiceNow: The COMPLETE Guide

    How it is implemented - i.e. Client Script, Server Script, or UXF Client Action. The table name Action Assignment being the place to create DA's may be a little confusing, especially since there's an Action Definitions sys_declarative_action_definition table and the term "definitions" is used elsewhere in the DA data model to be the ...

  16. GlideRecord

    ServiceNow provides JavaScript APIs for use within scripts running on the ServiceNow platform to deliver common functionality. This reference lists available classes and methods along with parameters, descriptions, and examples to make extending the ServiceNow platform easier. Please note: The APIs below are intended for scoped applications and may behave differently in the global scope.

  17. Assigned to not clearing when Assignment group changes on ...

    On the incident table the assigned to clears when the assignment group changes but this does not happen on other tables like sc_task. Loading... Skip to page content Skip to chat. Skip to page content Skip to chat. The assigned to field is dependent on the assignment group. On the incident table the assigned to clears when the assignment group ...