- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2015 11:45 AM
Hi All,
I have no idea about <j2:if > tags and their syntax
I want to compare
$[gs.getUserDisplayName()]
$[sc_request.opened_by.name]
<j2:if test="$[sc_request.opened_by.name] == $[gs.getUserName()]">
//Do Something
</j2:if>
How do I compare these two strings, can any one help me?
Thanks
Uma
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2015 03:18 AM
Hi uma,
There is a mistake in your code. gs.getUserName() returns you the user ID of the current user and not the name of the current user. You should either use -
1) sc_request.opened_by.name == gs.getUserDisplayName();
2) sc_request.opened_by.user_name == gs.getUserName();
I agree with kumaran. Below is the script you can use
<g2:evaluate var="jvar_answer" jelly="true">
var answer = 'false';
var sc_request = new GlideRecord('sc_request');
.
.
sc_request.query();
if(sc_request.next()) {
if(sc_request.opened_by.name == gs.getUserDisplayName()) { //sc_request should be GlideRecord Object as shown
//Also you can use "sc_request.opened_by == gs.getUserID()"
answer = 'true';
}
}
answer;
</g2:evaluate>
<j2:if test="$[jvar_answer == 'true']">
//Do what you want to do here
</j2:if>
Please mark the response helpful/correct if it helped you.
Thanks,
Tanaji

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2015 03:18 AM
Hi uma,
There is a mistake in your code. gs.getUserName() returns you the user ID of the current user and not the name of the current user. You should either use -
1) sc_request.opened_by.name == gs.getUserDisplayName();
2) sc_request.opened_by.user_name == gs.getUserName();
I agree with kumaran. Below is the script you can use
<g2:evaluate var="jvar_answer" jelly="true">
var answer = 'false';
var sc_request = new GlideRecord('sc_request');
.
.
sc_request.query();
if(sc_request.next()) {
if(sc_request.opened_by.name == gs.getUserDisplayName()) { //sc_request should be GlideRecord Object as shown
//Also you can use "sc_request.opened_by == gs.getUserID()"
answer = 'true';
}
}
answer;
</g2:evaluate>
<j2:if test="$[jvar_answer == 'true']">
//Do what you want to do here
</j2:if>
Please mark the response helpful/correct if it helped you.
Thanks,
Tanaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2015 03:31 AM
Thank you Tanaji, it worked for me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2015 03:34 AM
You are welcome