A tool to shutdown Sedna PBS

June 6, 2008

We all know Pivotal changed the LCS component name and the the little tool that we use to shutdown PBS is no longer compatible. I recompiled the code to be compatible with Sedna. Download the file below and rename it to clearcache.zip.

clearcachesedna.zip

Advertisements

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.

ScreenShot005 

'***************************************************
' Name:     OnPortalLoaded
' -> Default the Global Search to "Companies" BO
'***************************************************
Sub OnPortalLoaded(ParameterList)    
    Dim objInput
    Set objInput = UIMaster.documentMenu. _ 
        body.getElementsByTagName("INPUT")
    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._ 
        body.getElementsByTagName("INPUT")
    
    If objInput(0).Value = "Companies" Then
        strSearchText = objInput(1).Value
        Set objSearchFactory = _ 
      UIMaster.CreateCenterReference("quicksearch")
        With objSearchFactory
            .SearchType = 1 'A non-global quick search.
            Set .Table = _ 
        UIMaster.RSysClient.GetTable("Company")
            .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
    oField.InputElement.style.display = "none" 
    Set oTDs = oField.ParentElement.GetElementsByTagName("TD")
    For Each oTD In oTDs
        oTD.style.display = "none"
    Next
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 _ 
        UIMaster.documentMenu.all
        If objHTMLDoc.tagName = "DIV" _ 
            and UCase(objHTMLDoc.title) = _ 
        UCase(strBusinessObjectName) Then
            objHTMLDoc.parentElement.parentElement. _ 
                parentElement.parentElement. _ 
        parentElement.parentElement. _ 
        style.display="none"
        End If
    Next
End Sub

Better than a napkin: Track your BM changes

May 28, 2007

As Pivotal Customizers, we all love the feature of Transporter that allows us to easily transport changes at the element level from one BM to another. Even for some of us, building a transporter file is part of their day to day life.

When creating a transporter file, first, we need to know which elements to be included to the transporter file and make sure we are not missing anything. Some people keep track their changes on a napkin or their journal, just use their memory to remember, or run the script below to get all the changes automatically. The choice is yours.

Here is the script to keep track the changes since certain date – it’s not not complete, however I found it is good enough for Active Access Development.

BMChangesSince

Using client script to host xml configuration

May 16, 2007

To make an appserver rule configurable, we often need to store some parameters as a separate xml file. The only problem with this approach is that we have to remember to copy the xml file to the (production) server.

In Pivotal, the more practical way to store the configuration is to host the xml string inside a client script. Since the client script is part of the BM, it will always be available and there is no special deployment required.

Below is the example on how to retrieve xml configuration from a client script.

<?xml version="1.0" encoding="utf-8"?>
<config>
  <logging logFile = "D:\PivotalLog.txt" logLevel = "2">
  </logging>
</config>

Fig. Sample of XML Configuration hosted as a client script

string ClientScriptMapping = "CMS_Config";
string mapping = 
    m_pivotalSystem.ClientScripts[ClientScriptMapping].Text;
string logSettingString = 
    string.Empty;
 
try
{
 
    XmlDocument xd = new XmlDocument();
    xd.LoadXml(mapping);
    string xPathString = "/config/logging";
    XmlNode xNode = xd.SelectSingleNode(xPathString);
    logFile = xNode.Attributes["logFile"].Value;
    logSettingString = xNode.Attributes["logLevel"].Value;
    logSetting = (LogLevel)Convert.ToUInt16(logSettingString);
}

Fig. .NET ASR to retrieve xml string a client script

Migration: Using rsp_tablename_update_formulas

April 13, 2007

One thing we are missing when doing migration with direct sql approach is that all table level formulas will not be automatically calculated. In the past we must reproduce the code inside our migration script to handle all formulas manually.

To help the performance, Pivotal automatically generates a bunch of stored procedures inside the ED with the following format rsp_tablename_update_formulas. Most of them have only three parameters:

@recordId binary (8) 
@CurrentUserId binary(8) 
@CurrentUserName varchar(255) 

These stored procedures, we can use it out-of-the-box by calling it inside our migration script.

Unfortunately, for more complex formulas such as the ones with date related, soundex etc, Pivotal platform decided to do the calculation at the application level and pass the calculated values the stored procedures as additional parameters such as @P1, @P2, etc.

The beauty with this approach is, we only need to re-code the application level formulas and leave most of the calculation to the Pivotal auto generated stored procedures.

Migration: Generate Pivotal ID in SQL 2005

April 11, 2007

Below is the sample code on how to generate Pivotal ID using the new ROW_NUMBER() feature in SQL 2005.

USE AdventureWorksLT
GO
DECLARE @Last_Id AS BINARY(8)

SELECT 
    @Last_Id = Last_Id_Value 
FROM CMS59_ED.dbo.RSys_Last_Id 
WHERE Table_Name = 'Contact'

SELECT
    CAST(
    CONVERT(bigint, @Last_Id) + ROW_NUMBER() 
    OVER(ORDER BY CustomerID) 
    AS Binary(8)) AS Contact_Id,
    *
FROM SalesLT.Customer