July 28, 2016

Add Listview webpart from one site to any other site within Site collection in SharePoint.

Introduction: 
To display content from any SharePoint List/Library in Site Page or Publishing Page within same site, we can use List View web part but has one limitation: both Site Page where web part will be added and SharePoint List must be on same site. What if, there is requirement to have List view web part to display content of SharePoint List to another site, is it possible?

Here is the solution to display data from SharePoint list as List View web part from the site to its parent site within same site collection.

Approach/Solution:
  1. Open SharePoint site in Microsoft SharePoint Designer 2010 where your document library/list exists.
  2. Click on "Lists and Libraries" sections.
  3. Open your document library.
  4. Select "All Documents" view from "Views" section.
  5. Select your document library list view web part in design mode.

  6. Select "Web Part" tab in Ribbon.
  7. Click on "To Site Gallery" in "Save Web Part" group.
  8. Give appropriate name and description to web part and press "ok".
  9. Now your document library is added as web part in web part gallery. 
  10. You can add this document library web part to parent site or any other site within same site collection by adding it as list view web part on page.
  11. Web part will be available under "Miscellaneous" web parts category.
If you have any questions you can reach out our SharePoint Consulting team here.

July 8, 2016

Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation when deploying solution with workflow

Problem:
I created the Workflow in SharePoint Designer 2013 and used "Save As Template" to export a workflow as WSP solution file into Site Assets library.  And then took the WSP file and deployed it to target environment.  However, when the workflow was updated, the "Feature" that enables/publishes the workflow was not activated in the target environment as previously. It was giving following exception: 

“Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors:
Failed to create a 'ListId' from the text '$ListId:Lists/configuration;'. HTTP headers received from the server - ActivityId: 4b8fd97c-7c0f-4b12-8038-247a513a3f00. NodeId: . Scope: . Client ActivityId : 6768869d-f0de-3000-2122-c09145073f7d. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at Microsoft.Workflow.Common.AsyncResult.End[TAsyncRe……..”

Findings:
The "Elements.xml" file, which is packaged within the "WSP" solution file contains 2 different "<File>" elements. One <File> element represents the XAML file, and the other represents the Workflow association file. Comparing the Elements.xml file from a working solution file with the one which gives the specified error, I noticed that "WSPublishState" property value was different.  In the working solution file, WSPublishState value for each "<File>" element was "3" while in the failing version it was "1".

<PropertyName="WSPublishState" Value="3"/>

<PropertyName="WSPublishState" Value="1"/>
Note: WSPublishState property is also added within the "MetaInfo" tag in same file, so both occurrences should be updated.

Therefore, when the workflow files were published, due to different states it was corrupting the deployment process.

Resolution:
To resolve, please follow below steps:
1. Open WSP package using Project ->New Project -> ‘Import solution package’ from VS 2012/2013.
2. When solution is opened in VS 2012/2013, update the Elements.xml file.
3. Update the WSPublishState value for both "File" elements so they match. 

·       Note: Make sure you also update WSPublishState property within the ‘MetaInfo’ element if they differ. The actual value may matter (has not been tested); but if the values are both changed to "3" (to match the working version), then it works. Then again package the solution to create new WSP file, which will now deploy correctly.

The value of the WSPublishState corresponds to the 
Microsoft.SharePoint.WorkflowServices.StoragePublishState enumeration (viewed using Reflector):

internal enum StoragePublishState

{

    Unchanged,

    Unpublished,


    Published,


}

If you have any questions you can reach out our SharePoint Consulting team here.

July 6, 2016

Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors: Failed to create a 'ListId' from the text

Problem:

I have created a Designer workflow for SharePoint 2013 List in development site and moved it to production environment. In Production environment, when I tried to activate the feature related to my custom workflow after uploading and activating the workflow package into the Solution Gallery, I encountered the error:

Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors: Failed to create a 'ListId' from the text....

Cause:
I forgot to create one dependency List related to workflow solution in Production environment and tried to activate feature. Because of this, I encountered the above error.

To Solve this, I have created the dependency list and tried to activate the feature again, even this time I encountered the same error.

Resolution:
Because of the workflow instance that has already been created during the first erroneous deployment process, We need to delete that workflow instance through SharePoint designer and then re-activating the feature. This has solved my problem and workflow has been created successfully.


If you have any questions you can reach out our SharePoint Consulting team here.