1

I have a calculated site column. This Site column is used acrossed sites in Content types. Now when I use power shell script to change the Calculated foremule is allowing me to change only in Site column but not on the Content types where this column is being used.

Can any one have sample code to Update existing calculated formule which is already being used in the Content type?

2 Answers 2

4

You need to use the overload for SPField.Update that takes a boolean parameter. That will push the changes to lists that use the field.. I.e., in Powershell:

$myField.Update($true)

MSDN documentation here.

1
  • Awsome it works perfectly :-)... Thanks for your quick reply May 28, 2014 at 4:46
0

Below is the Powershell Script in order to update the site coulmn when used in multiple content types. Hope this might be helpful to some one.

function Update-CalcField([string]$url, [string]$Field, [string]$OutputType, [string]$Formula) {

Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
Start-SPAssignment -Global
 $SPSite = New-Object Microsoft.SharePoint.SPSite($url)
 $OpenWeb = $SPsite.OpenWeb()

$OpenWeb.Fields[$Field].OutputType = $OutputType
$OpenWeb.Fields[$Field].Formula = $Formula
$OpenWeb.Fields[$Field].Update($true)
$OpenWeb.Dispose()
$SPSite.Dispose()
}

#using the above function
Update-CalcField http://myserverapp.testserver.com/sites/test -Field MyCalc -OutputType Text -Formula '=IF(ISBLANK([title]),"Null","Completed")'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.