logo

NJP

🧠 Concepts to Improve Your ServiceNow Dev Skill 🧠

New article articles in ServiceNow Community · Mar 27, 2025 · article

After 20some years in tech, I am officially & unexpectedly a "real dev". Here are some concepts I either learned or learned more thoroughly in my first 90 days.

✍️ GET A CLUE (Comment Like Users Exist) ✍️

- Learn JSDoc. Yes "real devs" argue about this. Yes I'll catch🔥for suggesting it... but its 💯% better than what 90% of us were taught.

- This video is a great introduction to JSDoc

/* AN EXAMPLE OF JSDOC USAGE FOR A FUNCTION WITHIN A SCRIPT INCLUDE */ /** * Constrcuts an anchor tagged URL * @param {GlideRecord} recordGR - GlideRecord of the record we want to link to. Use this to get the table name and sys_id. * @param {string} text - anchor text for URL * @returns - a clickable hyperlink with URL embedded in the text parameter. */ _buildLink: function(recordGR, text) { var table = recordGR.getTableName(); var baseURL = gs.getProperty('glide.servlet.uri') + table + ".do?sys_id=" + recordGR.sys_id; var textEmbeddedURL = '' + text + ''; return textEmbeddedURL; }

😕 THINK FAB (Front And Back) 😕

Team: "What if someone changes that to something unexpected?"

Me: "They can't, the client won't let them."

Team: "But what if it changes from the server side?"

- Learn how to harden things from both client and server side. If a human can do it, so can a script. If a human can't do it, a script still can. Assume it can happen.

👂MESSAGES SHOULDN'T BE HARD (Hardcoded And Really Dumb) 👂

- You either work on a multi-language instance or WILL at some point.

- Even if you don't leverage multi-language, making a separate sys_ui_message record de-risks future development. Now if you need to change the message, you aren't changing the code that fires it!

- sys_ui_message / gs.getMessage() allow message translation into other languages. sys_ui_message stores the language versions. getMessage figures out which one to use.

- Learn to parameterize your messages: "{0} was closed by {1}" can be called with gs.getMessage("messageKey", [inc.number, inc.closed_by]);

/* TRY IT YOURSELF! - Create a sys_ui_message called "myFirstMessage". Use whatever language is local to you. - Make hte message body "{0} is priority {1}" - Run the following code in Background scripts - How many parameters can you have? I tried one with 20, so PLENTY! */ var incGR = new GlideRecord('incident'); incGR.setLimit(1); incGR.query(); while (incGR.next()){ gs.info(gs.getMessage("myFirstMessage", [incGR.number, incGR.priority])); }

💩 CRAP! - CATASTROPHIC RESULTS *ALWAYS* POSSIBLE 💩

Them: "But what happens if this doesn't return anything?"
Me: "It should return something."
Them: "But what if it doesn't?"

- Learn how to use try/catch to either keep processing gracefully, OR send important messages to troubleshooters.

- A truly excellent article article demonstrating this by @Trey Carroll

🧠 DON'T BE LAME (Logic And Methods Everywhere)

- 2x true for those maximizing Flow Designer / Playbooks. Sometimes you NEED code. Think about *where* best to execute it.

- Learn to use Script Includes and treat them like function libraries. "My flow needs code to generate a complex work_note" -> Put that logic in a Script Include function and call it from flow.

- Every function you desire, imagine how it might be re-used.

WANT MORE HELP BUILDING ON SERVICENOW?

▶️ Robert "The Duke" Fedoruk on YouTube

🎙️ CJ & The Duke podcast

View original source

https://www.servicenow.com/community/developer-blog/concepts-to-improve-your-servicenow-dev-skill/ba-p/3220009