Quantcast
Channel: ServiceNow Community - ServiceNow Scripting
Viewing all 208 articles
Browse latest View live

Background script to mass update Incident resolved_by and resolved_at fields

$
0
0

I have installed the plugin to create the resolved_by and resolved_at fields on the incident table. For existing records, I would like to mass populate these fields pulling data from the audit table using crystal reports and import this data into a temp table.

I tried using a background script (FIRST SCRIPT) and it wouldn't work. When it gets to the second while section, it appears to just go into an infinite loop. So I tired to simplify it (SECOND SCRIPT) and just manually set the value and it still goes through an infinite loop. What am I doing wrong?

FIRST SCRIPT:

read more


Add a UI Action Context Menu to Show a BSM Map for a CI

$
0
0

I saw a post which outlined how to add a UI action context menu to show a BSM map for a CI. In the SAND environment, I thought I'd try it out:

UI ACTION
Name: Show CI map
Table: CI’s Affected (task_ci)
List context menu: True
Show insert: True
Show update: True
Client: True
Onclick: showBSMMapList()
Condition: gs.hasRole(‘itil’) && RP.isRelatedList()

Script:
function showBSMMapList() {
//Retrieve the 'Affected CI' record
var sysId = typeof rowSysId == 'undefined' ? gel('sys_uniqueValue').value : rowSysId;
var gr = new GlideRecord('task_ci');

read more

Business rule order and extended tables

$
0
0

Does an extended table's business rules execute before the base table's business rules, regardless of the order specified, or is the order applied globally irrespective of the table?

Example:
BR on [task] with order of 100
BR on [incident] with order of 200

Which runs first?

"Force Password Reset 90 Days After Last Change" does nothing

$
0
0

Hi everybody !!

We have a problem when we implement the "Force Password Reset 90 Days After Last Change" we found in the WIKI.
When the scheduled job runs, it does nothing.
We have SNOW Berlin patch 10.
Have you the same problem or have you a solution for this issue ?
Many thnaks for your help.

I want to get subject from sys_email_log?

$
0
0

Hi Everybody,
Please let me know where i m doing mistake in following code:

My requirements is i want to return/print Subject name of (sys_email_log) table which is brought through Email(sys_email) table dot-walkin through background scripts/Business rules.

What i m getting is it returns only one value if i use if condition and if i use while in sys_email_log table as shown in following code then it doesn't query or match current logged in user. It return all Record which are in sys_email table.

Please help me in script where i should change.
 

read more

Execute Script via API?

$
0
0

Hi,

question is simple:
Is it possible to execute Script (e.g. like Script in "Scripts - Background") over SOAP or any other API?

Example: send Javascript as text via SOAP in PHP to a Servicenow instance and retrieve response text and do something with response in PHP.

Thank you

I want to get Event Name but

$
0
0

Hi All,

Please help me where i m doing mistake in following code actually i want to get the event name but i m getting sys_id of the event and i m running this code in Script - Background.

var myUserObject = gs.getUser();
var email_id= myUserObject.getEmail();
var gr =new GlideRecord('sys_email');
gr.addQuery('recipients','IN',email_id);
gr.query();
while(gr.next()){
   msysid = gr.sys_id;
   gr1 =new GlideRecord('sys_email_log');
   gr1.addQuery('email',msysid);
   gr1.query();
   if(gr1.next()){var  mevent = gr1.event.name;
gs.log(mevent);
   }}

read more

Accessing system properties outside of scripting blocks?

$
0
0

Is there any way to access the contents of a system property outside of a scripting block?

Specifically, I'm setting up several REST Web Service consumers; each has a separate endpoint, but each endpoint shares a common URL and will require (among other things) a common authentication token as a function parameter. These values are likely to change (the URL when we roll to production and the token on a regular basis). It's a no-brainer to just create these as system properties, right?

The problem is, now that I've created them as system properties, I can't seem to actually use them.

read more


Dynamically filter a reference field

$
0
0

Hello All,

I checked on the WIKI and the community board and didn't find an example of what I was thinking about.

We need to filter the assignment_group field based on an Incident template used. For this example, it could be 5-6 groups that may offer the support depending on the exact nature of the issue. We want to limit the "guesses" used by the end user.

I can't use the reference qualifier. I was thinking of using a business rule but was not sure if this was the best way to do it or if there is a better way to limit the list to only those five groups.

read more

Creating a GlideRecord and retrieving the current record

$
0
0

Hi everyone,

This may seem like a basic question to some of you, but I can't seem to get a handle on retrieving table information via GlideRecords. Mainly, I've been seeing different approaches to query a table (addQuery, RP.getParameterValue, if(!get('u_table_name', sys_id)), etc.). I've also looked into sysparam values and the wiki information has left me perplexed. Maybe I'm not looking in the right places for concise information, but any help would be welcomed.

read more

Can anybody suggest me how can i do?

$
0
0

Hi Everyone,

I have written one script(Script - Background) for getting report of sys_email_log table with recipients, Event Name and created also, according to logged in user(means if i have logged in with Abel tuter the the gauge/report will be only and only of Abel tuter not all others.

But I m facing problem here is, where should i put this code for getting result in filter and use on sys_email_log table.

var myUserObject = gs.getUser();
var email_id= myUserObject.getEmail();
var gr =new GlideRecord('sys_email');
gr.addQuery('recipients','IN',email_id);
gr.query();

read more

Counting Journal Entries

Get the data from the table and display on the screen

$
0
0

Can any1 please help me in getting data from the table and display on the screen in Service Now?

For Example: I have a dynamic content in a page with username and country name. Based on the username, country name will be displayed on the screen. Username and country name are stored in a table (UserInfo).

Thanks in advance

Change tab name of a related list

$
0
0

I'm trying to find a way to rename a tab for a related list that we have in a certain application module to make the purpose of the related list clearer.

Does anyone have any documentation found on the Wiki where this is possible? Or have a different method to my desired outcome?

Attached is a screenshot describing exactly what I want to do. Instead of the tab saying "Problems" I want it to say something else like "Problems Fixed" to make the purpose of the related list clearer.

UI Action - Need to disable the delete button for application specific forms for the users who don't have admin Role

$
0
0

I wanted to disable the delete button from the form for the application specific forms. I have written the UI action and can able to hide the delete button. The action name I have used is "sysverb_delete". I wanted to hide the delete button for the non admin users only.

The condition I have used in the condition section is "!gs.hasRole('admin')" and it does not work for me and delete button is disabled for the user who have "admin" role as well. please suggest me how to achieve this.

Thanks in advance...


Revert a list edit change

$
0
0

Hi,

I am trying to validate/revert a change made while editing an item in a related list displayed in a record. take the following script as an example:

Record: List Client Script
Type: onChange
List control: sales_opportunity
Field name: u_price

function onChange(sysId, oldValue, newValue){ 
  var price = newValue;
 
  if(isNaN(price)){// revert value/*
    what do I do here?
    somthing like: g_list.renderer.cancel(); // i know this method does not exist
    */return;
  } 
  /*
  Do stuff with number
  */ 
}

read more

Asset Management: Sync Records

$
0
0

In the new version of ServiceNow Asset Management, Assets are now in a separate table named Asset [alm_asset]. Prior to the Berlin release, assets were included in the Configuration Item [cmdb_ci] table. There are a lot of advantages with two tables, however the difficulty is to keep them in sync. Here are a couple notes on for asset/ci synchronization...

Read more at www.servicenowelite.com

What kinds of customizations prevent you from easily upgrading to the next release?

$
0
0

We're looking for roll out several additional modules in the coming months and something I've heard from other businesses is that certain customizations make upgrading the product to the next release challenging. We, like most customers, are interested in tailoring ServiceNow to suit our needs but we also need to be able to upgrade relatively quickly.

read more

Audit History - History Calendar

$
0
0

Is there a way to have the data details of a "history calender" of a record populate into an email notification?

For example, when a particular record has been updated, to generate an email with the history calender

Has anyone been able to achieve this?

How to make an image clickable in Navigation Menus?

$
0
0

Hi,

I have created a navigation menu of type horizontal blocks . It has several menu sections with section names and images(Left or Right). How to make these images clickable? URL redirection happens when user click on the section names. But in my case it should happen when user clicks on the image.

Please help me.

Thanks in advance

-
Amith

Viewing all 208 articles
Browse latest View live