Sharing the experience search

Search sharing-the-experience.blogspot.com
Showing posts with label SPD. Show all posts
Showing posts with label SPD. Show all posts

Wednesday, May 7, 2014

SPD WF 2013: 5 Things you wish you knew before using it #Azure #SharePoint2013

Wondering what you can get from SharePoint Workflow 2013 , which is a completely new beast?
I assumed that you have already read all WF 2013 perks that MSDN promises you.

My goal here is to give more a reality check - what you will discover while building workflow 2013 in SharePoint designer (SPD).

1. You can't access user profile. ex. to get a user's department.
You need use interop to call WF2010 that in turn accesses User Profiles list
2. Dictionary sometimes is cumbersome to use when you want to unite multiple stand-alone variables, even though MSDN uses this case to justify use of the new type - Dictionary
2.1. you can't add an item to the dictionary after the dictionary is created. all dictionary pairs should be created and assigned at the same time;
2.2. you can't retrieve dictionary key without assigning it the output variable, which clutters the variable list anyway.


3. Sometimes Workflow is failed to be open in SPD in SharePoint Online.
"Windows Workflow Foundation, part of .Net Framework 3.0, must be installed to use this feature"

To fix it:
3.1. Apply SharePoint Designer 2013 hotfix package (Spd-x-none.msp): April 8, 2014
     , spdcore2013-kb2727100
     3.2. Clear SPD Cache

4. Re-Publish workflow won't update WF version from the first time. You have to hit publish (at least in my env) twice to deliver a new WF to the site.

5. If (or rather when) your newly developed WF failed with internal status - suspended. The error is not informative even though it's verbose



Wednesday, February 29, 2012

Lesson learned: list corruption after stsadm -o import


The case:
The site is created from STP template with some data included. The additional data imported through stsadm –o import

The result:
       List corruption on the site.

The recommendation:

Don’t combine 2 approaches: STP with data and stsadm –o import.
Either go with:
-           STP with fresh data ;
-          Stsadm –o import on the blank site template.

Consideration:

 STSADM.EXE -O EXPORT:
It exports data using Object Model and generated new GUID for every object.
It doesn't copy workflow history and tasks lists. 

This means that you have some hard-coded logic in the site it will be broken after stsadm.exe export.

(for further analysis, you welcome to read my blog entry - Sharepoint: How to backup site: stsadm export and SPD backup)

P.S.
Some of the errors that you find in the import log that will wreck the havoc:


Importing File Version 1.0
Invalid file name. The file name you specified could not be used



Item does not exist. It may have been deleted by another user.
   at Microsoft.SharePoint.SPListItem.EnsureItemIsValid()

Thursday, June 9, 2011

SPD Workflow Tasks: email notification customization

[What you have]:

   You have a SharePoint Designed Workflow with action "Collect Data from a User"\"Assign a Form to a Group"\"Assign a To-do Item". The task list has email notification turned on.

[What you want]:

  You want change the default task email notification from the task list.
[What you want to know]:

WSS stores predefined alert templates under {sharepoint root\hive*}\TEMPLATE\XML
alerttemplates.xml
                * - If you use SharePoint on a daily basis, you are probably familiar with the SharePoint hive. In SharePoint 2010, the hive is called the SharePoint root.
 
    If you turn the notification on the Task list: Tasks -> Settings -> Advanced settings -> E-mail Notification; every time the task gets assigned -the email gets sent to the "Assigned to" person.
    The type of such notification is described in alerttemplates.xml:

 <AlertTemplate Type="List"  Name="SPAlertTemplateType.AssignedToNotification">
  
Here the piece where the text of the email is defined:
                        <IfSubString>
                        <Expr1>0x010801</Expr1>
                        <Expr2><GetVar Name="RawValue#ContentTypeId" /></Expr2>
                        <Then><GetVar Name="RawValue#EmailBody"/></Then>
                        <Else>

The meaning of this CAML piece is following:

   - "RawValue#" - I couldn't find any decent documentation about this value. But my experiment has shown that "RawValue" is the FieldCollection of the SPItem - "Task".

   - CAML gets the ContentTypeId of the task, check if  the content type id has a substring "0x010801"
Why "0x010801"? - There are predefined content types in SharePoint, all  custom content types are inherited from the basic one. The all basic content types are in the file {root folder\hive}\TEMPLATE\FEATURES\ctypes.xml. 
        The content type with ID 0x010801 is a workflow task.
   <ContentType ID="0x010801"
        Name="$Resources:WorkflowTask"
        Group="_Hidden"
        Hidden="TRUE"
        Description="$Resources:WorkflowTaskCTDesc"
        Version="0">
        <FieldRefs>
            <FieldRef ID="{58ddda52-c2a3-4650-9178-3bbc1f6e36da}" Name="Link" />
            <FieldRef ID="{16b6952f-3ce6-45e0-8f4e-42dac6e12441}" Name="OffsiteParticipant" />
            <FieldRef ID="{4a799ba5-f449-4796-b43e-aa5186c3c414}" Name="OffsiteParticipantReason" />
            <FieldRef ID="{18e1c6fa-ae37-4102-890a-cfb0974ef494}" Name="WorkflowOutcome" />
            <FieldRef ID="{e506d6ca-c2da-4164-b858-306f1c41c9ec}" Name="WorkflowName" />
            <FieldRef ID="{ae069f25-3ac2-4256-b9c3-15dbc15da0e0}" Name="GUID" />
            <FieldRef ID="{8d96aa48-9dff-46cf-8538-84c747ffa877}" Name="TaskType" />
            <FieldRef ID="{17ca3a22-fdfe-46eb-99b5-9646baed3f16}" Name="FormURN" />
            <FieldRef ID="{78eae64a-f5f2-49af-b416-3247b76f46a1}" Name="FormData" />
            <FieldRef ID="{8cbb9252-1035-4156-9c35-f54e9056c65a}" Name="EmailBody" />
            <FieldRef ID="{47f68c3b-8930-406f-bde2-4a8c669ee87c}" Name="HasCustomEmailBody" />
            <FieldRef ID="{cb2413f2-7de9-4afc-8587-1ca3f563f624}" Name="SendEmailNotification" />
            <FieldRef ID="{4d2444c2-0e97-476c-a2a3-e9e4a9c73009}" Name="PendingModTime" />
            <FieldRef ID="{35363960-d998-4aad-b7e8-058dfe2c669e}" Name="Completed" />
            <FieldRef ID="{1bfee788-69b7-4765-b109-d4d9c31d1ac1}" Name="WorkflowListId" />
            <FieldRef ID="{8e234c69-02b0-42d9-8046-d5f49bf0174f}" Name="WorkflowItemId" />
            <FieldRef ID="{1c5518e2-1e99-49fe-bfc6-1a8de3ba16e2}" Name="ExtendedProperties" />
        </FieldRefs>
    </ContentType>


That means the Alert "AssignedToNotification" checks if the task's content type is inherited from the workflow task. All instances of SPD WF tasks are childs of 0x010801. 
 - If the tasks has a derived workflow task content type, the email body is formed from the  field "EmailBody"  of the task list item.

 I have looked at the content of the field "EmailBody" and it looks like this:
<HTML>
  <HEAD>
    <STYLE>
TABLE.mail
{
    border-collapse:collapse; width:100%;
    font: 8pt Tahoma;
}

TD.header { background:#F8F8F9; border:1px solid #E8EAEC;              padding: 12pt 10px 20px 10px; font: 16pt Verdana}
TD.body { border-top:1px solid #E8EAEC; border-bottom:1px solid #E8EAEC; padding: 12pt 10px 24pt 10px; }
TD.footer { border-top:1px solid #E8EAEC; border-bottom:1px solid #9CA3AD; padding: 4pt 10px 4pt 10px; }
A { color:#003399; text-decoration:none; }
A:visited { color:#aa00aa; }.bodytext
{
    font: 8pt Tahoma;
    color: #000000;
}

    </STYLE>
  </HEAD>
  <BODY class=bodytext>
    <TABLE class=mail cellspacing=0 dir=ltr>
      <TR class=header>
        <TD class=header>Task assigned by SharePOint ETL User on 4/23/2010.<br></TD>
      </TR>
      <TR class=body>
        <TD class=body></TD>
      </TR>
      <TR class=footer><TD class=footer>To complete this task:<br><ol><li>Review <a href="http://webapp/sitecol/subsite1/subsite1_1/Lists/Discussion/DiscussionView.aspx?ID=380">Veronica M. Jackson</a>.</li><li>Perform the specific activities required for t
his task.</li><li><!--[if gte mso 12]>Use the <b>Edit this task</b> button to mark the task as completed. (If you cannot update this task, you might not have access to it. Click <a href="http://
/webapp/sitecol/subsite1/subsite1_1//Lists/Tasks/DispForm.aspx?I
D=379">here</a> to request access.)<![endif]--><![if !(gte mso 12)]><a href="
/webapp/sitecol/subsite1/subsite1_1//Lists/Tasks/DispForm.aspx?ID=379">Edit this task</a> to mark the task as completed.<![endif]></li></ol></TD></TR>

    </TABLE>
   
  </BODY>
</HTML>


I don't know for sure what puts the value in the "EmailBody" field. But I have a feeling that is OWSSVR.dll

[What you want to do]:

As I can see, here is 2 solutions:

1. Create a copy of alerttemplate.xml and change the CAML query there  - replace <GetVar Name="RawValue#EmailBody"/> with what you want to see in the email, and run the stsadm command:
stsadm -o updatealerttemplates -url {sitecollection url} -f {custom alerttemplate} –lcid 1033   http://technet.microsoft.com/en-us/library/dd278299%28v=office.12%29.aspx
   Consideration:The alert template is applied on the whole site collection. That means that you will change the email notification body for the whole site collection.

2. If you want to change the email body only for particular SPD WF tasks - you want to implement custom event handler on the task list .
    example:
  public override void ItemAdding(SPItemEventProperties properties)
        {
                var emailBody = properties.AfterProperties["EmailBody"];
                if(emailBody!=null)
                {
                    properties.AfterProperties["EmailBody"] = getNewEmailBody(emailBody.ToString(),properties.AfterProperties["Title"].ToString());
  
                }         
        } 

   
[What you want to consider]:
For some scenarios - you can avoid the deep diving into alert templates changing - and make use of the SPD WF action: "Send an Email".


Wednesday, April 27, 2011

Sharepoint: How to backup site: stsadm export and SPD backup

[What you have]:

A SharePoint site that needs to be backup

[What you want]:

You want to understand what tools you need to use to backup\restore one site (SPweb). What's the difference between stsadm and SharePoint Designer Backup anyway?

[What you want to know]:

Just a quick reminder:

Stsadm.exe -o backup performs a backup for entire site collection

Stsadm.exe -o export exports the site (spweb):

I will be focusing on the backuping up the site (spweb).  I will compare 2 options for site backup: SharePoint Designer (SPD) and stsadm -o export.

1. STSADM.EXE -O EXPORT
  • It can export sitecollection and webapplication as well.
  • It exports data using Object Model and generated new GUID for every object.
  • It doesn't copy workflow history and tasks lists. 
2. SharePoint Designer has an option to backup\restore the site:
This actually generates the same structure as  stsadm -o export\import

 Here is the backup made by stsadm -o export -url {url} -filename hzrdmgmt20110427.bak -versions 4 -includeusersecurity

Here is a backup made through the SharePoint Designer:


As you can see the structure is the same. The difference only in an attribute in the ExportSettings.xml:
"IncludeVersions". 

SPD can't backup a site larger than 2 Gb
If you have not installed Microsoft Office SharePoint Server 2007 with Service Pack 2 (SP2), backups that are performed by using Office SharePoint Designer are limited to 25 MB. After you install Office SharePoint Server 2007 with SP2 and Office SharePoint Designer with SP2, the limit is increased to 2 GB
                                                  Data protection and recovery for Office SharePoint Server (White paper)
                                           
SPD by default set "LastMajor" which means that the all other versions will be lost.
Using stasdm -o export allows you  specify what version backup strategy you want to employ (MSDN:Export: Stsadm)

!! Export will generate a new GUID for object. That means that you can't roll backup over the existing site. In the scenario when you need to restore the site - you have to create a new blank site and then export the backup file. (Capture and restore content by using SharePoint Designer)

[What you want to consider]:   


Additional reading:
stsadm export/import vs Backup/Restore
SharePoint Designer and STSADM Import/Export

Monday, April 25, 2011

Calendar view : how to remove the time

Probably a lots people out there know that the calendar view shows the time (12AM) for an item even  the interval column is "Date only"


I guess you, reader, want to know how to easy remove the time from the calendar view?

Here is a solution:

1. Open the calendar page with SharePoint Designer.

2. Find the following line of code:


<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

3. Add the line of style: 
<style>.ms-cal-monthitem B {display:none}</style> 
 4.  Save it.



Here is the result:
P.S. An alternative way of adding the style:
Instead of using SPD - just edit the page and place a content editor web part, add the style tag into the source editor and save it.

Monday, March 28, 2011

SPD Workflow: Custom action won't work

Yeah... The SPD WF is still in use in my project..

There are several benefits of using them:
 - easy to tailor to users' needs on the fly.
 - easy to understand by non-developers
  - can be done by non-developers.

There are (of course , as everything is in life)  minuses:
 - it's not transferable to another environment (but with extra effort-  it's possible  - explanation is here a hard-coded list id replacement )
 - it's not so flexible as a coded workflow
 - there is now way to debug it as easily as a coded workflow.

For some reason we use the SPD Workflow with custom written actions.
 Even  you are done with the step of writing the custom action. The second step - "using of the custom action" can be frustrating.
Based on my experience - the most common issue with the custom action in  the Sharepoint Designer Workflow is - it's appeared in the drop down list "Actions" , when you select  - it doesn't appear in the workflow.

That's my favorite one) - you won't find any trace of the errors in any logs.

I have found the concise and really helpful "how-to" fix the mysterious issues in the SPD WF - Common Pitfalls in SharePoint Designer Custom Actions
  • When you select a custom activity from the Actions drop-down, nothing happens
    • Usual suspect: the class name and assembly reference do not match in ACTIONS file and DLL. Please check that your class reference in the Action tag in the ACTIONS file exactly matches your DLL full name.
    • Not so usual suspect: SPD has a cached reference of your old DLL. Exit SPD, delete ApplicationData\Microsoft\WebSite Cache\ folder and restart SPD.
    • Even less usual suspect: You've correctly placed the ACTIONS file and the activity DLL, but you haven't added an authorizedType element into your web application web.config file. Add the correct entry (you can check the whole process here) and try again.
  • When you bind a property to a value, it doesn't get set
    • Usual suspect: the demoted property name in your DLL and in ACTIONS file do not match. Please check that all your properties in the code exactly match the Parameters section elements in your ACTIONS file.
 P.S. Thank you

Thursday, January 27, 2011

Module < AllUsersWebPart : how to add the xslt webpart

Can you add a dataview webpart (a  XSLT webpart)  into the solution  and make it deployable?
Yes, you can! But first you need to be aware of the following:

1. SharePoint Designer will let you convert a simple list view webpart into XSLT webpart  really easy, but it will hardcode the id of the list. It makes you xslt webpart not deployable  to any other site.

2. In case  you know how (if you don't know - I will explain further)  to resolve the first issue, you need to implement module features with file element which has a  AllUsersWebPart element. In that element you need to insert you xslt web part. !You need to insert your imported xslt webpart.

3.Sometimes it is really hard to guess what went wrong during module activation and why web part won't appear. 

Once you are aware of it, we can run straight ahead to the implementation:

1. Open your SPD, the page where you want to add your xstl web part. And start crafting it:
option "create a dataview webpart":  place your cursor inside a webpartzone and select from the main menu : Insert->SharePoint Controls ->Data View
option "convert to a dataview" : select the listview webpart which is already  - right click - select in the context menu "Convert to a XSLT Data View". Make changes that you want to make it. Save it.
Here is you go  - your xslt webpart on the page, but it's not deployable.

2. To make this webpart deployable we have to add it to the module feature. Prior to adding -we need at first import the web part. Go to the page with your webpart in the browser. Click on a  right corner arrow and select "Import".  I would prefer on this phase  to test the webpart and export it back to the page. 

Recently I have killed almost half of the day trying to figure out why the web part is broken after the module feature activation. If I had tested before,  I would have known  that's because imported webpart has a wrong value for a  property (<property name="ViewFlag" type="string"></property>. I have deleted the value.)

Ok, as soon as the webpart can easily export back, you can proceed with the module feature.
 Refer to detail explanation how to provision a file to msdn.

  Let's assume that you have managed you way out and got you a module feature with the reference to a page you want to provision and element  <AllUsersWebPart>. Let me just point it out that you have to put under this element <AllUsersWebpart> -   <![CDATA[
{exported web part content starting with  <webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">}]]>


Good deal! But it's still undeployable because the exported web part has a hard-coded value of the list Id.
Refer to out custom approach of an id replacement

Once you have handled  the id replacement, you are fearless and with deployable xslt web part on your site.

File provisioning: a hard-coded list id replacement

Howdy!
Today's topic might really help you in your SharePoint life. I will present to you a  technique to work with SPD workflow and page provisioning to make them portable from one environment to another. Not delaying any further - I will show you  real world examples with it's issue:
 Example #1. I have created SPD (SharePoint Designer ) workflow and want to export it and import to the another site created from the same site template (different enviroment: Dev, Qc, Staging).
 Issue: The exported wf holds hard-coded list id value
 Example #2. I have created a XSLT webpart and put it in a module <file> element. This feature should work on every site created from the site template to which this feature is belong to.
Issue: The xslt webpart has a hard-coded ListId.

Ok, I think it's convincing enough to read on to find a solution for described situations.
Here is our custom approach:
   We created a feature which we call SiteProvisioning. It consists of 2 elements:
1. A custom class: SiteProvisioning.cs which set as ReceiverClass for the feature:
<Feature Id="{4FA2AC90-321A-4d4c-B587-CE6D4A5B90FA}"
         Title="SiteProvisioning"
         Description=""
         Version="1.0.0.0"
         Scope="Web"
         Hidden="FALSE"
         DefaultResourceFile="core"
         ReceiverAssembly="Custom.SharePoint.Case, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a4607a0133bbaeb2"
         ReceiverClass="Custom.SharePoint.Case.SiteDefinition.SiteProvisioning"

         xmlns="http://schemas.microsoft.com/sharepoint/">
  <ActivationDependencies>
    <ActivationDependency FeatureId="43DA1A6A-0759-4093-B84D-9593555BC037"/>
  </ActivationDependencies>
( I will explain this element later)
  <ElementManifests>
    <ElementFile Location="SiteProvisioning.xml" />
  </ElementManifests>
</Feature>

2. And a file:
 <ElementManifests>
    <ElementFile Location="SiteProvisioning.xml" />
  </ElementManifests>
SiteProvisioning file is a list of elements which are originally have a hard-coded value and related list title;
<SiteSettings>
  <FixupFiles>
    <FixupFile DataViewInZone="true" DeleteWebPartsOnDeactivation="true" RelativePath="Lists/Discussion/DiscussionView.aspx" />
    <FixupFile DataViewInZone="true" DeleteOnDeactivation="true" RelativePath="default.aspx" />
    <FixupFile DataViewOutZone="true" DeleteOnDeactivation="true" RelativePath="default.aspx" />
  </FixupFiles>
  <ListInstances>
    <ListInstance Id="fd482aa7-9511-4b0f-abeb-79030bb681ca" Title="Case" />
    <ListInstance Id="85ac067e-e536-46f3-9a7b-032016cd032d" Title="Case Review Meeting" />
    <ListInstance Id="cde441a0-b34f-4f19-ba47-52b0b5c8d49e" Title="Action Items" />
    <ListInstance Id="dd764ce9-aa7a-41aa-aa2f-28841aee3356" Title="Claims" />
    <ListInstance Id="9b811048-cbd5-4e41-b526-703f1ddc3fae" Title="Disciplinary Actions" />
    <ListInstance Id="A8949622-30DB-4CE6-A6A6-B674DED51355" Title="Involved People" Web="/apps/systems/cases/" />
    <ListInstance Id="cbe513fb-ef61-45aa-9162-23398b8a4011" Title="Reports" />
    <ListInstance Id="4DF356F2-90CF-4D76-9B38-1B17F3B3D6E9" Title="Tasks" />
  </ListInstances>
</SiteSettings>

Every time we put a xslt web part in the module file, we need to be sure that we found a hard-coded value in it and added it to the SiteProvisioning also we need to put a file where we should replace this id during siteprovisioning.

The guy who will be in charge of the replacement is a  SiteProvisioning class
Here is an essence of it:

 public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            if (properties == null)
            {
                return;
            }

            SPWeb web = properties.Feature.Parent as SPWeb;         
            string filePath = this.GetProvisioinerFilePath(properties.Definition);

            var sz = new XmlSerializer(typeof(SiteSettings));
            SiteSettings settings = null;
            if (File.Exists(filePath)) {
                using (var sr = File.OpenRead(filePath)) {
                    try {
                        settings = sz.Deserialize(sr) as SiteSettings;
                    } catch { }
                }
            }

            if (settings != null) {
                this.RestoreDataViewInZone(web, settings);
                this.RestoreDataViewOutZone(web, settings);           
            }

            this.OnActivated(properties);
        }
  private void RestoreDataViewInZone(SPWeb web, SiteSettings settings)
        {
            if (settings.FixupFiles == null)
                return;

            foreach (var xFixupFile in settings.FixupFiles.Where(i => i.DataViewInZone))
            {
                var relativePath = xFixupFile.RelativePath;
                if (string.IsNullOrEmpty(relativePath))
                {
                    continue;
                }

                SPFile file = web.GetFile(relativePath);
                if (file == null)
                {
                    continue;
                }

                SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
                SPLimitedWebPartCollection pageWebParts = manager.WebParts;
                if (pageWebParts == null)
                {
                    continue;
                }

                foreach (System.Web.UI.WebControls.WebParts.WebPart webPart in pageWebParts)
                {
                    if (((webPart is DataFormWebPart) && (((DataFormWebPart)webPart).ParameterBindings != null)))
                    {
                        this.SubstituteGuidInZone(web, manager, webPart as DataFormWebPart, settings);
                        this.SubstituteIDInZone(web, manager, webPart, settings);
                    }
                    else
                    {
                        this.SubstituteIDInZone(web, manager, webPart, settings);
                    }
                }
                // http://msdn.microsoft.com/en-us/library/aa973248.aspx
                //
                //  Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager
                //  The SPLimitedWebPartManager class contains a reference to an internal SPWeb object that must be disposed.
              
                manager.Web.Dispose();
            }
        }

 private void SubstituteGuidInZone(SPWeb web, SPLimitedWebPartManager manager, DataFormWebPart dataForm, SiteSettings settings)
        {
            if (settings.ListInstances == null)
            {
                return;
            }

            foreach (var xListInstance in settings.ListInstances)
            {
                if (xListInstance.Id == null || xListInstance.Title == null) {
                    return;
                }

                SPList list = null;
                try
                {
                    if (string.IsNullOrEmpty(xListInstance.Web))
                    {
                        list = web.Lists[xListInstance.Title];
                    }
                    else
                    {
                        using (SPWeb listWeb = web.Site.OpenWeb(xListInstance.Web))
                        {
                            list = listWeb.Lists[xListInstance.Title];
                        }
                    }
                }
                catch (ArgumentException)
                {
                    continue;
                }

                if (list == null)
                {
                    continue;
                }
                string newId = list.ID.ToString();


                dataForm.ListName = newId;
                dataForm.ParameterBindings = Regex.Replace(dataForm.ParameterBindings, xListInstance.Id, newId, RegexOptions.IgnoreCase);
                dataForm.DataSourcesString = Regex.Replace(dataForm.DataSourcesString, xListInstance.Id, newId, RegexOptions.IgnoreCase);
                dataForm.Xsl = Regex.Replace(dataForm.Xsl, xListInstance.Id, newId, RegexOptions.IgnoreCase);

                manager.SaveChanges(dataForm);
            }
        }

     private void SubstituteGuidInZone(SPWeb web, SPLimitedWebPartManager manager, DataFormWebPart dataForm, SiteSettings settings)
        {
            if (settings.ListInstances == null)
            {
                return;
            }

            foreach (var xListInstance in settings.ListInstances)
            {
                if (xListInstance.Id == null || xListInstance.Title == null) {
                    return;
                }

                SPList list = null;
                try
                {
                    if (string.IsNullOrEmpty(xListInstance.Web))
                    {
                        list = web.Lists[xListInstance.Title];
                    }
                    else
                    {
                        using (SPWeb listWeb = web.Site.OpenWeb(xListInstance.Web))
                        {
                            list = listWeb.Lists[xListInstance.Title];
                        }
                    }
                }
                catch (ArgumentException)
                {
                    continue;
                }

                if (list == null)
                {
                    continue;
                }
                string newId = list.ID.ToString();


                dataForm.ListName = newId;
                dataForm.ParameterBindings = Regex.Replace(dataForm.ParameterBindings, xListInstance.Id, newId, RegexOptions.IgnoreCase);
                dataForm.DataSourcesString = Regex.Replace(dataForm.DataSourcesString, xListInstance.Id, newId, RegexOptions.IgnoreCase);
                dataForm.Xsl = Regex.Replace(dataForm.Xsl, xListInstance.Id, newId, RegexOptions.IgnoreCase);

                manager.SaveChanges(dataForm);
            }
        }

Tuesday, January 25, 2011

SPD: Site cache : how to clear?

Sometimes the site opened in the SharePoint Designer doesn't reflect up to date changes.
I have discovered it  a  long time ago when were dabbling with SharePoint Designer Workflow- the new actions didn't want to appear in the list of available.

Recently I have noticed that SharePoint Designer didn't show recently customized pages in the report of customized pages.

The reason was the  SPD caches the opened site.

The cure is easy to apply but not so easy to find!

To clear the cache - you have to go to:

        C:\Users\<username>\AppData\Local\Microsoft\WebsiteCache
        C:\Users\<username>\AppData\Roaming\Microsoft\SharePoint Designer\ProxyAssemblyCache
        C:\Users\<username>\AppData\Roaming\Microsoft\Web Server Extensions\Cache


 - and delete all folders and files there;
 - re-start SPD.


Breathe with relief)