Disabling Select Drop Down List using jQuery without ‘disabled’

Say you have a drop down list defined as a select tag:

<select id="dropdown">
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3" selected>Three</option>
</select>

You can very easily disable the drop down list with jQuery by adding a disabled property to the tag.

$('#dropdown').attr('disabled', 'disabled')

However, in doing that, the selected value of the drop down list is no longer posted back on a form submit. And some systems (such as SharePoint) may then persist the default value when saving changes, which in the example above is “1” instead of the selected “3”.

So instead of a straight forward disable, we’re forced to do some extra work to make sure the control remains disabled on the front end to the user, but still posts back the corrected selected value to the back end.

The JavaScript below achieves this:

Continue reading

Updating Locked Workflow Task

When trying to update a workflow task item in code, you may get the error “This task is currently locked by a running workflow and cannot be edited.”

This error gets thrown because the ows_WorkflowVersion of the task list item has been set to 512.

There may be a good reason it’s set to locked (i.e. currently being updated) but it you really really want to still update the task, you can override the flag.

Continue reading

Running Content Iterator in PowerShell

PowerShell can be very useful to quickly write up a script when you need to say update a field value for items in a list.

But what happens if your list happens to have 100,000+ items? Doing SPList.Items is going to get throttled.

And while PowerShell doesn’t have an equivalent for the ContentIterator class (which can iterate through large data sets while avoiding throwing a SPQueryThrottledException), we can run custom code through PowerShell that¬†utilizes ContentIterator.

The script below does a simple field update for items of a specific content type in a list.

Continue reading

Deleting Site Columns

When trying to delete a site column, you may get the error “Site columns which are included in content types cannot be deleted. Remove all references to this site column prior to deleting it.”

Delete Site Column Error

This simply means that the site column needs to be manually deleted from content types before it can be properly removed.

You may have already manually done so on all content types you know of that refers to the site column, but the error still persists.

This is because it not only needs to be deleted from content types on the site collection level, but on all site level content types as well!

Continue reading