How to get currently logged-in user in workflow

Posted On // Leave a Comment
        /// <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;
        }
Refer from http://www.sharepointkings.com/2008/08/how-to-get-currently-logged-in-user-in.html
[Read more]

Screenshot Pemission in Sharepoint 2007

Posted On // Leave a Comment
Maybe these screenshot could make you easy understand permission in Sharpoint 2007
Figure - 01: Permission level
permission Sharepoint
Figure - 01
Figure – 02: Built-in permission Sharepoint
built-in permission Sharepoint
Figure - 02
[Read more]

Microsoft.SharePoint.SPFieldUserValueCollection is not marked as serializable

Posted On // Leave a Comment

Problem:
Develop on SharePoint Workflow
Unexpected    System.Workflow.Runtime.Hosting.PersistenceException: Type 'Microsoft.SharePoint.SPFieldUserValueCollection' in Assembly 'Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' is not marked as serializable.
Snippet code causes error:
public sealed partial class YourWorkflow : SharePointSequentialWorkflowActivity
    {
        SPFieldUserValueCollection _reviewers;
Resolve:
Check fields in your custom activity or workflow, if it has field type Microsoft.SharePoint.SPFieldUserValueCollection, just remove it or use it as variable method.
[Read more]

HRESULT 0x80040E14 When Calling SPListItem.Update

Posted On // Leave a Comment
Problem:
This is snippet code causes error HRESULT 0x80040E14 when calling SPListItem.Update method
SPList docApprovalList = _web.Lists[List.DocumentApprovalList];
SPListItem itemUpdate = docApprovalList.GetItemById(documentApprovalListObj.Id);
//itemUpdate[SPBuiltInFieldId._Identifier] = documentApprovalListObj.Id;
itemUpdate["ID"] = documentApprovalListObj.Id;
itemUpdate["Status"] = documentApprovalListObj.Status;
itemUpdate.Update();
documentApprovalListObj is my business object which has an attribute Id is a SharePoint List Field ID {1d22ea11-1e32-424e-89ab-9fedbadb6ce1}
Solve:
DO NOT change or re-assign value of field ID of list item
[Read more]

How to create a User field that can contain more than one value

Posted On // Leave a Comment
<Field ID="{44DB06B2-DC96-4dd7-AA6A-1A82AE906179}"
         Type="UserMulti"
         Name="Groups"
         DisplayName="Groups"
         ShowInEditForm="FALSE"
         Mult = "TRUE"
         Group="MyGruoup"/>
There are 2 notes:
  • Type="UserMulti"
  • Mult = "TRUE" - Upper TRUE!
[Read more]

Restart attempt failed. iisreset /noforce

Posted On // Leave a Comment

Problem:

 
Attempting stop...
Restart attempt failed.
The service did not respond to the start or control request in a timely fashion.
(2147943453, 8007041d)

Restart attemp failed.

Solution:

  • Run services.msc
  • Start World Wide Web Publishing Service service

image

[Read more]

[ASP.NET] How to insert dynamically CSS to Web User Control

Posted On // Leave a Comment
        /// 

        /// Override user control's method OnInit

        /// 

        /// Event arg object
        protected override void OnInit(EventArgs e)

        {

            /*base.OnInit(e);*/

            ////Define an HtmlLink control.

            HtmlLink myHtmlLink = new HtmlLink();

            myHtmlLink.Href = UrlFlexgridCss;

            myHtmlLink.Attributes.Add("rel", "stylesheet");

            myHtmlLink.Attributes.Add("type", "text/css");


            ////Add the HtmlLink to the Head section of the page.

            Page.Header.Controls.Add(myHtmlLink);

        }
[Read more]