falkaholic Posted September 7, 2006 Posted September 7, 2006 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)?
comment Posted September 7, 2006 Posted September 7, 2006 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
falkaholic Posted September 8, 2006 Author Posted September 8, 2006 thanks! I'll try something like that.
Recommended Posts
This topic is 6709 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now