Showing posts with label SharePoint2007. Show all posts
Showing posts with label SharePoint2007. Show all posts

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, March 24, 2011

The Web application at http://sp2010:12523 could not be found. Verify


Unhandled Exception: System.IO.FileNotFoundException: The Web application at http://sp2010:12523 could not be found. Verify

that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.


private void button1_Click(object sender, EventArgs e)
{
using (SPSite site = new SPSite("http://sp2010:12523"))
{
using (SPWeb web = site.OpenWeb())
{
SPListCollection lstColl = web.Lists;
}
}
}


Workaround


When you create a new application, it defaults to x86. However sharepoint 2010 is a 64 bit application.


To resolve the issue, View your project properties, go to the Build tab and change the platform target to x64. Run your application again and everything should work as expected now.