The Now Platform® Washington DC release is live. Watch now!
Yesterday I introduced the evaluate tag, but didn't really say much about it. This post (and one or two more) we're going to spend some time understanding just what the heck that tag does.
My young friend Whazzup (at right) is intensely interested in this, but I think I detect a little skepticism there. "So what if I can evaluate a script?" he asks. "What good is that gonna do me?"
Well, Wazzup, it's like this: the evaluate tag is one of the wonders of the ServiceNow Jelly world, and it can do a lot for you...
Let's start with yesterday's example:
<?xml version="1.0" encoding="utf-8"?>
<j:jelly>
<g:evaluate>
var colors = ['Red', 'Black', 'Blue', 'Brown', 'CadetBlue', 'DarkGreen', 'DeepPink'];
</g:evaluate>
<j:foreach>
Color: $[SP] ${jvar_color}
</j:foreach>
</j:jelly>
<?xml version="1.0" encoding="utf-8"?>
<j:jelly>
<g:evaluate>
var user = gs.getUser();
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('user', user.getID());
gr.query();
var roleIDs = [];
while (gr.next())
roleIDs.push('' + gr.role);
gr = new GlideRecord('sys_user_role');
gr.addQuery('sys_id', roleIDs);
gr.query();
</g:evaluate>
Hello, ${user.getFirstName()} ${user.getLastName()}
Your user ID is: ${user.getID()}
You have these roles:
<j:while>
${gr.name}
</j:while>
</j:jelly>
Hello, Completely Loony
Your user ID is: 0e8085600a0005896f731eba56151fe4
You have these roles:
itil_admin
knowledge_admin
admin
content_admin
discovery_admin
knowledge
itil
asset
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.