Checking logged in user in server script in widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 02:02 AM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 02:30 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 02:34 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 02:39 AM
Hi ,
Have you declared and assign false value at start like below
data.showMyDelegated = false; // this will help to check false condition
Thanks,
Valmik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 02:40 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2022 04:28 AM
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