Selecting a random item from a Global List
Hi. I searched around and didn't find anyone else doing this, but managed to figure it out so I thought I'd post a code snippet.
We wanted to randomly choose an Exchange database when provisioning a new mailbox, but still give the option to change it if needed.
I created a global list with the DNs of the Exchange databases. Added it to the approval form, then added the following code as an onload event:
exdbs = IDVault.globalList(null, "exchange-database")[0];
idx = Math.floor(Math.random() * exdbs.length);
form.select("exchangeDb", exdbs[idx]);
"exchange-database" is the name of the global list, and "exchangeDb" is the name of the form field.
Hope someone finds it helpful.
-james
|