We are using SharePoint online. would like to set a variable with user's ID.
The login name of the current user is returned as i:0#.f|membership|yourEmailadress
.
Is there any way we can get the user id?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityWe are using SharePoint online. would like to set a variable with user's ID.
The login name of the current user is returned as i:0#.f|membership|yourEmailadress
.
Is there any way we can get the user id?
I'm not sure if the ID is available in the same way in SPO as it is in on-prem, but logically I would use this approach:
Have a script running on a PC somewhere that periodically (once a day should be enough) grabs a list of all users in the tenant - it's also a good idea when using a list like this to have it delete all the existing entries to avoid duplicates
Script uploads the Claims-Based Auth username form and associated user ID to a list in SPO for each user it finds
Workflow gets the ID by selecting the item from the list where it finds a match on the Claims-Based Auth username form
In Javascript:
var userID = _spPageContextInfo.userId;
Update for workflows:
In workflows User profiles is available as a data source. Pick user profiles, ID and then match the list item so that Account name equals 'Created by' (as string)