Checking logged in user in server script in widget

-Andrew-
Kilo Sage

Hi guys.

I'm trying to get the current logged in user in an if statement within the server script of my widget, i've tried the below and other ways but i'm stumped:

data.user = gs.getUserID();

	if(record.requester == data.user){
		data.showMyDelegated = true;
	}

//Have also tried:

	if(record.requester == gs.getUserID()){
		data.showMyDelegated = true;
	}
12 REPLIES 12

yes so do one thing replace 

record.requester = gr.getDisplayValue('caller_id');

this above line to below line 

record.requester = gr.getValue('caller_id'); // this returns sys_id

You need to compare with sys_id as gs.getUSERID() GETS SYS_ID 

NOW DO THE COMPARISON AFTER REPLACING

data.user = gs.getUserID();
		if(record.requester == data.user){
			data.showMyDelegated = true;
	}

please mark my answer correct if it helps you

 

 

 

Thanks - this is setting the data.showMyDelegated to true each time.

 

for example i have two records showing in the list, I am the the caller for one and someone else is for another - this is where i was getting stuck

Hi ,

Have you declared and assign false value at start like below

data.showMyDelegated = false; // this will help to check false condition

Thanks,

Valmik

okay then do like this first declare it to false and then mark it true according to your condition

data.showMyDelegated =false;
data.user = gs.getUserID();
		if(record.requester == data.user){
			data.showMyDelegated = true;
	}
else{
data.showMyDelegated =false;
}

With this you can use the false condition too

 

 

hello did this help or any follow up required ?

if it worked you can close the thread by marking the correct which will push this question to solved queue