Remove ‘ReadOnlyField’ lock from columns created in InfoPath using PowerShell


Have you ever created an InfoPath Form Template and published fields from the template to SharePoint Columns in your content type?

I’m sure you have, otherwise you probably wouldn’t be reading this.

Essentially, the columns will be grayed out in the list settings:

And if you try to set the value of the field using SharePoint Designer, you won’t see it in your list of available columns:

However, luckily we have PowerShell – and we can simply edit the ReadOnlyField value from $true to $false – thus allowing us to edit this field. Here’s how!

$web = Get-SPWeb http://weburl
$list = $web.Lists["List Name"]
$field = $list.Fields["Field Name"]
$field.ReadOnlyField = $false
$field.Update()
$list.Update()
$web.Update()
$web.Dispose()

After doing so, the column is not only editable in the browser – we can choose it in Designer:

Advertisements

Remove SharePoint List Views Using PowerShell


Ever have a need to delete list views using PowerShell?  Of course you do, it’s a great reason to use PowerShell!

Luckily for us, there is great access to the Object Model and we can readily access lists, items, and of course views.

I threw together a nifty little function that accepts three parameters, WebUrl, ListName and ViewName and will remove a single view from a SharePoint list.

The code is quite simple, basically we grab an SPWeb object using the WebUrl parameter – we then grab an SPList using the ListName parameter, and finally we grab an SPListView using the ViewName parameter.  Once we’ve drilled down to the specific SPListView, we can call the Delete() method using the ID of the view.

Here’s my function, enjoy!

function Remove-SPListView {
Param(
[string]$WebUrl,
[string]$ListName,
[string]$ViewName
)
Start-SPAssignment -Global
$SPWeb = Get-SPWeb $WebUrl
$List = $SPWeb.Lists[$ListName]
$View = $List.Views[$ViewName]
$List.Views.Delete($View.ID)
$List.Update()
$SPWeb.Update()
$SPWeb.Dispose()
Stop-SPAssignment -Global
}

Generic Error on Listedit.aspx page after SP1 and Aug 2011 CU


Wow did this issue get under my skin.

At my current client, where their SharePoint 2010 Enterprise Intranet is about as business critical as a SP environment can be – I performed the SP1 and Aug 2011 CU updates. The updates themselves went about as smooth as could be expected, until we noticed that lists and libraries would give the generic error w/ correlation ID when navigating to the List Settings page (/_layouts/listedit.aspx).

This seemed like not too big of a deal on the first site collection we noticed it on – then we realized it was farm-wide.

After doing a lot of log-reading, re-running PSCONFIG.exe to ensure that everything completed from an upgrade perspective; we were in the dark…

This morning I noticed something while browsing through the layouts folder – listedit.aspx (and some other files) was modified on 6/8/2011 at 11:46 AM. Most of the other aspx files were showing a modified date much further in the past.

On a whim I copied listedit.aspx from a known-good farm into my broken farm and VOILA – lists and libraries work again.

This might not help anybody, because I couldn’t find anyone else having this exact issue – but I didn’t want to lose track of the “fix.”