Joseph Michael Pesch
VP Programming

Sharepoint Get User Information from within Workflow/Application Page

by 27. May 2011 14:39

// Workflow member variable declarations...
public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();

private void SomeMethod()
{
  // This method failed: SPList userList = SPContext.Current.Web.SiteUserInfoList;
  SPList userList = workflowProperties.Site.RootWeb.SiteUserInfoList;
  SPUser user = SPContext.Current.Web.EnsureUser(@"domain\userid");
  SPListItem userItem = userList.Items.GetItemById(user.ID);
  foreach(SPField fld in userItem.Fields) 
  {
    System.Diagnostics.Debug.WriteLine(string.Format("{0} >>> {1}", fld.Title, fld.InternalName)); 
  }
}

OUTPUT FROM MY SAMPLE TEST:
ID >>> ID
Content Type ID >>> ContentTypeId
Content Type >>> ContentType
Name >>> Title
Modified >>> Modified
Created >>> Created
Created By >>> Author
Modified By >>> Editor
Has Copy Destinations >>> _HasCopyDestinations
Copy Source >>> _CopySource
owshiddenversion >>> owshiddenversion
Workflow Version >>> WorkflowVersion
UI Version >>> _UIVersion
Version >>> _UIVersionString
Attachments >>> Attachments
Approval Status >>> _ModerationStatus
Approver Comments >>> _ModerationComments
Edit >>> Edit
Name >>> LinkTitleNoMenu
Title >>> LinkTitle
Title >>> LinkTitle2
Select >>> SelectTitle
Instance ID >>> InstanceID
Order >>> Order
GUID >>> GUID
Workflow Instance ID >>> WorkflowInstanceID
URL Path >>> FileRef
Path >>> FileDirRef
Modified >>> Last_x0020_Modified
Created >>> Created_x0020_Date
Item Type >>> FSObjType
Sort Type >>> SortBehavior
Effective Permissions Mask >>> PermMask
Name >>> FileLeafRef
Unique Id >>> UniqueId
Client Id >>> SyncClientId
ProgId >>> ProgId
ScopeId >>> ScopeId
File Type >>> File_x0020_Type
HTML File Type >>> HTML_x0020_File_x0020_Type
Edit Menu Table Start >>> _EditMenuTableStart
Edit Menu Table Start >>> _EditMenuTableStart2
Edit Menu Table End >>> _EditMenuTableEnd
Name >>> LinkFilenameNoMenu
Name >>> LinkFilename
Name >>> LinkFilename2
Type >>> DocIcon
Server Relative URL >>> ServerUrl
Encoded Absolute URL >>> EncodedAbsUrl
File Name >>> BaseName
Property Bag >>> MetaInfo
Level >>> _Level
Is Current Version >>> _IsCurrentVersion
Item Child Count >>> ItemChildCount
Folder Child Count >>> FolderChildCount
Account >>> Name
E-Mail >>> EMail
Mobile Number >>> MobilePhone
About Me >>> Notes
SIP Address >>> SipAddress
Locale >>> Locale
Calendar Type >>> CalendarType
AdjustHijriDays >>> AdjustHijriDays
TimeZone >>> TimeZone
Time Format >>> Time24
Alternate Calendar Type >>> AltCalendarType
CalendarView Options >>> CalendarViewOptions
WorkDays >>> WorkDays
WorkDay StartHour >>> WorkDayStartHour
WorkDay EndHour >>> WorkDayEndHour
Is Site Admin >>> IsSiteAdmin
Deleted >>> Deleted
Picture >>> Picture
Department >>> Department
Job Title >>> JobTitle
Is Active >>> IsActive
Group >>> GroupLink
Edit >>> GroupEdit
Name >>> ImnName
Picture >>> PictureDisp
Name >>> NameWithPicture
Name >>> NameWithPictureAndDetails
Edit >>> EditUser
Selection Checkbox >>> UserSelection
Content Type >>> ContentTypeDisp
 
 

Tags:

C# | Sharepoint

Comments are closed