Thursday, March 27, 2008

Working on Dev Machine And Not Installed with SharePoint (Workaround for Workstation Development!)

Copy few DLL's and register them and you all set for MOSS Workflow devlopment.
  1. Copy all the server DLL’s from this location “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI” to Dev Machine Maintain the same file structure.
  2. Then GAC these DLL’s (Drag N Drop into “C:\WINDOWS\assembly”)
    a. Microsoft.SharePoint.dll
    b. Microsoft.SharePoint.Security.dll
    c. Microsoft.Sharepoint.WorkflowActions.dll
    d. Microsoft.Office.Workflow.Tasks.dll
  3. Copy "microsoft.sharepoint.WorkflowActions.intl.dll" from Server by navigating through
    C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.WorkflowActions.intl\12.0.0.0__71e9bce111e9429c
    COPY microsoft.sharepoint.WorkflowActions.intl.dll to Dev Machine
    3.a Now GAC the above DLL into your Dev Machine.
  4. Copy " microsoft.SharePoint.workflowactions.intl.resources.dll" from Server by navigating through C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.WorkflowActions.intl.resources\12.0.0.0__71e9bce111e9429c
    COPY microsoft.SharePoint.workflowactions.intl.resources.dll to Dev Machine
    4.a Now GAC the above DLL into your Dev Machine
  5. Copy "microsoft.sharepoint.library.dll" from Server by navigating through C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Library\12.0.0.0__71e9bce111e9429c
    COPY microsoft.sharepoint.library.dll to Dev Machine
    5.a Now GAC the above DLL into your Dev Machine.
  6. Install Visual Studio 2005 Extensions for Windows Workflow Foundation (EN)
  7. If you wish you can also install “Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System_Setup"

Now you all set for developing SharePoint Workflows!

Tuesday, March 18, 2008

Assigned item level permission (Moss 2007)

Currently working on a new project which requires WF auto assign the permission at document level once this document finish with all the Approvals.

Console App sample Code for you to test:

static void Main(string[] args)
{
string strResult = "";
string strFileID = "1";
try
{
SPSite WebApp = new SPSite("http://security/");
SPWeb Site = WebApp.OpenWeb();
SPList list = Site.Lists["Documents for Review"];
SPQuery newSPQuery = new SPQuery();
newSPQuery.Query = "" + strFileID + "";

SPListItemCollection listItemCol = list.GetItems(newSPQuery);
if (listItemCol.Count > 0)
{
foreach (SPListItem item in listItemCol)
{
SPRoleDefinition RoleDefinition = Site.RoleDefinitions.GetByType(SPRoleType.Reader);
SPRoleAssignment RoleAssignment = new SPRoleAssignment("us\\MOSSUser, "rajasudhakar@shotmail.com", "Raja Dandu", "Test via Code notes");
RoleAssignment.RoleDefinitionBindings.Add(RoleDefinition);

if (!item.HasUniqueRoleAssignments)
{
item.BreakRoleInheritance(true);
}
item.RoleAssignments.Add(RoleAssignment);
item.Update();
}
}
}
catch (Exception ex)
{
strResult += "Permission not set, reason: " + ex.Message;
}


Related links:
http://msdn2.microsoft.com/en-us/library/ms414036.aspx
http://msdn2.microsoft.com/en-us/library/ms414400.aspx
http://office.microsoft.com/en-us/sharepointtechnology/CH100649861033.aspx