Archive for the ‘Client Script’ 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

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 add version number to Pivotal BM?

April 10, 2007

During Pivotal Development often we need to be able to track which version the users/testers are running against. Below is the sample client script code to show the version number. The version number itself stored as a global variable. Please note that you need to make the client script as global script.

    1 Dim strVersion                              

    2 Dim objNewCell


    4 strVersion = “”


    6 Set objNewCell = _

    7     UIMaster.documentMenu._

    8     getElementsByTagName(“TABLE”)(0). _

    9     insertRow(1).insertCell(0)


   11 objNewCell.className = “FindTitleCell”

   12 objNewCell.innerText = “BM Version: “ + strVersion