how to create a link on record producer which will redirect to user table

Raviteja K
Tera Expert

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.  

1 ACCEPTED SOLUTION

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


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Ankur Bawiskar
Tera Patron
Tera Patron

HI Raviteja,



Create a macro type of variable on the record producer.


In the ui macro you can add anchor tag in html and redirect to new url based on some condition.



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


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

thank you for your response. please elaborate?


Hi Raviteja,



One quick thing:


1) If the user is logged in the instance and has opened the record producer then it is but obvious that user is present in the instance right so I didn't get "If user details is not available in that table new tab will redirect to new record"



Can you explain in more detail the highlighted part.



Apart from the above question


Following is the UI Macro which will show link which takes the user to user record of logged in user:


As of now I am showing 2 links one will take to new record and other will take to the logged in user's record



<?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 loggedInUser = gs.getUserID();


loggedInUser;


</g:evaluate>



<body>


<a id="newRecord" href="/sys_user.do?sys_id=-1" target="_blank">Click Here</a>


<a id="oldRecord" href="/sys_user.do?sys_id=${jvar_sysId}" target="_blank">Click Here</a>


</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


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

that is new customized user table, not base sys_user table. That new table is created for internal purpose. All the user records are not yet available in that table.