Hi
We are using the function "Append List Field Choices" in a workflow, but the options of the field in which we insert are not reordered.
Is it possible to rearrange these options from Workflow?
Hi
We are using the function "Append List Field Choices" in a workflow, but the options of the field in which we insert are not reordered.
Is it possible to rearrange these options from Workflow?
Ricardo,
You can accomplish the sort by using the SDK Script activity and a few lines of code. Add an SDK Script activity below the activity where you are appending a list field choice;
Update the Execute method with this code. Note: In the code below the name of the list field is 'ListField'. When you update your SDK Script activity use the name of your list field;
protected override void Execute() { // Get a reference to the listField... FieldInfo fi = Field.GetInfo("ListField", this.RASession); // Copy the fieldInfo item list to a temp list... List<string> itemList = fi.GetItemList(); // Sort the list alpha ascending... itemList.Sort(); // Note: if you want to sort the list alpha descending then comment out // the Sort line above and uncomment the Reverse line below... //itemList.Reverse(); // Set the fieldInfo.ItemList to the newly sorted list... fi.SetItemList(itemList); // Perpetuate the changes... fi.Save(); }
The SDK script will sort the items in alpha ascending order. Note: If you want to sort the items in alpha descending order just comment out the Sort method and uncomment the Reverse method on the itemList object.