Google+ Tools
Make Google+ profile picture
Make Google plus banners for profile
Create and share your Google Plus profile banners.

Profile image for mrk studios Bin Ku on February 15, 2011
Get current user in workflow sharepoint context
Language
C#
Tags

Get current user in workflow sharepoint context


/// <summary>
        /// Get current user in workflow sharepoint context
        /// </summary>
        /// <param name="workflowProperties"></param>
        /// <returns></returns>
        public static SPUser GetCurrentUserInWorkflow(Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties)
        {
            string ModifiedbyUserName = Convert.ToString(workflowProperties.Item.GetFormattedValue("Modified By"));
            string[] strChar = { "ID=" };

            string[] strChars = ModifiedbyUserName.Split(strChar, StringSplitOptions.None);

            Int32 iUserID = Convert.ToInt32(strChars[1].Substring(0, strChars[1].IndexOf("\"")));
            
            SPUserCollection usersInSite = workflowProperties.Web.SiteUsers;
            int countUsers = usersInSite.Count;
            for (int iCnt = 0; iCnt <= countUsers - 1; iCnt++)
            {
                if (usersInSite[iCnt].ID == iUserID)
                {
                    return workflowProperties.Web.SiteUsers[iCnt];                    
                }
            }
            return null;
        }

Comments

blog comments powered by Disqus