- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 01:16 AM
Hi all
I need to create a link on record producer which will open an new tab and redirect to customised user table with logged in user details. If user details is not available in that table new tab will redirect to new record. How this can be achieved.
Please help. Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 05:36 AM
Hi Raviteja,
Ok so you want to search whether the logged in user is present in that new table or not. So here is modified script:
So what it will do is it will search whether that user is present or not and accordingly it will show anchor tag based on that.
I am redirecting the user to custom table record as per my assumption. In my earlier post I had redirected to sys_user
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_sysId" object="true">
var userSysId = '';
var gr = new GlideRecord('customTable'); // add your custom table name here
gr.addQuery('columnName', gs.getUserID()); // add column name of your custom table here to compare with logged in user sys_id
gr.query();
if(gr.next()){
userSysId = gr.sys_id;
}
userSysId;
</g:evaluate>
<body>
<j:if test="${jvar_sysId == ''}">
<a id="newRecord" href="/<customTableName>.do?sys_id=-1" target="_blank">Click Here for new record</a>
</j:if>
<j:if test="${jvar_sysId != ''}">
<a id="oldRecord" href="/<customTableName>.do?sys_id=${jvar_sysId}" target="_blank">Click Here for old record</a>
</j:if>
</body>
</j:jelly>
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 05:36 AM
Hi Raviteja,
Ok so you want to search whether the logged in user is present in that new table or not. So here is modified script:
So what it will do is it will search whether that user is present or not and accordingly it will show anchor tag based on that.
I am redirecting the user to custom table record as per my assumption. In my earlier post I had redirected to sys_user
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_sysId" object="true">
var userSysId = '';
var gr = new GlideRecord('customTable'); // add your custom table name here
gr.addQuery('columnName', gs.getUserID()); // add column name of your custom table here to compare with logged in user sys_id
gr.query();
if(gr.next()){
userSysId = gr.sys_id;
}
userSysId;
</g:evaluate>
<body>
<j:if test="${jvar_sysId == ''}">
<a id="newRecord" href="/<customTableName>.do?sys_id=-1" target="_blank">Click Here for new record</a>
</j:if>
<j:if test="${jvar_sysId != ''}">
<a id="oldRecord" href="/<customTableName>.do?sys_id=${jvar_sysId}" target="_blank">Click Here for old record</a>
</j:if>
</body>
</j:jelly>
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 05:46 AM
thank you so much
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 03:27 AM
Hi Ankur,
This code is working like a charm. But issue here is when we update the user details after clicking the link "Click Here for old record" it is redirecting to itil homepage. Here I need to redirect to same record from where this link has been clicked.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 03:31 AM
Hi Raviteja,
I think that would be difficult. Not sure whether this would work or not and not tried as well.
Send the current record sys_id to that page in the url as parameter. in onSubmit script fetch the url parameter value and redirect to that page once form submits.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 04:03 AM
sample code please?