functions expression rules

Certified Senior Developer

for example, I am having 10 questions in my DB  for that each question has a unique question id

If I enter 5 then 5 question id  should be come randomly help me out on this 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    My quick solution is to fetch all the IDs from DB, then randomly remove items until only 5 are left.

    a!localVariables(
      local!dbIds: {3,7,42,6,9,13,123,45,889,657},
      reduce(
        rule!TST_RemoveRandomItemFromList(_,_),
        local!dbIds,
        enumerate(5)
      )
    )
    
    TST_RemoveRandomItemFromList(
      list(Integer Array),
      dummy(Integer)
      
      remove(
        ri!list,
        ceiling(rand() * count(ri!list))
      )

Reply
  • 0
    Certified Lead Developer

    My quick solution is to fetch all the IDs from DB, then randomly remove items until only 5 are left.

    a!localVariables(
      local!dbIds: {3,7,42,6,9,13,123,45,889,657},
      reduce(
        rule!TST_RemoveRandomItemFromList(_,_),
        local!dbIds,
        enumerate(5)
      )
    )
    
    TST_RemoveRandomItemFromList(
      list(Integer Array),
      dummy(Integer)
      
      remove(
        ri!list,
        ceiling(rand() * count(ri!list))
      )

Children