Showing posts with label Configuration. Show all posts
Showing posts with label Configuration. Show all posts

Saturday, April 14, 2012

Export data into an Excel File using escript


In fact, there are different ways to export a excel file from Siebel. Anyway, this time, let’s focus on using scripting as a tool to extract accurate information from Siebel, which is also easy to implement through COMCreateObject.

 First of all, let me say, that in the most cases are no need of adding lots of scripting in Siebel. In other words,   be aware of a “out-of-the-box” solution instead of code, for many reasons well known, such as reduce maintenance cost, easier way to upgrade, and so on.

After said this, here’s a list detailed step by step the most common points, which you would do well to follow:

  • Create the Application Object: 
          COMCreateObject("Excel.Application")
  • Make Excel visible through the Application Object:
          ExcelApp.Visible = true;
  • Open a File using the Open Method on the Application Object:
          ExcelApp.WorkBooks.Open(fileName);
  • Insert data in a concret Cell:
          ExcelApp.ActiveSheet.Cells(1,1).Value = "Value:";
  • Close Excel using Quit Method on the Application Object:
          ExcelApp.Application.Quit();





Once implemented, we could use the business service simulator to invoke Write_To_Excel method, so navigate to Administrator – Business Service > Simulator:




Finally, as a result, bellow it’s shown that we fill data into worksheet cells from three different sheets:



Hope it helps!
Arreveure.
Joan.


Usefull expressions:

=SIERROR(CONSULTAV(D3;A:A;1;FALSO);0)

 



Monday, March 22, 2010

Read only field can be accessed from script

If you want to modify via script a “read-only” field, in Siebel 7.7 don’t works. To avoid this we should do:

BusComp.InvokeMethod("SetAdminMode", flag)

Argument

flag

Description

"TRUE" or "FALSE". Flag to specify whether the business component should be executed in Admin mode.

In order to allow visibility rules for the business component, it’s required to set the flag to TRUE before of SetFieldValue (then it’s required to set the flag to FALSE).


For instance:

function WebApplet_PreInvokeMethod (MethodName){

if (MethodName =="Sample"){
[...]
BusComp.InvokeMethod("SetAdminMode", "TRUE");
BusComp.SetFieldValue("Example_Read_Only_Field","Example");
BusComp.WriteRecord();
BusComp.InvokeMethod("SetAdminMode", "FALSE");
[...]
}
return(ContinueOperation);
}

Thursday, March 18, 2010

Usage of InvokeServiceMethod() on Calculated Fields

In order to achieve complex requirements, we can invoke Business Service scripts from within the Calculated Fields (in Siebel Business Component).

First of all, I would like to emphasize that each calculated field is evaluated whenever the business component is queried, that means that impact performance. Moreover, scripts aren’t recommended as Siebel Best practices. Anyway, in certain contexts his usage is required.

Technical Configuration

Function:
InvokeServiceMethod (name, method, context, returnProperty)

Description:
Returns the value of the return property from the returnProperty set of the specified business service, after invoking the method with the context.

For Example:

InvokeServiceMethod ("BusServ", "PersonalizationMethod", "I_Id=" + [Id] + "," + "I_Date=" + [Created] ,, "ReturnProperty")

invokes the business service method PersonalizationMethod in business service BusServ, passes it the context I_Id=’Id’,I_Date=’DD/MM/YYYY’, and returns the value set by the business service in the property ReturnProperty.





Following is a sample code snippet (Business Service: BusServ):

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{

switch (MethodName)
{
case "PersonalizationMethod":
Example (Inputs, Outputs);
return (CancelOperation);
break;
default:
return (ContinueOperation);
break;
}
}

Where:

function Example (Inputs, Outputs)
{
var Id = Inputs.GetProperty("I_Id");
var Date = new Date(Inputs.GetProperty("I_Date"));
[...]
Outputs.SetProperty("ReturnProperty", Return);
}

Hope this helps!

Monday, March 1, 2010

In Siebel Tools, create a new workflow for linking a file from an external application

First of all, this process lists all the files that there are in a Siebel Server as a result of an integration between Siebel and an extenal application, a sentence such as:

Clib.system("cmd /c dir /B C:\\Prova_joan\\* > C:\\Prova_joan\\joanprova1.txt");

In order to treat files, I try to read each path:

flist=Clib.fopen("C:\\Prova_joan\\joanprova.txt","rt");
Clib.strncpy(destString [i], sourceString , maxLen);
Clib.fread(Caracter,UWORD8,flist);
Clib.fclose(flist);

Finally, I use a sentence for renaming files, in order to tranfer a file from a directory to another directory:

var Source_Path = "C:\\Prova_joan\\"+ destString [i];
var Destine_Path = "C:\\Prova_Final\\"+Rename;
Clib.rename(Source_Path, Destine_Path );

In parallel, it was created a calculate field that once DDBB save a file name , then returns the path of this one (using string concatenation).