RANDOM Function

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
joftech
Posts: 117
Joined: Thu Oct 19, 2006 10:42 am
Location: Sydney
Contact:

RANDOM Function

Post by joftech »

Hi Support,

Could you please tell me the context for using the RANDOM function.


I tried Gift.VoucherNumber = RANDOM as a rule but I keep on getting error messages.

I also tried a rule Gift.C= RANDOM(VoucherNumber)

This gives me the following error in testing mode
Operation error. com.bas.shared.ruleparser.ParseException Unsupported function RANDOM

Thanks

Alan
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

What sort of error messages are you getting when using Gift.VoucherNumber=RANDOM

(this is the correct usage)
Aware IM Support Team
joftech
Posts: 117
Joined: Thu Oct 19, 2006 10:42 am
Location: Sydney
Contact:

Post by joftech »

The error message i get is

rule ' ' uses business object 'RANDOM' which has not been found.

Alan
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

Try using Gift.VoucherNumber=RANDOM()

The documentation for this function is wrong - there should be brackets after the function.
Aware IM Support Team
joftech
Posts: 117
Joined: Thu Oct 19, 2006 10:42 am
Location: Sydney
Contact:

Post by joftech »

Hi Support,

That got rid of the error message. When I use it however I get only a value of zero.

What the client has asked for is that the gift voucher numbers get generated randomly ( dont ask why as I think they dont know either)

Alan
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

What is the format of the Gift.VoucherNumber attribute?

The default format (#) corresponds to integer - this could be the reason why you always getting zero, since RANDOM returns a double value in the range 0 - 1. For example, 0.124342. So the result is then rounded to the nearest integer which is zero.

So you need to either set the format of the attribute to be double (for example, #.##) or multiply the result by some factor.
Aware IM Support Team
joftech
Posts: 117
Joined: Thu Oct 19, 2006 10:42 am
Location: Sydney
Contact:

Post by joftech »

Hi Support,

You were right. One i changed the formate to #.00000 etc it worked.

Thank You

Alan
bazar2009
Posts: 75
Joined: Thu Mar 26, 2009 8:20 pm

Post by bazar2009 »

I noticed that the documentation is still wrong for the RANDOM function. I had to search the forum because I ran into the same exact problems as joftech.

It would be helpful if the text in the rule editor would display that the brackets () are required for the function to work (or have them automatically display when the RANDOM function is selected) and that the attribute should be a double.
Post Reply