on 2016 Mar 03 10:40 AM
Hello experts!
Currently, we use an extension collection as consecutively list. In our case each entry with cause will create a row with additional information about collaborator groups with read-write access in that table.
My questions are:
Best,
Heiko
Request clarification before answering.
Hi Heiko,
Didnt get your requirement.. but if you are looking to sort an extension collection based on the value of one of the columns then yes it can be done via scripting.
We had a requirement where we added custom approvers to contract documents, there were custom columns like "Approver Sequence" in this extension collection and the final approvers list had to be sorted based on approver sequence. I wrote a comparator class like this in the relevant script (top of the script before actual script logic starts):
//Comparator for sorting the custom approvers list
class CustomListComparator implements Comparator {
public int compare(Object o1, Object o2) {
appSequence1 = o1.get("CUST_APP_SEQ").getDisplayName();
appSeqInt1 = Integer.parseInt(appSequence1.trim());
appSequence2 = o2.get("CUST_APP_SEQ").getDisplayName();
appSeqInt2 = Integer.parseInt(appSequence2.trim());
return appSeqInt1 - appSeqInt2;
}
}
In the script, I copied the collection members to a java arraylist and passed it to this comparator to get back the sorted list like this:
//Add the custom approvers to java ArrayList for sorting
ArrayList customArrayList = new ArrayList();
for (member:iter) {
//Do not add empty rows in the ArrayList
if (hasValue(member) @and hasValue(member.get("CUST_APPROVER")))
customArrayList.add(member);
}
Collections.sort(customArrayList, new CustomListComparator());
Not sure if this was the best/cleanest solution but worked for us!
- Gayathri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Gayathri,
thanks for your answer We used your approach and modified it to our requirement. The sortation works within the array and everything seems to be correct.
Nevertheless, the sortation will be not reflected in the extension collection. Furthermore, we got an error message after we add/remove values with our test user. It says that we don't have the rights to edit the master agreement.
I want to ask you how the sortation can be reflected in the extension collection? Which additional step we have to do?
Thanks in advance,
Heiko
Hi Heiko,
Good to know you were able to use the comparator! I have not sorted my custom collection "in place" my requirement was to populate another custom collection based on consolidating and sorting values from other collections.. but I believe you can sort in-place also if you are coding for the right scripting event.. like Validate or Pre phase change.. what is the Target of your script?
- Gayathri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.