You are viewing limited content. For full access, please sign in.

Question

Question

Can a field drop down list be sorted in ascending or descending when populated via the Append List Field Choice WF activity?

asked on July 21, 2014

I'm running into an issue where I am populating a field drop down list using the Append List Field Choice wf activity. It seems that it won't take the value that is appended and include it as a sorted value... just adding it to the bottom of the list. I have selected the Ascending button multiple times and every time that I run the workflow to add a value, it gets set back to  None. 

 

I'm not sure if this is a technical issue, non-supported functionality, or if I am missing some critical configuration point. 

 

 

 

 

3 0

Answer

APPROVED ANSWER
replied on July 21, 2014

The list field values and their order (list position) is stored in the lup table in the database. The sort options that you see in the "edit list" dialog in the Laserfiche Administration Console performs a one time operation that will sort the current list values with the specified option.

 

When Workflow is used to append list field choices, it does just that (adds it to the bottom of the list).

 

You can manually go back into the Administration Console and re-sort the updated list values.

 

A possible alternative is to use an external table instead of a built-in Laserfiche list. Create an external table that you use Workflow to update with the new values. Then you can configure the field in the template to be a dynamic field (even if it's only one field) and map it to the external table and column specifying the ascending sort order.

2 0

Replies

replied on July 22, 2014 Show version history

Justin,

 

If you opt for a workflow only solution, you're missing 2 programs you can easily implement through SDK activities, namely:

 

> retrieve the content of a list field

> clear the content of a list field

 

Then things get simple as:

1) retrieve the content of the list field in %(Token)

2) append new item(s) to %(Token)

3) clear the content of the list field

4) append %(Token#@SortAscending@#) to the list field

 

Take note that Laserfiche will enforce option 'Add blank to the list' even though %(Token) has no such value, so is the case (if I recall correctly) for duplicate values.

 

Invest in reusability: package your SDK activities into workflows!

3 0
replied on February 24, 2015

I threw together a simple SDK Script to handle this whole process. Could probably be improved a lot since I don't have too much experience with LFSO, but maybe this will help someone out.

 

protected override void Execute()
{
	// Fields to change
	string templateName = "<template name>";
	string fieldName = "<field name>";
	string newItem = "<new item>";

	// Connect to database (LFSO)
	ILFDatabase db = this.Database;
	LFTemplate temp = (LFTemplate)db.GetTemplateByName(templateName);
	LFTemplateField field = (LFTemplateField)temp.ItemByName[fieldName];
	List<string> listItems = new List<string>();

	// Retrieve existing list items
	bool cont = true;
	int i = 0;
	while(cont) {
		try {
			 listItems.Add(field.Item[++i]);
		} catch {
			cont = false;
		}
	}

	// Don't add if duplicate
	if(!listItems.Contains(newItem)){
		listItems.Add(newItem);
	}

	listItems.Sort();

	field.ClearDropDownList();

	// Add list items back to field
	i = 0;
	foreach(var item in listItems) {
		field.Item[++i] = item;
	}

	field.Update();
}

 

2 0
replied on February 6, 2018

Thanks for posting this, very helpful!

0 0
replied on July 22, 2014

'Sort Column' and 'Sort Order' yes

0 0
replied on July 23, 2014

Thanks to everyone for the suggestions!

0 0
replied on January 4, 2017 Show version history

Can anyone provide the c# code to add a new value to an existing List using the sdk.

 

Thanks

0 0
replied on January 4, 2017

Please do not post the same question in multiple threads.

FieldInfo FI = Field.GetInfo("Field Name goes here", RASession);
FieldItemList FIL = FI.GetItemList();
FIL.Add("new value goes here");
FI.SetItemList(FIL);
FI.Save();

(this code snippet user Laserfiche.RepositoryAccess and assumes you already have a connection to Laserfiche ("RASession").

0 0
replied on January 18, 2017

Thank you for your help. Sorry about that. I am kind of new to this and your example makes sense and it works. I see that I can call FIL.Remove to remove a value. However, just looking through the methods available, I dont see a method that allows updating an existing value. 

Thanks for your help in advance. 

 

 

0 0
replied on February 5, 2018

Following up on this. I tried switching to dynamic fields with the sort option, but having trouble using dynamic fields with Weblink. I tried implementing the very useful looking script provided here, however my Workflow SDK Script option does not contain a definition for this.Database. What is that?

I also found that the Workflow SDK script object is missing an important reference. LFSO90Lib, that solved all the other errors, but not the fact that there is no this.Database.

Am I working in the correct application or is this a conversation about performing this action from a custom Visual Studio application?

0 0
replied on February 5, 2018

Newer versions of Workflow use RepositoryAccess not LFSO for connecting to Laserfiche. So the reference to interop.LFSO90Lib is not added by default and this.database is not valid for an RA connection. You need to either switch your code to use RA or your script class to SDKScriptClass90 (instead of RAScriptClass102).

1 0
replied on February 6, 2018

Oh, very good, changing the base class works! I would use RepositoryAccess, but it doesn't seem to include the same methods as LFSO, so everything would need to be re-worked. Thanks for this update!

0 0
replied on April 6, 2023 Show version history

When will the append list values activity come to Cloud.

The issue we are having is:

With dynamic fields we cannot filter columns by the values being populated with the lookup, because the lookup is dependent on a template. Columns being filtered is not aware of a template. So we cannot filter columns in the repo using values populated in a dynamic field.

None of the other options are available in cloud. (ie. SDK, alter lup etc)

 

However, this activity also needs enhancements to allow removing a value and sorting by alpha for this to be effective.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.