I want to write a workflow for SharePoint 2013 in Visual Studio. How do I know what user using (add, update or delete) an item?
And I have no columns with unique data.
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 community
First, every SharePoint list has a unique column and it's titled ID or OWS_ID.
Do you need a workflow or an event handler?
Edit. Your question is real broad and there are tons of online resources geared towards creating Visual Studio SharePoint workflows. Suggest you try one of the tutorials, then come back to this site with an exact question.
MSDN - Develop SharePoint 2013 workflows using Visual Studio: https://msdn.microsoft.com/en-us/library/office/jj163199.aspx
In Visual Studio, you can get the person who started the workflow using SPWorkflowActivationProperties Originator property.
In Designer, you can use
If you need to know the current logged in user:
SPWeb theSite = SPControl.GetContextWeb(Context); SPUser theUser = theSite.CurrentUser; string strUserName = theUser.LoginName;
If you need to know who the creator (author) of an item is:
string loginName = string.Empty; SPWeb spWeb = SPContext.Current.Web; var fullUserName = spListItem[SPBuiltInFieldId.Author] as string; var userName = fullUserName.Split('#'); SPUser spUser = spWeb.EnsureUser(userName); loginName = spUser.LoginName;