Showing posts with label Array Methods and Properties in Siebel eScript. Show all posts
Showing posts with label Array Methods and Properties in Siebel eScript. Show all posts

Tuesday 16 August 2016

Array Variable in siebel eScript

Hello All,

While working with siebel eScript I got a requirement to use array for storing some variables.
Arrays work like normal JavaScript variable in siebel the difference is just in the declaration and the dimension.
Below code describes how to use array.

Sample code looked like.


      var Result= new Array();

      for(var x = 1; x <= 5; x++)
      {  
        // Dynamically assign value in Array variable
          Result[x] = x;
          Outputs.SetProperty('Output'+x,Result[x]);                                                            
      }

the oputput of this will be,
Output1 = 1
Output2 = 2
Output3 = 3
Output4 = 4
Output5 = 5

we can also declare multiple dimensional arrays also,


      var Result= new Array();
// or we can explicitly specify multi dimensional arrays var Result= new Array(x,y);

      for(var x = 1; x <= 5; x++)
      {  
        for(var y = 1; y <= 5; y++)
         {
        // Dynamically assign value in variable
          Result[x,y] = x+y;
          Outputs.SetProperty('Output'+x+y,Result[x,y]);
         }                                                        
      }


the oputput of this will be,
Output11 = 2
Output12 = 2
...
Output21 = 3
Output22 = 4
...
Output51 = 6
Output55 = 10

we can create hierarchical property sets from the outputs depending on the format we are required to return output.

for Creating Hierarchical property sets refer the post http://www.siebelfoundations.com/2016/08/working-with-property-sets-in-siebel.html

Monday 15 August 2016

How to work with input of Array Type in Siebel eScript

Hello All,

Recently I had a requirement wherein I was getting multiple values in inputs and had to use the values one by one in my code ,perform some calculation till all values have been read from input.
The requirement can be summarized as, suppose we are given 5 Service Request number in input and we are required to perform some operation on each of them.

  • We need a way to read each Service Request number individually
  • We need to parse the input based on a delimiter

In my case I was getting the input in format as : 1-12345;1-34566;3-78686;9-09867
Multiple SR numbers separated by semicolon( ; ) as delimiter.

first i had to use Vanilla Business Service

BS : Inbound E-mail Manager 
Method : GetTokens

to parse input text and convert input string in multiple SR numbers.
For more information on this BS please refer bookshelf.
https://docs.oracle.com/cd/E14004_01/books/eMail/eMail_BusServMeth3.html

then, Iterate my code number of time and each time store the output in a variable, since the number of SR in input is not fixed i had to user arrays to dynamically store output.

Sample code looked like.
function Service_PreInvokeMethod(MethodName, Inputs, Outputs)
{
    if (MethodName == 'GetSRNumber')
     {
      var Result= new Array();
      var Status = "";
      var SRInput = Inputs.GetProperty("SRInput");
      var NumberOfSR = Inputs.GetProperty("NumberOfSR");
      var Token = "";
      var oService = TheApplication().GetService("Inbound E-mail Manager");                                    
      var oInputs = TheApplication().NewPropertySet();
      var oOutputs = TheApplication().NewPropertySet();

 // call BS to parse input to separate Numbers

      oInputs.SetProperty("Delimiter", ";");
      oInputs.SetProperty("NumTokens", NumberOfSR);
      oInputs.SetProperty("Text", SRInput);
      oService.InvokeMethod("GetTokens", oInputs, oOutputs);
      for(var x = 1; x <= NumberOfSR; x++)
      {
         Token = oOutputs.GetProperty('Token '+x);
        // Dynamically assign value in variable
          Result[x] = Token;
          Outputs.SetProperty('SR'+x,Result[x]);
      }
 }
 return (CancelOperation);
}


here, NumberOfSR is the count of SR's in Input which we require to separate to individual SR, Result is a array in which we are storing values of SR Number
expression Outputs.GetProperty('Token '+x) this expression iterates in the loop for each instance i.e. for x =1 it is evaluated as
 Outputs.GetProperty("Token 1")
and for subsequent values of x as
 Outputs.GetProperty("Token 2")
 Outputs.GetProperty("Token 3")
 Outputs.GetProperty("Token 4"), here we are dynamically creating the variable based in the number of times we need to run loop.

The same way we are dynamically assigning values in Array,
expression Result[x]  this expression iterates in the loop for each instance i.e. for x =1 it is evaluated as
Result[1] 
and for subsequent values of x as
Result[2] 
Result[3]
Result[4]  
.
The output of this is











we can then fetch the values of SR Number from output or we can use Property set to create Hierarchical outputs as well.

for Creating Hierarchical property sets refer the post http://www.siebelfoundations.com/2016/08/working-with-property-sets-in-siebel.html


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