How do I output something from the "gs" variable?

arnabbose
Tera Expert

How do I output something from the "gs" variable?   For example, I want to see "gs.getRoles()"   - how do I output this?  

I tried:

${gs.getRoles()} - but this didn't work.

Just want to output something onto the webpage.

PLEASE SUGGEST

4 REPLIES 4

Anurag Tripathi
Mega Patron
Mega Patron

depends on where are you using it.



gs.log(gs.getRoles());


gs.addInfoMessage(gs.getRoles());


gs.print(gs.getRoles());


-Anurag

Also, given a sys_id, how do I get the name/title of the object and output it?   I'm guessing I need to know the table or type?   Or can is there some general method that I can use?


Something like:


name = object.get(sys_id); ?



Think it would be object.sys_id; wherein the object should be a glide object. Is that Correct ???


there is a script that takes in sys_id and responds with the object, HI people shared once but that is ver much against the system performance.



If you know what object's sys_id you have then the following works easily


suppose you know the object is an incident record


var gr=new GlideRecord('incident'); //glidereocrd to that table


gr.get('pass your sys_id here as a string');


gr is the object you need


-Anurag

syedfarhan
Kilo Sage

Hi Arnab,



Try something like this


var ourUser = gs.getUser();


gs. ­print( ­ourUser. ­getFirstName()); //should print out the first name of the user you are currently logged in as


ourUser = ourUser. ­getUserByID( ­'abel.tuter'); //fetched a different user, using the user_name field or sys_id on the target user record.


gs. ­print( ­ourUser. ­getFirstName()); //this should be the first name of the user you fetched above


gs. ­print( ­ourUser. ­isMemberOf( ­'Capacity Mgmt'));



In your case


Example:


gs.info(gs.getSession().getRoles());


Output:


admin,hr_fulfiller,itsa_fulfiller,security_admin



Thanks