Unable to set value of the property ‘aSettings’

I developed a page, inheriting from LayoutsPageBase which was being displayed in a modal dialog using JavaScript similar to the following:

<script type="text/javascript">
    function DisplayCustomPopupPage() {
        var options = SP.UI.$create_DialogOptions();
 
        options.url = "http://urltocustompage/page.aspx";
        options.title = "Popup Page";
        options.allowMaximize = false;
        options.showClose = true;
        options.width = 800;
        options.height = 450;
 
        SP.UI.ModalDialog.showModalDialog(options);
    }

The DisplayCustomPopupPage function would be called from a click event on the page.

The popup page had an InputFormTextBox control on it that was configured for rich text mode.

The problem I encountered with this was a JavaScript error that said ‘null’ is null or not an object or Unable to set value of the property ‘aSettings’: object is null or undefined.
Continue reading

Posted in JavaScript, SharePoint | Tagged , | 2 Comments

Start SharePoint Timer Job Script

I’ve written a PowerShell script that starts a SharePoint timer job, which is useful if you do a lot of work that relies on certain timers firing and don’t want to have to keep going into the Central Administration site to manually start the desired timer. For instance, the Workflow timer fires every 15 minutes by default and although you could reduce this to 1 minute, sometimes you just want to try and force it to start. If, like me, you don’t have the patience to wait up to a minute for it to execute 🙂

The script is pretty simple really, the main component being

job-workflow | Start-SPTimerJob

Now, this on its own isn’t much use, so the following script allows you to run it and receive confirmation that the process was started.
Continue reading

Posted in SharePoint | Tagged , | 2 Comments

Get ListTemplate and Create New List in PowerShell

A PowerShell related post today:

To create a list or library in SharePoint, you can do the following:

$web = Get-SPWeb "http://serverUrl"
$web.Lists.Add("List Title", "List description", "Template Name")

Now, say you were creating lists based on the schema from another list:

$web = Get-SPWeb "http://anotherServerUrl"
$list = $eb.Lists.get_Item("List name")
$listSchema = $list.SchemaXml

The SchemaXml from a list only contains the ServerTemplate numeric value, which can not be passed to the Add method in a PowerShell script.
Continue reading

Posted in SharePoint | Tagged , | 1 Comment

Task locked by Running Workflow and Cannot be Edited

If you’re trying to update a task item that is linked to a running workflow using code similar to

public UpdateTaskItem(SPList taskList, int identifier, string newValue)
{
  taskItem = taskList.GetItemById(identifier);
  // Update task item
  taskItem["fieldname"] = newValue;
  taskItem.Update();
}

and receive an error stating This task is currently locked by a running workflow and cannot be edited, a simple fix is to update the built in field WorkflowVersion to the value 1 prior to calling the Update method.
Continue reading

Posted in SharePoint, Workflow | Tagged , , | Leave a comment

Remove property from SPPropertyBag

Have you ever tried to remove a property from a SPWeb object and after applying the update, when you next check for the property it is still there?

Logically, you’d think the following code would do this for you:

webObject.Properties.Remove("yourkey");
webObject.Properties.Update();

But, I’ve found, if you reload the SPWeb object and check for the key, it still exists, even though it had been previously removed. To successfully remove a property from the web’s property bag, try setting the property to null, as shown below.

webObject.Properties["yourkey"] = null;
webObject.Properties.Update();

Now when you reload the SPWeb object and check for the property, it won’t exist. It seems that the Remove method is either flaky, or the change is not being persisted after applying the update on the Properties property.

Of course, you really should be using the new AllProperties property instead, where this issue is not present. This property was added to 2010 and uses a HashTable instead of the SPPropertyBag. Items added to AllProperties will filter down to Properties but not the reverse. Most (if not all) of the internal properties use the old Properties property, so there are still certain cases where you’d want to manipulate them. How you work with them is slightly different, for example:

// Remove from old style Properties
webObject.Properties["yourkey"] = null;
webObject.Properties.Update();
 
// Remove from new AllProperties
webObject.AllProperties.Remove("yourkey");
webObject.Update();

Nothing too different, instead of updating the property collection directly you you just update the parent web or site object.

Posted in SharePoint | Tagged , | Leave a comment