Display the occurances in a multi-value field
Oct 20, 2009
http://www.bleedyellow.com/blogs/DominoHerald/entry/display_the_occurances_in_a_multi_value_field8?lang=en_us


 I have been working on an application and one of the requests was to let 4 different business segments each select a number of suggested countries. Once this was done someone would review it and decide which countries to engage in. Each of the business factors could select a country only once (not a problem) but the reviewer needed to be able to see which ones where selected most frequently. Ordinarily, I would use a view with categories and view totals and be done. But there was a kicker - the reviewer needed to see based on which ones where selected most. Views would have "Albania" at the top and "United Kingdom" at the bottom even if Albania got one vote and the UK 4. So I had to sort based on frequency, and view totals won't do that. 



I am taking all the entries from the response documents and putting them in the parent, so I have a multi-value field with all the entries appended. Then I do an @Sort and they are all alphabetical order. I then wrote a script to take each entry in the multi-value field, and compare it to the next. If they are the same, I increment the counter up one and go to the next value. If different, I put this in a new array with a tilde separating the country form the counter. I put this into a field then use a computed for display field and @ReplaceSubstring(freqNations;"~"; "   ") to display like this: 



image







So the user sees a list by frequency*. Much easier for the user and they think you're doing something really spiffy. I used Julian Robichaux's Shell Sort to organized after I get the counter. It's doing something weird to the "A" entry (as you can see). I think that's because I've reversed one sort and I'll check into that.





Except for this one alphabetical bug, this is working very well, and I think I'll be using it more  in the future. Here is the code, in case you'd like it. 





Cheers,



Brian

 

Add a Comment 
More Actions 
Comments (2)


1 Roy Rumaner commented Oct 20 2009 Permalink Recommendations 0
When are you updating the parent document? Do you do it each time an entry on the response is made or is there a scheduled agent processing them?


2 Brian M Moore commented Oct 22 2009 Permalink Recommendations 0
I update the parent document each time a response document has the "Submit" button clicked. This is because, for this workflow, the people completing the response docs may change their mind over the review period, and the overall reviewer needs to see how things are 'shacking out' during the process. It could be done PostSave or via a scheduled agent depending on the needed workflow. Since the process here only has 4 possible responders, doing it via the UI isn't a major drag.

 


Cheers, 
Brian
This is an archive of my previous blog http://www.bleedyellow.com/blogs/DominoHerald attachments are in the download control