AnsweredAssumed Answered

Help with giving people a position number

Question asked by duncanbaker on Aug 11, 2014
Latest reply on Aug 11, 2014 by duncanbaker

Hey folks

 

I'm trying to work through an issue. I have a list of people records and I want the user to assign them numbers - the layout shows the list of people and there's a blank field next to each name to put the number. Consider it a top ten or starting order or whatever. In the end, it's not possible for two people to have the same number.

 

So, the user adds numbers to the first 5 people in whatever order. There's a button named 'sort' (we'll come back to that but it runs a script, it's not just the main sort button) which resorts the records and shows him the list of names in number order (and any additional non-numbered names are under those in alphabetical order). If he decides that position number 5 should now be position number 2, he changes that number. Until 'sort' is hit, we now have two number 2's in the list. When 'sort' is hit, I am essentially looking at all the relevant records, sorting them by the assigned position number and then by modified timestamp (descending). Looks like this

Name Position Modified

Jon 1 5.19

Tim 2 5.20 - this was number 5

James 2 5.19

Bob 3 5.19

Andy 4 5.19

 

I then loop through the records and reset the position number, starting at 1 and so on. Now the list looks like this:

Name Position Modified

Jon 1 5.19

Tim 2 5.20 - this was number 5

James 3 5.19

Bob 4 5.19

Andy 5 5.19

 

This is fine. (I guess all the modified stamps would have updated too). BUT, if a user decides position number 2 should be position number 4, this is what we get after the sort by assigned number & modified:

Name Position Modified

Jon 1 5.19

James 3 5.19

Tim 4 5.20 - this was number 2

Bob 4 5.19

Andy 5 5.19

When the reset of position numbers happens, Tim will be 3 not 4.

 

I did have this happening on field exit per record, was grabbing the old number before it changed and then adjusting the modified sort order to ascending if the new number was greater than the old. But, that was proving too slow, so I want this all to happen on layout exit or when the 'sort' button is hit by the user. And multiple position numbers could be changed higher or lower prior to the user resorting the list with the button.

 

Any ideas on how to accomplish this? I've thought about maybe grabbing the old position number and setting the value to a hidden field and possibly using this during the process but not figured out how yet. Needs to be FMGo compliant. There might be a completely different way to approach the whole thing, which I am open to.

 

Thanks

Outcomes