Quantcast
Channel: ServiceNow Community - JavaScript
Viewing all 197 articles
Browse latest View live

Inbound email actions and using Scripts Includes

$
0
0

Hi all
Now we have our system running for a few weeks and the main bugs are now resolved, I am now sorting out some e-bonding which is working via email. all good and I am now looking to make it a little easier to understand for fellow admins (who are not so good with Javascript)

At the moment I have the same code in both the update and the New incident routine. - shoddy I know, but as we tested we saw that some responses came in as a new Incident and others as a reply (When treated as a new ticket on their system it does not preserve the watermarks, but subsequent updates do)

read more


Business Rule to add user onto the incident watch list of certain tickets

$
0
0

Dear,

I'm looking for help with conditions that trigger a business rule to add someone onto a watch list under certain conditions on my Calgary instance.
The conditions are based on location = MAD and the ticket assignment group, I would like to have all assignment groups starting with SAP.
Is there an option to say current assignment group like "SAP%" or current assignment group contains "SAP"
Currently the rule works fine but adds the user on too many tickets (all assignment groups) (see attached screenshot).

Business Rule:
Name - Add to watch list
Table - Incident

read more

Script to kick in after ticket has been created/saved originally

$
0
0

Hi folks,
Im creating an 'on change' client script to prevent our Itil users from updating a ticket if the 'Assigned to' field is blank.
We are trying to force them to accept the ticket or ensure it is with an individual first before they can update it.
I have added a role to the script so that the EMEA Servicedesk group are excluded from this.
I have also said if the assigned to is blank make 'comments' read only so they cannot update.
It also gives an alert too.
Script below.
Im trying to set the script so that it only activates after the incident is originally saved.

read more

Create new Check Box

$
0
0

Hi,

How to create check box in a form .
Please suggest.

Thanks

Notification dont display variables like ${number} - called via business rule on incident table

$
0
0

Hello,
Please help here.
I have business rule scheduled to run with scheduled job.
In this rule i need send notification. All is erady but when notification is send out from tool, body dont contain my variables defined in notification.

I call notification like here at the end of business rule gs.eventQueue("incident..fivedays", null, tiket.caller_id.email, null);
All is fine, but I have only problem that notification email dont take variables like ${number} and simmilar.

Can somebody help please ?
Petr

Setting Category/Subcategory with a client script

$
0
0

Hello,

We're making a onChange client script that sets the category / subcategory values from a CI. It runs when the CI changes. Our problem is that the subcategory value is changed back to --None-- after our script is finished. I guess because it is the default value.

How can I make the value I set in subcategory stick?

Thanks,
Jeromy

Calling a Script Include function from the Condition Block

$
0
0

How do you call a Script Include from a Condition Block on a UI Action?
var aclrules = new ACLRules();
aclrules.isTaskOwner(gs,current);

i want to use the result of the function and AND it to the condition statement.

re-number old records

$
0
0

Hi all,

I have a table that I want to update all existing records with an ID number. How can I do that with a script?

any ideas?
Thanks!


Placing Service Catalog Variables in System Created Request

$
0
0

Currently we have this UI Action created that Copies a current requested item if it is closed or cancelled so that it can be re-created with all the information attached.

//This UI action creates a copy of the current RITM and transfers all data to the new copy with a new number.//The intent is to allow users to copy a RITM in any state in order to reduce the amount of keying to create//recurring requests. 
//Get current workflow.var thisFlow = current.cat_item.workflow.toString();
var oldNum = current.number.getDisplayValue();
 
var prevDesc ='Variables:';

read more

User Interface

$
0
0

How do you make the information icon disappear based on access rules for Tasks ? or for any other table ?

Set font color in a script?

$
0
0

I am displaying the Caller's phone number on the incident form and setting it to read-only through a script. The script displays the phone number field only if it contains a value, and uses setReadOnly() to set it to read-only. The problem I am having is that the read-only field is grayed out making it hard to read, and I would like to set the font color to black.

read more

Inbound email scripting assistance

$
0
0

We have a number of inbound email scripts that have been working nicely until lately... We use it to sync contact information form an Oracle DB to our users and companies within SN.

Target table is Company, and the inbound email comes in with variable pairs one per line, body example is:
firstname: FIrstn
lastname: lastn
phonenumber: 614-222.2222
jobtitle: emailaddr: first.last@boo.edu
datasource: CSDB Email Submit by boo
clientid: 10534975
mobilenumber:
client: Company name
contactid: 215765
inactive: 1
incident: no

SN reports back in error logs:

read more

Reading LDAP for a single user and populating sys_user

$
0
0

I'm attempting to do a single user update of the sys_user record. Click a button, it grabs the userid, does an LDAP query and then re-populates the sys_user record.

So far I have this as prototype code:

/* Query LDAP for a specific UserID */ 
    var ldapServer =new GlideRecord("ldap_server_config");
    ldapServer.addActiveQuery();
    ldapServer.query();
 
    while(ldapServer.next()){var ldap =new GlideLDAP();
         ldap.setConfigID(ldapServer.getUniqueValue());
         var env = ldap.setup();
         var query ='';

read more

Need help with Client Script to Copy Requested For

$
0
0

I found a Client Script on the forum that's working for us with the exception of copying the Requested For when creating Time Worked from the SC_Task table. The short description is copying from the sc_task to the Time Worked, I've tried several different variations for the request.requested_for but can't seem to get it to work. Incident works fine too, when creating Time Worked from the Incident.

function onLoad() {
//Only run for new tickets
if(g_form.isNewRecord()){
//Populate requested_by based on parent

var par = g_form.getReference('task', popRequestedBy);
}

read more

Is it possible to remove or disable the Remove button from Manage Attachment page for a specific table except for a given role?

$
0
0

Would anyone know if it is possible to disable or remove the "Remove" button from the popup screen in Berlin without manipulating the UI Page that appears when you click the Manage Attachments? We don't want users to be able to remove attachments when added on an form for an application I am creating unless they have a given role.


Formatting this script to show Dollar and Cents $1,000.00

$
0
0

Foremost I am not a java scriptor, so if this client script I wrote looks crazy, it may be crazy, but it works. :) so I feel lucky!
If you wonder why I did the '*1' on the value, is it because they were not adding to a sum without this.

My challenge now is dilemma is the currency value I am displaying. I want to display this with dollars and cents.
The form value of 'TMW_IT_Purchase_request_grandtotal' appears as "1248" and I want it to appear as "$1,248.00".

Would someone be willing to show me what I am missing.

read more

On Change of two fields

$
0
0

There is a field named 'abc' in a form which is dependent of fields 'abc1' and 'abc2'. Whenever 'abc1' or 'abc2' changes, 'abc' also gets changed. Is there any way to check for both the fields for their onchange in one client script or UI policy?

Restricting a certain client Script from ESS users

$
0
0

Hi folks,
I have created an 'on change' client script to prevent our Itil users from updating a ticket if the 'Assigned to' field is blank.
Script below.
We dont want this script to apply to Self Service Users.
I was thinking the best way to do this is to allow the Caller ID and Opened by (possibly the watch list too) to bypass to script so that it doesnt apply to them meaning self service users would be able to update the ticket even if the 'assigned to' field is blank.
Am I on the right track thinking this?

read more

Slush Bucket with Regular forms

$
0
0

Trying to get a slush bucket on a regular form. Does not pull any data from the source table. can someone show me this.

This seems to work fine on catalog forms

thanks

Simple GlideAjax question

$
0
0

So this is hopefully a simple GlideAjax question. It seems to be however I am having trouble figuring it out.

Long story short, I am trying to make an automated process in which users can add or remove members of a group (after manager approval). The workflow is all set; that part works flawlessly. However, the issue I am having is limiting the options in the list collector. I am trying to set filters on a list collector using a Script Include and Client Scripts, however it just is not working for me...see code below:

Script Include

read more

Viewing all 197 articles
Browse latest View live