Skip to main content

Posts

Showing posts from May, 2011

Cancel the Workflow Through Object Model

 SPSecurity.RunWithElevatedPrivileges(delegate()                 {                     using (SPSite osite = new SPSite(SPContext.Current.Site.ID))                     {                         using (SPWeb oweb = osite.OpenWeb(SPContext.Current.Web.ID))                         {                                                         SPList oList= oweb.Lists["List Name"];            SPListItem olstitem = oTravelRequestList.GetItemById(133);                             SPWorkf...

How to Hide InfoPath Control Programmatically c#

To hide the InfoPath control we can simply create a variable and format the control accordingly. If you want to hide the control programmatically, set the variable value. then InfoPath will render the control accordingly. XPathNodeIterator NodeIterator = nav.Select("/my:myFields/my:MainSection/my:BidDocument", NamespaceManager); nav.SelectSingleNode("/my:myFields/my:isPicVisible",NamespaceManager).SetValue("True"); Above code will display the control. Following code will hide the control nav.SelectSingleNode("/my:myFields/my:isPicVisible", NamespaceManager).SetValue("False");

Programmatically Setting Taxonomy Field Values

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.taxonomy.taxonomyfield.aspx static void Main(string[] args) {     var url = ConfigurationManager.AppSettings["Url"].ToString();     var library = ConfigurationManager.AppSettings["Library"].ToString();     // Reads XML, considering     // (key => lookup field,value => taxonomy field)     Dictionary<string, string> mappingFields = XMLHelper.ReadDictionaryXML("MappingFields.xml");     using (SPSite site = new SPSite(url))     {         using (SPWeb web = site.RootWeb)         {             // Gets the list/library             SPList list = web.Lists[library];             foreach (SPListItem item in list.Items)             {             ...

In a meeting workspace get all agenda items from a list programmatically.

using Microsoft . SharePoint . Meetings ; Sample code: using ( SPSite site = new SPSite (< enter your workspace url >)) using ( SPWeb web = site . OpenWeb ()) {     SPMeeting meeting = SPMeeting . GetMeetingInformation ( web );     SPQuery query = new SPQuery ();     query . MeetingInstanceId = ( int ) SPMeeting . SpecialInstance . AllButSeries ;     query . Query = @ "<Query>                        <Where>                           <IsNotNull>                              <FieldRef Name='ID' />                           </IsNotNull>                        </Where...

Export a SharePoint Designer workflow to Visual Studio in SharePoint 2010

Common situation when designing workflow is that you start to design workflow in SharePoint Designer and then you want to add some code in Visual Studio. In the following example, I will go through the procedure to create a workflow in SharePoint Designer and then open it and deploy it from Visual Studio. Let’s start by creating a reusable workflow in SharePoint Designer Enter the workflow information and then just implement one step to set the document status to approve: Next, in order to be able to reuse it in all the sites from site collection in SharePoint, publish the workflow globally: Save the workflow and then Save it as a template : You should see the confirmation : Now, if you go to the Site Library, you will see this: Save the .wsp localy and then, open Visual Studio and choose to import a workflow: You can deploy it as a sandbox: and select your .wsp and all the elements included in the .wsp: Wait for importation to be completed: Then deploy the sol...