Archive for February 24, 2012

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);
    }
</script>

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.
Read more

Get SharePoint Timer Job Name

SharePoint Short #4
As a follow up to my recent post Start SharePoint Timer Job Script, that demonstrates how to start a specific timer job by it’s internal name, the following is a PowerShell script for retrieving the internal name from its display title.

For example, to get the internal name for the Delete Job History timer job, run the following script:

Get-SPTimerJob | Where {$_.Title -eq "Delete Job History"} | ft id,name

Will provide the following output:

Id                                      Name
--                                      -----
cbe86d89-8ed4-49fa-8b84-f814f9a67ab9    job-delete-job-history

To list all timer jobs and their internal names, run the following script:

Get-SPTimerJob | Sort-Object title | ft title,name

Security Trim SPNavigationNode

SharePoint Short #3
To have the URL specified by a SPNavigationNode security trimmed, make sure you do not specify the isExternal constructor parameter.

Obviously, specifying true for this parameter would not apply security trimming against the link, as you would be adding an external link. Specifying false, you’d think it would. Think again.

Using the two parameter constructor does apply security trimming, where relevant.

So, instead of

SPNavigationNode newNavNode = new SPNavigationNode("Node name",
                                  "http://someurl/library/page.aspx", false);

do

SPNavigationNode newNavNode = new SPNavigationNode("Node name",
                                  "http://someurl/library/page.aspx");

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.
Read more

Save Conflict

SharePoint Short #2
In event receivers such as ListAdded, FieldAdded or ItemAdded, if you’re updating the newly created item you may encounter the following error:

“Save Conflict”

These events are asynchronous by default, so changing them to synchronous will ensure that the list, item or field has been added before the event fires. When it’s set to asynchronous, there a high possibility that the item has not completely finished adding when the event is fired, hence the save conflict error.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers >
      <Receiver>
        <Name>CustomFieldAdded</Name>
        <Type>FieldAdded</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>Custom.FieldAdded</Class>
        <SequenceNumber>10000</SequenceNumber>
        <Synchronization>Synchronous</Synchronization>
      </Receiver>
  </Receivers>
</Elements>
Follow

Get every new post delivered to your Inbox

Join other followers: