Friday, 18 January 2019

Siebel Auto Complete Functionality :- Part 3

-------To take things a step ahead, -----

In my previous Posts

Siebel Autocomplete from Plugin

Siebel Autocomplete from Native Siebel jQuery

we achieved autocomplete functionality with one limitation that Values to be fetched for autocomplete were provided in the PR file itself that makes it less flexible solution in real case scenario

Now Lets Try to make siebel database layer to act as data source rather then hard code values.

the Solution ,

1. We need to have the value set stored somewhere in siebel , say LOV's Description
2. We need to fetch the value from LOV and pass it as source in the auto complete function

My Solution ,


  • Client Side BS to Fetch Source from List Of Values (Siebel Vanila BS can also be used for this)

BS Code :
{
  var boLOV, bcLOV; 
  boLOV = TheApplication().GetBusObject("List Of Values");
  bcLOV = boLOV.GetBusComp("List Of Values");
  var tags;
  var tag;
  with(bcLOV)   {
  ActivateField("Description"); 
  ActivateField("Type");
  ActivateField("Value");
  SetViewMode(AllView); 
  ClearToQuery(); 
  SetSearchSpec("Type", "AUTOCOMPLETE_LOV");
  SetSearchSpec("Value", "AUTOCOMPLETE");
  ExecuteQuery(ForwardOnly);    if (FirstRecord())
  tag = bcLOV.GetFieldValue("Description");   
  }
Outputs.SetProperty("Tags",tag);
}


  • Calling the BS in PR file and pass as input to autocomplete()


             var sBusService = SiebelApp.S_App.GetService("Query Siebel Data");
    var Inputs = SiebelApp.S_App.NewPropertySet();
    var Outputs = SiebelApp.S_App.NewPropertySet();
// Invoke the Business service Method and pass the Inputs
           Outputs =  sBusService.InvokeMethod("GetValue");
   Data = Outputs.GetChild(0).GetProperty("Tags");
        Array = Data .split(','); // split string on comma space


  • LOV with the Values 



now the final Code

if (typeof(SiebelAppFacade.AutoComplete) === "undefined")

{ SiebelJS.Namespace("SiebelAppFacade.AutoComplete");
  define("siebel/custom/AutoComplete", ["siebel/phyrenderer"], function ()
{
 SiebelAppFacade.AutoComplete = (function ()
 { function AutoComplete( pm )
 { SiebelAppFacade.AutoComplete.superclass.constructor.call( this, pm );

 if ( Data == '' || Data  == null )
 {
 var sBusService = SiebelApp.S_App.GetService("Query Siebel Data");
 var Inputs = SiebelApp.S_App.NewPropertySet();
 var Outputs = SiebelApp.S_App.NewPropertySet(); /
/ Invoke the Business service Method and pass the Inputs
 Outputs = sBusService.InvokeMethod("GetValue");
 Data = Outputs.GetChild(0).GetProperty("Tags");
 Array = Data .split(',');
// split string on comma space }
 }
 SiebelJS.Extend( AutoComplete, SiebelAppFacade.PhysicalRenderer ); 

// bind events function

 AutoComplete.prototype.BindEvents = function(){ SiebelAppFacade.AutoComplete.superclass.BindEvents.call( this );
 // Passing the Value for AutoComplete data too Function
 var tags = Array;

 $( '.siebui-ctrl-textarea').autocomplete(
{ source: function( request, response )
{ var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
 response( $.grep( tags, function( item ){ return matcher.test( item ); }) );
 }});
};
 return AutoComplete; }());
 return "SiebelAppFacade.AutoComplete"; });}

Working example


No comments:

Post a Comment

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...