cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

Cisco Community Designated VIP Class of 2020

258
Views
0
Helpful
2
Replies
Highlighted
Beginner

Is there any way to generate random number in CPO

Requirement : -

> I want  to generate a random number from set of 1-9 numbers .is there any way in cpo ?

Thanks

Siva

Everyone's tags (6)
2 REPLIES 2
Cisco Employee

Is there any way to generate random number in CPO

Yes, write a VBScript function to do such. (using the Execute Windows Script activity)

Here is the one I use:

Set arrArgs = WScript.Arguments

min = arrArgs.Item(0)

max = arrArgs.Item(1)

Randomize

Wscript.Echo INT((max-min+1)*Rnd+min)

Feed it two inputs, Min and Max as variables. Then the output of the script is the random number.

-shaun

--Shaun Roberts
Technical Leader, CX
shaurobe@cisco.com
Enthusiast

Is there any way to generate random number in CPO

I created a process that uses 3 steps, all of which happen inside the engine rather than having to span out to a script, so it runs a lot faster.

Technically, it's pseudo-random...

Predefine Output Variable "Random Number" as type "Numeric"

Step 1:  Format Date

  Format string: fffffff 

    (that's seven lower-case letters "f")

  Original date: [Process.Start Time]

Step 2: Format Date

  Format string: ff\0\0\0\0\0

  Original date: [Process Start Time]

Step 3: Set Variable

  Variable to update: [Process.Variables.Output.Random Number]

  New value: ([Workflow.Format Date.Formatted Date]-[Workflow.Format Date (2).Formatted Date])/100000

This returns a basically random number between 0 and 1 (so you can mulitply it by your maximum value) based on the numeric fraction of a second of the start time of the process.

CreatePlease to create content
Content for Community-Ad
FusionCharts will render here
This widget could not be displayed.