The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TechNow Ep 14 | Avoid Hard Coding

Chuck Tomasi
ServiceNow Employee
ServiceNow Employee

expert-logo-2.png

Make changes to your ServiceNow solutions easier, faster, and cheaper by employing a few easy-to-follow best practices. We'll show you how and the thought process to follow to avoid hard-coding in your scripts and workflows.

Originally aired May 16, 2014   (Reposted June 15, 2016)
(Be sure to change your YouTube Setting to 720HD)

Have your questions ready to post below on this discussion page.

And Please Let our Expert Know how they've helped! Comment Below!

Like, Share, Mark Helpful. 


Featured Experts

find_real_file.pngChuck Tomasi is a Platform Architect for ServiceNow.   He is a computer science major with over 30 years of IT experience. As a former ServiceNow customer, Chuck won the first Innovation of the Year Award at Knowledge 10. Since joining ServiceNow in 2010 as a Technical Consultant, he has done many large scale ITSM implementations and custom applications, acted as an adjunct instructor for Education Services, created and lead the Technical Best Practices program, and co-hosts the ServiceNow series "TechNow".

 

find_real_file.pngAndrew Kincaid is a Sr. Software Engineer for ServiceNow. His extensive platform knowledge extends back to 2009 as a customer, Technical Consultant, and Developer.

 


5 REPLIES 5

paramveer
Kilo Guru

Thanks chuck ! It's really helpful.



Thanks,


Param


Neeta3
Giga Contributor

There is a one Inbound action to create P2 incident in our Service Now instance. The value for User and Requested by field is fixed with one specific user. Suppose next time I want to fix those values with another user, how we can avoid hard coding in this?

Chuck Tomasi
ServiceNow Employee
ServiceNow Employee

Create a system property of your choosing, like "my.email.user" and give it a sys ID of the user you want.

 

In your inbound script, retrieve the value like this:

 

var userID = gs.getProperty('my.email.user');

 

Option 2: Use the user display value so the property is more readable than a sys_id. ex: "Chuck Tomasi", then in your email script, set the value of requested_by like this:

 

current.requested_by.setDisplayValue(gs.getProperty('my.email.user'));

 

gs.getProperty() is going return "Chuck Tomasi" and setDisplayValue() is going to turn it in to a sys_id which gets stored in requested_by.

 

The catch is - you need all display values to be unique! If you have John Smiths, you may not get the right person. I don't suspect that will happen here since you are in control of the incoming email user.

Hi Chuk,

 

Thanks for the reply.. It's really helpful.