Widget get user name and user id

hurm
Tera Contributor

I want get the current user name and user id ,display in the preview

plase help me 

thanks

 

find_real_file.png

1 ACCEPTED SOLUTION

Hi zhian,

If you look at the screenshot that I posted earlier the fields that are references have two correlating properties. One property displays the sys_id of the referenced record and the other one displays the display value of the record. It's indicated by the suffix of "_dv" at the end of the property name.

So to show the display value of the department it would be user.department_dv instead of user.department.

find_real_file.png

View solution in original post

21 REPLIES 21

Mohith Devatte
Tera Sage
Tera Sage

Hello @zhian ,

HTML:

 <label for="name">User Name:</label>
  <input type="text" id="name" name="name" ng-model="data.username"><br><br>
  <label for="userid">User ID:</label>
  <input type="text" id="userid" name="userid" ng-model="data.userid"><br><br>

SERVER SCRIPT :

data.username = gs.getUser().name;
data.userid = gs.getUser().user_name;

No need of client controller 

try this and let me know

mark my answer correct if it helps you

 

I want to display the currently logged in username and id

 

No create table and input user info

 

It's not easy to understand, sorry

@zhian if you just want to display the name and user ID and user name then you can use below code which is simple 

HTML:

<h6> User name:</h6>
{{data.username}}
<h6> User ID:</h6>
{{data.userid}}

Server script :

data.username = gs.getUser().name;
data.userid = gs.getUser().user_name;

 

gs.getUser().name --> this method gives name 

gs.getUser().user_name -- > this method gives ID 

if you want to access any field on the user table. you can use gs.getUser() and just append ".your_field_name" .

Hope this helps you

Displays the ID and NAME of the currently logged in user