Everything began from nothing.

Showing posts with label Farm. Show all posts
Showing posts with label Farm. Show all posts

Friday, 17 February 2017

SharePoint XSN provisionning with WSP

it's not very simple to package a form xsn in the wsp solution, specialy if you want to do a provisionning.


You probably tried to use something like:
1 <elements xmlns="http://schemas.microsoft.com/sharepoint/">
2    <module name="DefaultForms" rootwebonly="FALSE" url="Lists/Forms">
3      <file path="DefaultForms\TestForm.xsn" type="GhostableInLibrary" url="TestForm.xsn"/>
4    </module>
5 </elements>

But if you just put the XSN files in a module and deploy it to a Form-library like this, or just upload the xsn file to the library, the Info Path form will not be able to render (error: form is not browser enabled).
What you have to do to fix this is adding some extra properties:
 1 <elements xmlns="http://schemas.microsoft.com/sharepoint/">
 2   <module 
 3        name="DefaultFormulieren" 
 4        rootwebonly="FALSE" 
 5        url="Lists/Forms">
 6      <file path="DefaultForms\myform.xsn" 
 7            type="GhostableInLibrary" url="TestForm.xsn">
 8        <property name="ContentTypeId"
 9                  value="XXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
10        <property name="ContentType" value="Form"/>
11        <property name="vti_contenttag" type="string" 
12                  value="{xxxxxxxxxxxxxxxxxxxxxxxxx},2,1"/>
13        <property name="ipfs_streamhash" type="string"
14                  value="u+Z+9oSpboLO+KfE7V3NmgN0DfxlgCQB0/R8/S3pVBM="/>   

15      </file>
16   </module>
17 </elements>

  • ContentTypeId and ContentType are self explaining, but how to find the vti_contenttag and ipfs_streamhash?

  1.  open the form in InfoPath-designer and publish it to a SharePoint site.
  2.  create a WSP from the existing site.


If it’s a publishing site you cannot in a normal way access the ‘save site as template’ page. So you should browse to / _layouts/savetmpl.aspx. There's no shame in doing this (or in forgetting), just remeber that it's hidden for a reason!


Make sure ‘Include content’ is selected.
Download the WSP and rename to .cab
Now you can extract this file with (for example) winrar.
Browse to the just extracted files. 

Open the Modules folder
Under 'files' you’ll find the XSN file (under a subfolder with the name of the library), I always use this file to be absolutely sure it’s exactly the same as when a user publishes the original XSN with infopath.

Go back to the root folder of your extracted WSP and open the 'propertybag' folder.
In this folder open the elements.xml. 

Find the File tag for your XSN file. (just search for .xsn).

Here you’ll find the vti_contenttag and ipfs_streamhash values. You can just add these to your module, since SharePoint itself figures out if values are fields or need to be set to the propertybag.

Friday, 10 February 2017

Activate / Deactivate Feature with PowerShell on all site collections of the webapp

Hello,


When we do some change on the solution  specially on the branding  for exmple ( display teamplate),we should update also existing sites collection and replace old files with new one after the deployment. So this powershell Script with do this on the all farm.
$feature = Get-SPFeature -Identity "ID OF THE FEATURE"
$siteCollections = Get-SPSite –WebApplication $webhubUrl -Limit ALL
$siteCollections | foreach-object {
   Write-Host "Deactivating" $feature.DisplayName "on" $_.Url -foregroundcolor yellow
   Disable-SPFeature $feature -Url $_.Url -confirm:$false

}
$siteCollections | foreach-object {
  
   Write-Host "Activating" $feature.DisplayName "on" $_.Url -foregroundcolor green
   Enable-SPFeature $feature -Url $_.Url

Tuesday, 17 January 2017

Set custom level permission SharePoint PowerShell

Hello,


Some time we need to apply a script on all the web application, today we can set the permission level for a specific group.

for the base permission you can use:
 ViewListItems
AddListItems
EditListItems
DeleteListItems
ApproveItems
OpenItems
ViewVersions
DeleteVersions
CancelCheckout
ManagePersonalViews
ManageLists
ViewFormPages
Open
ViewPages
AddAndCustomizePages
ApplyThemeAndBorder
ApplyStyleSheets
ViewUsageData
ManageSubwebs
CreateGroups
ManagePermissions
BrowseDirectories
BrowseUserInfo
AddDelPrivateWebParts
UpdatePersonalWebParts
ManageWeb
UseClientIntegration
UseRemoteAPIs
ManageAlerts
CreateAlerts
EditMyUserInfo
EnumeratePermissions
CreateSSCSite

below the script :


$sites = get-spsite -Limit ALL –webapplication [webapp url]
ForEach ($spSite in $Sites)       
{        

$spWeb = $spSite.RootWeb

# Enter the Name of the Permission Level to Change

if ($PermissionLevel=$spWeb.RoleDefinitions["custom deinifition"])
{

Write-Host "working with : " $spSite -ForegroundColor Green
$bps = $PermissionLevel.BasePermissions

Write-Host "saving base permission ..."
Write-Host $bps -ForegroundColor Cyan

# Enter all the permissions that Permission Level should have enabled

$PermissionLevel.BasePermissions="ManageSubwebs","$bps","ApplyThemeAndBorder,ApplyStyleSheets,ManageWeb"

Write-Host "Applying new base permission on ..."
Write-Host  $PermissionLevel.BasePermissions -ForegroundColor Magenta

$PermissionLevel.Update()
$spweb.Dispose()
$spsite.Dispose()
else
{
Write-Host "no custom definition  in " $spSite -red

Thanks.