Archive for the ‘Pivotal Rich Client’ Category

How to Default Global Search to "Companies"

May 12, 2008

This is the sample code on how to default the Global Search to certain Business Object such as Companies.


' Name:     OnPortalLoaded
' -> Default the Global Search to "Companies" BO
Sub OnPortalLoaded(ParameterList)    
    Dim objInput
    Set objInput = UIMaster.documentMenu. _ 
    objInput(0).Value = "Companies" 
End Sub

' Name:     OnGlobalQuickSearchLoaded
' -> Handle the Companies Global Search to run
' Company Quick Search
Function OnGlobalQuickSearchLoaded(vntParameters)
    Dim objInput
    Dim strSearchText
    Dim objSearchFactory
    On Error Resume Next
    Set objInput = UIMaster.documentMenu._ 
    If objInput(0).Value = "Companies" Then
        strSearchText = objInput(1).Value
        Set objSearchFactory = _ 
        With objSearchFactory
            .SearchType = 1 'A non-global quick search.
            Set .Table = _ 
            .SearchText = strSearchText
        End With
        UIMaster.ShowCenterReference _ 
    actionAskUser, objSearchFactory, Null
    End If
    OnGlobalQuickSearchLoaded = True
End Function

Rename Tab Title

October 20, 2007
' Name    : ChangeTabTitle
' Purpose : Use DHTML to Change the Tab Title
Sub ChangeTabTitle(sTabName, sNewTabTitle) 
    Dim sTabId
    sTabId = "Tab_" + _
    CStr((UIMaster.RUICenter.Form.Tabs(sTabName). _ 
    Ordinal - 2))
    UIMaster.documentCenter. _ 
    GetElementById(sTabId).innerText = sNewTabTitle 
End Sub

How to get the deleted rows from SaveFormData

September 10, 2007
IRRecordset2 rstDeleted;
rstDeleted = (IRRecordset2) pForm.SecondaryFromVariantArray(
                                    Recordsets, “Assistants”);
foreach (object deletedId in rstDeleted.DeletedRecordIds)
    //Do Something with your id here

Hide Foreign Key Field

September 10, 2007
' Name    : HideForeignFieldEx
' Purpose : To Hide FK Field using DHTML
' Inputs:
'   sTabName : tab name   
'   sSegmentName : segment name       
'   sFieldName : field name
' Returns:
'   N/A
Sub HideForeignFieldEx(sTabName, sSegmentName, sFieldName) 
    Dim oField 
    Set oField = UIMaster.RUICenter.GetForeignFieldEx(sTabName, _ 
                                    sSegmentName, sFieldName)
    Dim oTDs    
    Dim oTD
    'Hide the label
    UIMaster.RUICenter.GetFieldLabelEx(sTabName, _ 
                       sSegmentName, sFieldName).style.display = "none" 
    'Hide the Input = "none" 
    Set oTDs = oField.ParentElement.GetElementsByTagName("TD")
    For Each oTD In oTDs = "none"
End Sub

Hide Business Object From Menu

August 20, 2007

Below is the function to hide business object from the left hand menu.

' Name:    HideBusinessObject
' Purpose: To Hide Business Object 
'        from Left Hand Navigation
' Info:    To be called from OnMainWindowOpen 
' 1.0            8/20/2007     JM        
Sub HideBusinessObject(strBusinessObjectName)  
    Dim objHTMLDoc
    For Each objHTMLDoc in _ 
        If objHTMLDoc.tagName = "DIV" _ 
            and UCase(objHTMLDoc.title) = _ 
        UCase(strBusinessObjectName) Then
            objHTMLDoc.parentElement.parentElement. _ 
                parentElement.parentElement. _ 
        parentElement.parentElement. _ 
        End If
End Sub

Worry free "stop" statement

April 11, 2007

When working on a Pivotal Client Script, we often add the “stop” statement to launch the script debugger and then remove it from the release version. Most of the time we forget to do it, right?

Fortunately, Pivotal has a feature to turn on the debug flag (UIMaster.DbgFlag) by adding &debug at the end of the url to launch Active Access as below:


I found this flag is very useful when it is combined with our favorite “stop”statement.

If DbgFlag Then Stop

We can just leave the code on the release version and it won’t be executed unless we add the &debug at the end.

Using Non-default Search Result List

April 11, 2007

Since Version 5.0 Pivotal allows us to use non default search result list to display results from an active search.

Although it is very straight forward deal, we still need to pay a little bit attention to the SearchSource parameter that is expected by UseSearchResultsList function. It expects Business Object Internal Name instead of table name and Business Object has to be made visible.

Sub ShowNonDefaultSearchResult(strBusinessObject, _
                                strSearchName, _ 
    Const strSEARCH_TYPE = "search"
    Dim objSearchFactory 
    Set objSearchFactory = _ 
    objSearchFactory.SearchType = searchTypeRegular   
    objSearchFactory.Options.UseSearchResultsList _ 
        strBusinessObject, strSearchResultName
    Set objSearchFactory.Search = _ 
    objSearchFactory.Options.AutoRun = True
    objSearchFactory.UsePlatformButtons = True  
    objSearchFactory.Parameters(0) = _ 
    UIMaster.ShowMultiSelectModal objSearchFactory, Null
End Sub

How to get Pivotal Connection String

April 11, 2007

The C# code below shows us on how to build the trusted connection string from the registry stored by Pivotal.

using Microsoft.Win32;


private string GetConStringByPivotalSystem(string systemName)


    string pivotalKey =


            + systemName;

    string odbcKey = “SOFTWARE\\ODBC\\ODBC.INI\\”;

    string sODBC;

    string serverName;

    string dbName;


    RegistryKey key =

       Registry.LocalMachine.OpenSubKey(pivotalKey, true);


    sODBC = Convert.ToString(key.GetValue(“User Data”));


    odbcKey = odbcKey + sODBC;

    key = Registry.LocalMachine.OpenSubKey(odbcKey, true);

    serverName = Convert.ToString(key.GetValue(“Server”));

    dbName = Convert.ToString(key.GetValue(“Database”));

    return “Data Source=” +

                serverName + “;Initial Catalog=” +

                dbName + “;Integrated Security=SSPI;”;