Explanation required reg getUserByID() method

Prasanthi1
Giga Contributor

Internal Explanation required for me.

 

var newUser = gs.getUser ();

gs.print (newUser.getUserByID ('abel.tuter').getFirstName ());

 

I didnot understand this, kindly explain line by line.

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Prasanthi 

 

 gs.getUser() -since it gives you a reference to the user object for the current user, it means you are getting control access to the whole user object.

If you use below code

var newUser = gs.getUser();

gs.print (newUser.getFirstName());

since you didn't mention any specific user for whom you need first name, it will give you your firstname i.e., current logged in user first name

 

but you have choosed the user_name in getUserByID ('abel.tuter'), so within the users list, it will identify which user has this UserID -abel.tuter and gives you that user firstname.

 

Methods does not serve always one purpose , based your requirement you extend your code to use it more.

Here is another link which might be useful for you

https://sn.jace.pro/docs/glideuser/

 

Kindly mark the response correct and helpful, once your issue is resolved and close the thread for others benefit in future

 

BR,

Harika

 

View solution in original post

7 REPLIES 7

Hi @Prasanthi 

 

 gs.getUser() -since it gives you a reference to the user object for the current user, it means you are getting control access to the whole user object.

If you use below code

var newUser = gs.getUser();

gs.print (newUser.getFirstName());

since you didn't mention any specific user for whom you need first name, it will give you your firstname i.e., current logged in user first name

 

but you have choosed the user_name in getUserByID ('abel.tuter'), so within the users list, it will identify which user has this UserID -abel.tuter and gives you that user firstname.

 

Methods does not serve always one purpose , based your requirement you extend your code to use it more.

Here is another link which might be useful for you

https://sn.jace.pro/docs/glideuser/

 

Kindly mark the response correct and helpful, once your issue is resolved and close the thread for others benefit in future

 

BR,

Harika

 

Thank you for your answer and explanation. I totally understood. Thanks again

Happy to help 🙂