How to generate random number in siebel

Requirement: to generate non-repetitive random numbers

eScript

1. Approach: Clib.rand()

var temp = Clib.rand();
TheApplication().RaiseErrorText(temp);

But this function do not guarantee the non-repetitive output.

2. Approach: new Date().getTime()

var aDate = new Date().getTime();
TheApplication().RaiseErrorText(aDate);

This method returns the date-time, in milliseconds, of the Date object. It's always incrementing.

3.Approach: using vanilla SIS OM PC Service


SIS OM PC Service is a vanilla service which provides a method to get new system generated row id as output.
The output can be utilised to generate random number by calling RowIdToRowIdNum() in expression.

Workflow:









Step 1 : Service :SIS OM PC Service Method: Get Next RowId
Output: Next Row Id

Step 2: Service: Workflow Utilities
Output : Random Num [Type Expression] : RowIdToRowIdNum([&Next Row Id])


Sometimes data coming in inbound integration from external system cannot be uniquely identified.
One of the options is to use "SIS OM PC Service" business service in datamaps and the generated output row_id could be used as user key during the insertion. In the field map following expression is used:

InvokeServiceMethod("SIS OM PC Service", "Get Next RowId", "XYZ='12'", "RowId")

This might result in error "Access denied to invoke business service 'SIS OM PC Service' for search specification 'InvokeServiceMethod("SIS OM PC Service", "Get Next RowId", "XYZ='12'" ,"RowId")'" . This error is related to security issue. In order to use any business service with InvokeMethod we need to define that business service at following places:


1 - Mobile Web client/Dedicated client: In CFG we need to define following parameter
[Siebel]
BusinessServiceQueryAccessList = SIS OM PC Service

2 - Web Client: We need to define this in Parameter "Business Service Query Access" at enterprise or component level where it is being used.
Name: Business Service Query Access
Value: SIS OM PC Service


Source:
http://exploringsiebel.blogspot.com/2009/09/how-to-generate-random-number-in-siebel.html
http://exploringsiebel.blogspot.com/2010/08/generate-random-number-cont.html

Comments

Popular Posts