Friday 25 January 2019

Sending SMS in Siebel : Extending Default [ALT + F9] functionality

Hello All ,

 Sending Email in Siebel is very basic and very useful functionality ,which we widely use.
 Command F9 is provided by default for sending the email via Pick recipient option.

 so using existing framework lets try to extend this functionality for sending SMS,




 Solution,

  •   There is default option for Send Wireless Message in Siebel which is Invoked from Command ALT + F9

 lets extend this functionality to send SMS too ,


  • Find the target Applet , "Send SMS Applet" 


 by default there is Option to Pick Recipient which in turn selects email address as it is Based on Contact ,
 so we need to add some custom code here to Pick Phone number also for the contact
 also we need to enter the Text which we want to sens as SMS Body , and store it in a variable

 Below code in Applet PreInvoke does the needful,

 function WebApplet_PreInvokeMethod (MethodName)
 {
 if(MethodName == "SendSMS")
 {
 this.BusComp().ActivateField("Contact Id");
 this.BusComp().ActivateField("Email Body");

 var SMSBody = this.BusComp().GetFieldValue("Email Body"); // get SMS body to be sent
 var PhoneNum = this.BusComp().GetMVGBusComp("Contact Id").GetFieldValue("Cellular Phone #"); //get Phone number to send SMS
 sendSMS(SMSBody,PhoneNum);
 }



  •  Add Button to Invoke method say SendSMS , that will trigger SMS.


 Now we can send SMS as we have Phone number and Message Body,
 There are certain API available for this, i am using way2sms for this purpose,

 API for way2sms :
 apikey, unique key for user
 secret, unique key for user
 usetype, stage or Production
 phone, Number to send SMS to
 message, Message body

sample Request : http://www.way2sms.com/api/v1/sendCampaign?apikey=UO9EWGKEQI2YQA5BSCRJHT5TUXHORPP8&secret=UX93MQ92VIBTCGY7&usetype=stage&phone=999670002&message=HelloRahul"); 

Paramteterized Request : PhoneNumber and Message passed in Request as variable

http://www.way2sms.com/api/v1/sendCampaign?apikey=UO9EWGKEQI2YQA5BSCRJHT5TUXHORPP8&secret=UX93MQ92VIBTCGY7&usetype=stage&phone="+ PhoneNum +"&message"+ SMSBody;

now we can call Siebel EAI Transport to Hit the URL ,


 sendSMS(SMSBody,PhoneNum)

 ///SMS//////

var k = "https://smsapi.engineeringtgr.com/send/?Mobile=***67753*2&Password=able&Message="+SMSBody+"&To="+PhoneNum+"&Key=RAHULVsG7AhXF0bnm2uz";

var EAISiebelAdapter = TheApplication().GetService("EAI HTTP Transport");
var Inputs = TheApplication().NewPropertySet(); var Outputs = TheApplication().NewPropertySet();
Inputs.SetProperty("HTTPRequestURLTemplate","https://smsapi.engineeringtgr.com");
Inputs.SetProperty("HTTPRequestBodyTemplate",k);
Inputs.SetProperty("HTTPRequestMethod","POST");
//Inputs.SetProperty("HTTPContentType", "text/xml; charset=UTF-8");
EAISiebelAdapter.InvokeMethod("Send", Inputs , Outputs);
 ////sms end////TheApplication().RaiseErrorText( "SMS  "+ SMSBody +"  sent to user  with Phone Number  "+ PhoneNum);*/return (CancelOperation);
 }
 return (ContinueOperation);}


 Note:
 1. ALT + F9 is default command to Open Send Wireless Message applet
 2. SMS API depends on the client, as i have chosen free demo from way2sms, working with different API ,might require different code
 3. By Default there is Option of Pick Recipient which Open a Pick applet for choosing recipient first, before navigating to Send SMS Applet, this is default behavior and can be overridden with below steps (will share detailed solution in later post)

  •   Open The User Property for the BC
  •   Search for Enable Recipient in User Property
  •   Disable and Compile/Deliver




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


Siebel Auto Complete Functionality :- Part 2

Hello All ,

This post is continuation of post Autocomplete in Siebel ,in this post i have tried to remove the dependency of 3rd party Files as it has its own Encapsulated classes and methods which we could not control much.

So in this post lets try to achieve the functionality using native siebel jQuery Framework,


  • jQuery function autocomplete() can be used to bring the feature , since its native siebel jQuery Framework we need worry about the layout or CSS


  • Source , the source is the data set from which the searched value appears in drop down source has 2 components , Request and Response 


 Code snippet that does the magic :-)

Define source to hold the Suggestions/Options for auto fill, is a Array of keywords as below,

var tags = [ "AAKASH", "ABHISHEK", "MOHIT", "ROHIT", "BHANU", "PRITAM", "RAHUL" ];

 Define function that reads the user input and searches the source using RegExp function of jQuery.

$( '.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 );
          }) );
      }
});


Working Code ,

video here,



























PR File ,

if (typeof(SiebelAppFacade.AutoComplete) === "undefined") {
 SiebelJS.Namespace("SiebelAppFacade.AutoComplete");
 define("siebel/custom/AutoComplete", ["siebel/phyrenderer"], function () { SiebelAppFacade.AutoComplete = (function ()
{
 function AutoComplete( pm )
{ /* Be a good citizen. Let Superclass constructor function gets executed first */ SiebelAppFacade.AutoComplete.superclass.constructor.call( this, pm );
 }
 SiebelJS.Extend( AutoComplete, SiebelAppFacade.PhysicalRenderer );

 /// bind events function
 AutoComplete.prototype.BindEvents = function(){ SiebelAppFacade.AutoComplete.superclass.BindEvents.call( this );
 var tags = [ "AAKASH", "ABHISHEK", "MOHIT", "ROHIT", "BHANU", "PRITAM", "RAHUL" ];
//////bind Autocomplete with all the text area fields //////
 $( '.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"; });
 }

In my next post i will try to extend this to read the data from Siebel Database then manually passing in variable.


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...