Creating a BBIS part so that the ADF doesn’t need hard coded values (GUIDs and URLs)

By: Chris Whisenhunt

Posted on: December 12, 2016

We got our ADF developed by Blackbaud and had issues with the need to hard code GUIDs and URLs. The hard coded values looked something similar to this.

var BBI = BBI || {
    // update these values when updating changelog
    Config: {
        version: 1.5,
        updated: '01/15/2016',
        isEditView: !!window.location.href.match('pagedesign'),
        responsive: true

    Defaults: {
        rootpath: BLACKBAUD.api.pageInformation.rootPath,
        pageId: BLACKBAUD.api.pageInformation.pageId,

        designationQueryId: 'DADA4C7E-DFA7-4E83-A440-988DBAE3F16A',
        MerchantAccountId: 'BC69375B-EF5D-4849-9204-726CCD165730',
        paymentPartUrl: 'http://yoursite/payment',

        // ADF - Custom Attributes
        handlingNotesGUID: '10197036-033D-4BD4-9474-3F9895A9F98F',
        pledgeGiftGUID: '2C7579EF-7C56-4E97-8A51-F281358544AD'

    Methods: {
        //methods in here such as pageInit, etc.

So to get rid of those hard coded GUIDs I decided to create a new BBIS part that was on every page and that rendered those GUIDs to a new JS namespace. Then that namespace was referenced through the code above.

In the new BBIS part the editor gave the ability for a user to select the designation query, merchant account, payment part page, and the attributes to use for the handling notes and pledge gift.

In the display part we rendered the new JS like so.

Partial Public Class ADFModifierDisplay
    Inherits BBNCExtensions.Parts.CustomPartDisplayBase

    Private _content As ADFModifierProperties
    Private _scriptName = "ADF Modifier for page {0}"

    Protected Overrides Sub OnPreRender(e As EventArgs)
        Dim pageID = API.Pages.CurrentPage.Id
        Dim script = "var SCU = SCU || { Defaults: { "

        If(pageID > 0) Then
            With MYCONTENT
                Dim paymentPartUrl = URLBuilder.GetSitePageLinkBuilder(.PAYMENTPARTID).ToString()

                script += "designationQueryId: '" + .DESIGNATIONQUERYID.ToString() + "', "
                script += "MerchantAccountId: '" + .MERCHANTACCOUNTID.ToString() + "', "
                script += "paymentPartUrl: '" + paymentPartUrl + "', "
                script += "handlingNotesGUID: '" + .HANDLINGNOTESATTRIBUTEID.ToString() + "', "
                script += "pledgeGiftGUID: '" + .PLEDGEGIFTATTRIBUTEID.ToString() + "'"
            End With

            script += "}};"

            If(Not String.IsNullOrWhiteSpace(script)) Then
                ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType(), String.Format(_scriptName, pageID), script, False)
            End If
        End If
    End Sub

    Private ReadOnly Property MYCONTENT As ADFModifierProperties
            If _content Is Nothing Then
                _content = Me.Content.GetContent(GetType(ADFModifierProperties))
                If _content Is Nothing Then
                _content = New ADFModifierProperties
                End If
            End If
            Return _content
        End Get
    End Property
End Class

The new BBIS part was added to the template/layout so that they were on every page. Then the JS that was created by the Blackbaud designer was changed to reference the newly rendered JS, like so.

Defaults: {
    rootpath: BLACKBAUD.api.pageInformation.rootPath,
    pageId: BLACKBAUD.api.pageInformation.pageId,

    designationQueryId: SCU.Defaults.designationQueryId,
    MerchantAccountId: SCU.Defaults.MerchantAccountId,
    paymentPartUrl: SCU.Defaults.paymentPartUrl,

    // ADF - Custom Attributes
    handlingNotesGUID: SCU.Defaults.handlingNotesGUID,
    pledgeGiftGUID: SCU.Defaults.pledgeGiftGUID

No more hard coded values and everything is easily configured between environments without having to the change the JS.

2 thoughts on “Creating a BBIS part so that the ADF doesn’t need hard coded values (GUIDs and URLs)

  1. nice solution
    Navy just finished converting 25 custom parts over to talk to CRM from RE. We’re doing our testing now and then plan on migrating at least some stuff to make better use of the newer JS apis. I’ll keep this in mind when we do that. thanks

Leave a Reply

Privacy Policy | Sitemap | © 2011 Blackbaud, Inc. All Rights Reserved

Digital Ocean