Thursday, June 20, 2019

Use Open UI to Dynamiclly Manipulate Detail Tabs

In a screen with many view tabs it may be useful for process automation to minimize clicking on detail tabs if user does not need to navigate there when no records are present.  Open UI allows changing the view tab labels to provide indicators to signal to the user information about that tab.  In order to do so, join fields or calculations based on MV fields relevant to the child BC need to exist and be exposed as controls on the parent BC applet (they can be hidden).

One additional feature is to hide the view tabs not requiring navigation for UI optimization but keeping them available in case the user needs them.  Siebel uses a UI dropdown widget when there are too many views to fit horizontally across.  We can leverage this widget to conditionally place additional views based on the values in BC fields.


The following script is attached to a navigation manifest event:



if(typeof(SiebelAppFacade.pptCustomNavigationPR) === "undefined"){ 
  SiebelJS.Namespace("SiebelAppFacade.pptCustomNavigationPR"); 
  define ("siebel/custom/pptCustomNavigationPR", ["siebel/accnavigationphyrender"], function () { 
    SiebelAppFacade.pptCustomNavigationPR = (function(){ 
      var PM; 
      var PRName = ""; 
      function pptCustomNavigationPR(pm){ 
      SiebelAppFacade.pptCustomNavigationPR.superclass.constructor.apply(this,arguments);} 
      SiebelJS.Extend(pptCustomNavigationPR, SiebelAppFacade.AccNavigationPhyRenderer); 
            
      pptCustomNavigationPR.prototype.Init = function() { 
        SiebelAppFacade.pptCustomNavigationPR.superclass.Init.apply(this, arguments); 
        PM = this.GetPM(); 
        PRName = PM.GetPMName(); 
      }; 
      /*pptCustomNavigationPR.prototype.ShowUI = function(){ 
        SiebelAppFacade.pptCustomNavigationPR.superclass.ShowUI.apply(this, arguments); 
        //implement ShowUI method here 
      }; 
      pptCustomNavigationPR.prototype.BindEvents = function(){ 
        SiebelAppFacade.pptCustomNavigationPR.superclass.BindEvents.apply(this, arguments); 
        //implement BindEvents method here 
      };*/
            
      pptCustomNavigationPR.prototype.BindData = function(bRefresh){ 
        SiebelAppFacade.pptCustomNavigationPR.superclass.BindData.call(this, bRefresh); 
                
        //Prototype for child record counter on view tabs 
        if (PRName == "NavigationDetailObject_PM"){ 
          //the framework is processing detail navigation, this is a good place for code that manipulates view tabs. Get applet, control, value and properties 
          //Code assumes the top form applet has a control that exposes a count 
          var oView = SiebelApp.S_App.GetActiveView();
                                  
          if (typeof(oView) != 'undefined' && oView != null && oView.hasOwnProperty("GetName") == true) {
            var sViewName = oView.GetName();
                 
            //Limit execution of this script to only views matching a naming convention as it must have a parent form applet containing the hidden calculated fields
            if ( sViewName.indexOf("XXX Search Text") >= 0 ){
              var suppressTabs = true;

              //This applet must have controls containing the BC fields that will be used in the array
              var applet = oView.GetAppletMap()["XXX Parent Form Applet"];

              //Declared Array where index is UI display name of the detail tab and value is either BC Field Name or '-'.  If field name, non 0/non null value indicate tab should
              //be displayed.  '-' indicates tab should always be hidden.  If tab should always be displayed, do not put it in the array
              var tabList = {"Contacts":"XXX Contact Count","Activities":"XXX Activity Count","Service Requests":"XXX SR Count","Notes":"XXX Notes Flag","Fees":"XXX Fees Flag","Audit Trail":"-"};
              var hitCount, fieldName;
              var tabIndex = 0;
              var tabs = [];
              var tabScreens = [];
              var showWidget = false;
              var lastTab;
      
              //loop through each visible detail tab... 
              $(".siebui-subview-navs .siebui-nav-tabScreen .ui-tabs-nav a").each(function(index){ 
                //get the current tab label text 
                var currentLabel = $(this).text(); 
                  
                //check if tab is in array of labels that need modification
                fieldName = tabList[currentLabel];
                if (typeof(fieldName)!='undefined' && fieldName != ""){  //we found the tab 
                  if (fieldName == "-") hitCount = "";
                  else hitCount = applet.GetBusComp().GetFieldValue(fieldName);

                  //Either modify the label if an indicator needs to be appended or if tab is to be suppressed, add to an array of labels to appear in the option list
                  if (hitCount != "" && hitCount != "0") {
                  //now change the text 
                    $(this).text(currentLabel + " (" + hitCount + ")"); 
                    lastTab = $(this);
                  } else if (suppressTabs) {
                  //If this tab should be generally suppressed, there are no indicators needing to be displayed, and it is not currently selected
                    if (fieldName != "" && (hitCount == "" || hitCount == 0) && $(this).parent().attr("tabindex")!= "0") {
                      showWidget = true;
                      tabs[tabIndex] = currentLabel;
                      tabScreens[tabIndex++] = $(this).attr("data-tabindex").substring(9);
                      $(this).remove();
                    } else {
                      lastTab = $(this);
                    }
                  }   
                }
              }); 
              
              //If any tabs need to be suppressed, display a drop down at the end of the detail tab row with list of view tabs that have been suppressed
              if (showWidget == true) {
                var j=0;
                var htmlstring = lastTab.parent().parent().html();
                var append = '<li><select aria-atomic="true" aria-label="Third" bar="" class="siebui-nav-links siebui-nav-viewlist" id="j_s_vctrl_div_tabScreen" level="" role="combo" view="">==$0<option hidden="" value=""></option>';</select></li>
                while (j < tabIndex) {
                  append = append + '<option value="tabScreen'+tabScreens[j]+'">'+tabs[j++]+'</option>';
                }
                append = append + '</select></li>';
                lastTab.parent().parent().html(htmlstring+append);
              }
            }
          }
        }        
      }; 
              
      return pptCustomNavigationPR; 
    }()); 
    return "SiebelAppFacade.pptCustomNavigationPR"; 
  }); 
}

Tuesday, March 8, 2016

Thick Client Event Logging

There are surprisingly few blog posts out there about vanilla options for logging in the thick client.  Perhaps this is because everyone knows how to do it and if so feel free to ignore this.  But perhaps it is because most people just struggle through using inefficient methodologies.

Here is a simple tip for troubleshooting when using the thick client.  There is an OS environment variable called SIEBEL_LOG_EVENTS (if it does not exist you can create it). Many developers know how to set this to an integer between 0 and 5, but values of 4 and 5 where good detail is provided create a file that unreasonably large and hard to parse.  When troubleshooting on the thin client you can set individual event log levels from the Administration - Server Configuration screen, component events view.  You can do the same when using a thick client though you need to do it using the SIEBEL_LOG_EVENTS variable.  You can use any combination of event aliases and levels, but the value I have found useful is the following:
StpExec=4,PrcExec=4,ObjMgrSqlLog=4,SQLParseAndExecute=4,ObjMgrBusServiceLog=4,EventContext=4,ProcessRequest=4,ObjMgrDBConnLog=5,SecAdpLog=5,ObjMgrSessionLog=5,ObjMgrBusCompLog=2
Basically you can enter any comma separated list of event aliases.

One coda is that if I were trying to troubleshoot a WF issue, I could open this log and do a find for the word 'Instantiating'.  The first instance I would find is the Start step of the WF Process followed by the values of the process properties being set by that step:
PrcExec Create 4 00000002569f1a98:0 2016-01-20 15:31:33 Instantiating process definition 'PPT Passport History Response Integration'.
PrcExec PropSet 4 00000002569f1a98:0 2016-01-20 15:31:33 Setting runtime value of property 'Namespace: 'USER' Name: 'ConfigItem' Datatype: 'String'' to:
PrcExec PropSet 4 00000002569f1a98:0 2016-01-20 15:31:33 Start
PrcExec PropSet 4 00000002569f1a98:0 2016-01-20 15:31:33 Setting runtime value of property 'Namespace: 'USER' Name: 'ObjectName' Datatype: 'String'' to:
PrcExec PropSet 4 00000002569f1a98:0 2016-01-20 15:31:33 Workflow - PPT Test Error Process
PrcExec PropSet 4 00000002569f1a98:0 2016-01-20 15:31:33 Setting runtime value of property 'Namespace: 'USER' Name: 'CurrentStep' Datatype: 'String'' to:
PrcExec PropSet 4 00000002569f1a98:0 2016-01-20 15:31:33 Convert Siebel Message PPH
Subsequent occurrences look like this:
StpExec Create 4 00000002569f1a98:0 2016-01-20 15:31:33 Instantiating step definition 'Start'.
StpExec End 4 00000002569f1a98:0 2016-01-20 15:31:33 Stopping step instance of 'Start' with a 'Completed' status.
In this way you can step through the WF.  The advantage of this logging level over say looking at the WF Instance Monitor or only using WF Simulator, is you will be able to see the SQL executed and the bind variables used, what BCs were instantiated along the way, and what BS methods might have been called.

Tuesday, February 9, 2016

EAI Integration Map expressions

While there are many posts I have seen that talk about expressions supported by 'EAI Data Transformation Engine', I have never seen an attempt to compile a list of supported functions and examples of there uses.  So this will be a humble beginning that will hopefully grow over time.  Note that these functions are mostly VB so if trying out one that is not listed, start with what is supported in VB.  They can also be found in Siebel Bookshelf as Siebel Query Language expressions

Do not include XML element (use System type)
IfNull([Middle Name], [Conflict Id])

Transforming Dates
(from 'YYYYMMDD' to 'MM/DD/YYYY'):
Right(Left([Source Field Name],7),2) +"/"+Right([Source Field Name], 2)+"/"+Left([Source Field Name], 4)

(from Siebel Date to externally recognized format):
ToChar([Birth Date], 'YYYY-MM-DD')
ToChar([Completion Date], 'YYYY-MM-DDThh:mm:ss')

Conditional Logic:
IIF([Source Field Name] = "false", "N", "Y")

SSN formatting (Strip hyphens):
IIF(InStr([PPT Social Security Number], "-") > 0, Left([PPT Social Security Number], 3)+Mid([PPT Social Security Number], 5, 2)+Right([PPT Social Security Number], 4), [PPT Social Security Number])

EAI Lookup for an Inbound Interface:
  • EAILookupSiebel("XXX",[Source Field Name])
    • XXX is the Type in the EAI Lookup table.  This needs also needs to be setup as a value under the EAI_LOOKUP_MAP_TYPE LOV type.
  • IIF([Source Field Name] IS NULL, "", EAILookupSiebel("XXX",[Source Field Name]))
    • EAILookupSiebel fails if no value is found so minimize this possibility unless an exception is desired
Extract the file name from a File Path:
Mid([Source Field Name], InStr([Source Field Name], "/", -1) + 1)

Thursday, October 22, 2015

Interesting Web Service approach

I was recently working on a client where all the integration used HTTP Web Services but were not implemented using what I think most Siebel Developers would think of as the "Best Practice".  Basically, the payloads were created using XSLT and the actual call to the Web Service was invoked using 'EAI HTTP Transport' rather than a custom WS Proxy BS created using the Tools wizard. 

The reasoning provided to me behind using XSLT to create the payload is that it was more flexible.  What do I mean by that?  Well assume an outbound interface is needed where the "Best Practice" alternative would be to use 'EAI Siebel Adapter' to query an Integration Objects , then to use 'EAI Data Transformation Engine' to transform the payload into an IO (that was initially created by consuming a WSDL) recognizable by the Web Service.  The limitation in this approach is around a couple pieces that Siebel Tools wizards have trouble with.  The first is that some modern standards compliant  WSDL definitions that use recursive data types cannot be imported at all.  The second is that the SOAP Header follows a standard that is somewhat outdated, is not configurable, and basically requires scripting to create a custom header anyway.  So the question is whether it is better to create the custom header using a scripted Filter Service, or to create the payload using XSLT.  Once you go down the path of using XSLT, you basically cant use a Proxy Service anymore (since the proxy would be adding the SOAP envelope) so 'EAI HTTP Transport' is used instead.

I can think of a number of downsides to this approach:
  • Deployment Complexity increases
    • XSLT files must be deployed to the File System and kept in sync across however many app servers (and failover servers) are used by EAI in the respective environments
    • No WSDL is actually consumed in this approach so web service end points must be stored somewhere which will likely be different in each environment
  • More Steps in the WF
    • 'EAI XSLT Service'  uses UTF-16 input so it is likely Encoding will need to occur both to and from using 'Transcode Service'
    • Reading the XSL File from the file system
  • Mainainability
    • Siebel resources that know XSLT are presumably more rare than Siebel resources familiar with more "Best Practice" approaches
  • Performance
    • Calls to the File System to get the XSLT file might add significant load to a high volume interface
  • Data Integrity
    • The integrity of the outbound message data structure is not really enforceable in Siebel. Using XSLT requires the developer to create a payload that is correct as only the external system would be able to validate it.  This is perhaps debateable because ultimately the developer will probably need to resolve this one way or the other during development.  While I personally believe it is easier to troubleshoot problems that are actually identified within Siebel due to the strict defintion of the messages maintained in Siebel, I will concede that might be personal preference.
I am curious what others think and whether developers that use this approach can defend it better than I can.  Ultimately, I think a scripted filter service is a better solution to the custom Soap Header issue, though I think this approach seems reasonable if the WSDL cannot be consumed, and modifying it is not possible.

Scriptless OK/Cancel popup

In the early days of configuring in Siebel, if a user wanted a confirmation or warning message before proceeding, it would require Browser Script to implement and most Siebel configurators would try to discourage the requirement on purely technical grounds.  And to be fair, an application littered with popup warnings may not be a great idea on functional grounds either, but there are probably good reasons to implement a warning message on occasion and it would be nice if it could be done in a way that does not have technical repercussions.  So here you go.

On a BC, configure a 'Named Method' user property with value:
"YourMethodName", "INVOKESVC", "FDNS IDENT Encounter", "LS Pharma Signature UI Service", "ShowConfirmDialog", "'Cancel Method Name'", "YourCancelMethodName", "'OK Method Name'", "YourOKMethodName", "'Confirm Text'", "'Are you sure you want to Proceed or some other message?'"

The method 'YourMethodName' would be invoked according to your requirements.  In a simple case, a custom action button on an applet could invoke this method but it could really be invoked anywhere.

The methods 'YourOKMethodName' and 'YourCancelMethodName' need to be callable methods, either that you also configured as additional Named Methods, or vanilla methods (or scripted ones defined in PreInvoke but that would sort of defeat the point). 

When 'YourMethodName' is invoked, a popup message containing the message parameter is shown with an Ok and Cancel button.  Clicking either button calls the methods defined.  Enjoy

Vanilla Merge Behavior

I recently encountered an issue when adding a DB View based EBC to a BO.  When I attempted to perform a MergeRecords operation on two records in the primary BC (Contact in this case), I got an error:

[1] An error has occurred writing to a record
Please continue or ask your system administrator to check your application configuration if the problem persists.(SBL-DBC-00111)
[2]ORA-06550: line 137, column 15:
PL/SQL: ORA-01031: insufficient privleges
ORA-06550: line 137, column 1:
PL/SQL: SQL Statement ignored

It turns out this error is caused because siebel is attempting to update a column in a DB View.  Why would it try to do that you might ask?

If we reverse engineer what is happening, we find that when performing a MergeRecords operation, Siebel determines the underlying table of the active business component and uses the SRF to find all links where the identified table is shared with the source business component of the Link and the source field is ‘Id’ (or null which is the same thing).  The merge algorithm then takes this list to write the SQL to update the appropriate destination field to the new value of the Id field on the Source BC.  Since merge is a data integrity operation, the use of Links using the ‘Id’ field is a proxy for those links configured to have a data integrity implication. 

Ideally, Siebel would provide a configurable mechanism to exclude a particular link from a Merge, or, at a minimum, to recognize that when a link points to a destination BC that is based on a table object whose type is ‘External View’, no update is possible and hence should not be attempted.  Alas that is not the case. 

Therefore a way to trick the algorithm into excluding this link is to define the link on one which is not based on data integrity, and instead make it just informational.  This can be done by making the Source field of the link something other than Id.  But since we do not want to actually change the definition of the view this link points to, a column whose value matches the ROW_ID column is desireable.  In the case of the Contact BC, there are a couple of potential options.  PERSON_UID defaults to the Id field but since this column might be populated by EIM to be a value other than it’s ultimate row id, the values may not match on that data set.  But since Contact is based on the Party model, the PAR_ROW_ID should always match since this points to the S_PARTY record and the same ROW_ID is always used. This column is not exposed on the Contact BC though so it needs to first be exposed and then the new BC field can be used in the links.

Friday, May 10, 2013

The XML Logger - Reviewing the Payload

In my last post, I talked about how to capture XML Payloads by splitting large values across a series of DB records. In order to look at the data, we need to reassemble the payloads into a single text block again. I expose my Payload BC in a view tied to either the User's session:

or to the record on which the interface was executed:

The latter is accomplished through the payload parsing I talked about which allows us to create a view which links an object record to the payload record once the transaction id is stored on the payload record. On these views, I expose I nice looking form applet which displays both the request and response sides of the interface. The form fields are actually calculated fields, defined as DTYPE_TEXT, with the following expression:
InvokeServiceMethod("XXX Utilities", "ConcatenateField", "bo.bc='XXX User Session.XXX User Session XML Detail', FieldName='Log Text', SearchExpr='[Parent Id]=""+[Id]+"" AND [Field]="Request"'", "Out")
where:
  • 'XXX Utilities' is my eScript framework service with many commonly used functions
  • 'ConcatenateField' is a method on that service 'bo.bc' is a parameter name for that method
  • 'XXX User Session' is the name of the business object where my user sessions are stored
  • 'XXX User Session XML Detail' is the name of the business component containing the split up log data 'FieldName' is another parameter for this method
  • 'Log Text' is the name of the field on the 'XXX User Session XML Detail' BC where the split payload text is stored defined as DTYPE_CLOB
  • 'SearchExpr' is another parameter for this method

Finally the search expression looks a bit complicated as passing quotes to the InvokeServiceMethod is difficult. I have improvised by using a commonly used XML expression of " which the method then recognizes and converts back to a quote. Here is the method:

function ConcatenateField(Inputs, Outputs) {
//Inputs: bo.bc  "boName.bcName"
//   FieldName
//   SearchExpr BC Search Expression (Optional)
 var retValue = "";
 var found = false;
 var search = Inputs.GetProperty("SearchExpr");
 try {
  var arSplit = Inputs.GetProperty("bo.bc").split(".");
  var bcQuery:BusComp;
  if (arSplit[0] == "ACTIVE") 
   bcQuery = TheApplication().ActiveBusObject().GetBusComp(arSplit[1]);
  else 
   bcQuery = TheApplication().GetBusObject(arSplit[0]).GetBusComp(arSplit[1]);
   
  var delimeter = (Inputs.GetProperty("delimeter") != "" ? Inputs.GetProperty("delimeter") : "\n");
 
  with (bcQuery) {
   if (search != "") {
    ClearToQuery();
    arSplit = Inputs.GetProperty("SearchExpr").split(""");
    search = arSplit.join("'");
    SetSearchExpr(search);
    ActivateField(Inputs.GetProperty("FieldName"));
    SetViewMode(AllView);
    ExecuteQuery(ForwardOnly);
   }
  
   found = FirstRecord();
   while(found) {
    retValue += GetFieldValue(Inputs.GetProperty("FieldName"));
    found = NextRecord();
    if (found) retValue += delimeter;
   }

      Outputs.SetProperty("Out", retValue);
  }
 } catch(e) {
  TheApplication().RaiseError(e);
 } finally {
  bcQuery = null;
  arSplit = null;
 }
}