September 7, 200619 yr Hi guys, I want have a portal with 5 random child records in it. Nothing to fancy, I've come up with a couple ideas on how to do it, but niether really give me that warm fuzzy feeling: 1. Sort the portal on a value list. The value list will a field with randon data in it. Then have the portal only show 5 records. Not sure if that will work nice or not. 2. Have a field in the child records have a random field and sort the portal on it. Again showing 5 records only. The problem is the random field needs to be generated on every record all the time. Anyone got a better way(s)?
September 7, 200619 yr A calculation like: GetNthRecord ( Child::ChildID ; Ceiling ( Random * Count ( Child::ChildID ) ) ) could pick a random ChildID for a key field in the Parent. The problems are that (a) being an unstored calculation, it would revaluate on every scren refresh, and ( you need 5 UNIQUE ID's. I think I would populate the key field by a script: Set Field [ Parent::ScriptedKey; "" ] Loop Exit Loop If [ ValueCount ( Parent::ScriptedKey ) ≥ 5 ] Set Field [ Parent::ScriptedKey; Let ( item = GetNthRecord ( Child::ChildID ; Ceiling ( Random * Count ( Child::ChildID ) ) ) ; Parent::ScriptedKey & Case ( IsEmpty ( FilterValues ( item ; Parent::ScriptedKey ) ) ; item & ¶ ) ) ] End Loop
Create an account or sign in to comment