Thursday, November 24, 2011

Get DateOnly from Caculate a Date in Ninetex workflows

Tuesday, October 11, 2011

How to start Nintex Workflow programtically

 Problem Statement: I have a SPList with Ninetex WF attached to it. The WF triggers for every item creation/updating on the list. But here I am creating/updating list items through SharePoint object model. While doing so, list items are getting updated but Ninetex WF is not triggered.
Reason: In SharePoint 2007, we cannot start the Ninetex WF using “system account” credentials (i.e. Drawback of Ninetex tool).
Below code will help you to run the Nintex workflow even with "System account" credentials also.
SPSecurity.RunWithElevatedPrivileges(delegate())
{
using (SPWeb currentweb = new SPSite(siteUrl).OpenWeb())
{
 currentweb.AllowUnsafeUpdates = true;
 SPList spList = currentweb.Lists["Custom List Name"];
 SPListItem spListItem = spList.Items.Add();
 private SPWorkflowManager wfManager;
 private SPWorkflowAssociationCollection spWorkFlows;
 // To replace the WF name globally
 string WorkflowName =ConfigurationManager.AppSettings["WorkflowName"].ToString();
 wfManager = spList.ParentWeb.Site.WorkflowManager;
 spWorkFlows = spList.WorkflowAssociations;
 foreach (SPWorkflowAssociation sendingWF in spWorkFlows)
 {
  if (sendingWF.Name == WorkflowName.Trim())
  {
    spListItem.Update();
    //To start Ninetex WF after updating Items in list
    wfManager.StartWorkflow(spListItem,sendingWF,
                            sendingWF.AssociationData, true);
    break;
  }
 }
});
Note: SPSecurity.RunWithElevatedPrivileges, it runs with the “System Account” credentials.

Monday, September 26, 2011

Code Block are not allowed in this file

Most of them got this exception if you are working on developing site pages with inline code in SharePoint. you can get the answer if you searched in search engine with in less time. But we cannot get all the answers in one place that is what I am doing here merging all the solutions at one place for quick reference.
Error: I have created site pages through SharePoint designer and added inline code inside of “Script” tag and after that if I tried to view this page I got this error “An error occurred during the processing of /Pages/Sample.aspx. Code blocks are not allowed in this file”.
Affected files: i.e. Master pages and Page layouts.

< PageParserPath>
 //To allow script code to the specific page
 < PageParserPath VirtualPath=”/Pages/Sample.aspx” CompilationMode=”Always” AllowServerSideScript=”true” />

//To allow script code to all the pages
 < PageParserPath VirtualPath=”/Pages/*” CompilationMode=”Always” AllowServerSideScript=”true” />

//To allow script code to the Master page
 < PageParserPath VirtualPath=”/_catalogs/masterpage/Sample.master” CompilationMode=”Always” AllowServerSideScript=”true” />

//To enable code blocks on folder
 < PageParserPath VirtualPath=”/TeamSite/CustomForms/” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders="true"/>
< /PageParserPath>

AllowServerSideScript, IncludeSubFolders” are self-explanatory and “CompilationMode” attribute have the following options:
·         Always – The default value, which compiles the page always
·         Auto – Page will not be compiled if possible
·         Never – The page will not be dynamically compiled 
Thanks for reading My post.

Thursday, July 21, 2011

How to validate the users in sharepoint's peoplepicker controls

Here are the steps to include SharePoint people picker control.
Step1: Add the below people picker control in your sharepoint page(.aspx)

Step2: Add the below code to validate the users and stores the user information into SharePoint list.
string PeoplePickerValue=peoplepcikerID.CommaSeparatedAccounts;
if (!string.IsNullOrEmpty(PeoplePickerValue))
   {
       SPUser User1 = null;
       User1 = spDLRWeb.AllUsers[PeoplePickerValue];
       if (User1!= null)
          {
              //To add People Picker to the list items.
              // ”Title” is Single Line of text field.
             spListItem["Title"] = User1.Name; 
             //”Manager” is People Picker Field.
             spListItem["Manager"] = User1;
           }
    }
else{ return; }
In the above code, "CommaSeparatedAccounts" will return the valid users information only otherwise it will return null value.
Note: Now,PeoplePicker validations are implemented on server side. i will update how to validate the users in people control at client side soon..

Monday, June 27, 2011

Identifying Worker Process (w3wp.exe) – IIS 6.0 and IIS 7.0 for Debugging ASP.NET Application

If you are debugging a ASP.NET web application which is hosted on IIS, you need to attach the particular worker process in Visual Studio to start debugging. To Attach a process we can go to Tools > Attach Process or use shortcut key Ctrl +P. The process window will show the worker process (w3wp.exe) which is currently running on IIS. You need to select the process and click on attach button to start the debugging.
Problem starts when you have multiple worker process running on IIS.  If you have multiple sites hosted on IIS and each site having their own application pool then you will see the list of all worker process in the Process Attach window. 

Here  you need to identify the particular worker process which is associated with your application pool. Note: Whenever we create a new Application Pool, the ID of the Application Pool is being generated and it’s registered with the HTTP.SYS (Kernel Level of IIS) . So whenever HTTP.SYS Received the request from any web application,  it checks for the Application Pool and based on the application pool it send the request 

C:\Windows\System32\inetsrv>appcmd list wp