Can't clear previous results
Greetings. Within my Workflow I perform a "Select Features" and this works fine on the first iteration. If I run my workflow again, then all my previous results are appended to the new results which I don't want. I've tried setting the beginning of my workflow to an empty featureset to clear the results and that works until I get to the end of my workflow and the results are still concatenated. I've also tried setting "Clear Collection First" on my Select Features activity but after the first iteration if I run the workflow again I get a "Arg_NullReference Exception". I can't even seem to catch this exception in a Try/Catch, I've tried every possible exception. At any rate, please let me know if y'all have any ideas how I can just clear the results after every workflow run. Many thanks
-
Add a Run External Command activity, command name "ClearSelection".
0 -
I must have tried nearly every "Clearing or Removing" RunExternal command I could think of except...... "ClearSelection". Thanks that solved my issue.
0 -
First of all, I am not sure why 'Clear Selection' command fixed the error Josh originally have it since it does the same job with 'Clear Colleciton First' = True when no CollecitonName is configured on SelectFeatures activity used.Anyhow if it has been fixed, it is good.
However, I would like to leave some comments on this since 'SelectFeatures' activity is powerful one to set the EsriFeatureSet to the Gcx Results to either 'NamedCollection' or 'DefaultCollection' (check the help document for the SelectFeatures activity in the workflowdesigner), and also there are some commands associated with those NamedCollection and DefaultCollection.
(1) When 'Collection Name' is configured on SelectFeatures, the featureset goes to the NamedColleciton object whose id is 'CollectionName' on the GVS, while 'Colleciton Name' is empty, the featureset goes to the DefaultCollection.
(2) 'ClearSelection' Command does clear out all features from the 'DefaultColleciton'
(3) 'ClearResults' Command does make the ActiveColleciton empty, where ActiveCollection is what you see on the GVS' result panel (either from Default Colleciton with yellow star next to the feture or from NamedCollection. FeatureSetManager manages both NamedCollection and DefaultCollection. So 'ClearResults' does not remove NamedCollection from the FeatureSetmanager, but make them empty. Therefore when you add new features to the same NamedCollection, it is added to the existing ones. There is requested defect item about 'ClearResults' command to clear NamedColleciton too. However, you can overwrite that command with your implementation until the GVS support.
(4) NamedCollection are managed to the history of the Results to on the GVS.
(5) 'SelectAllResults' command removes all features from the ActivieColleciton
(6) 'RemoveCollectionById' removes the NamedColleciton from the FeatureSetManager.
(7) 'AppendToDefaultCollecitonById' command to append all featurs on the Default Colleciton to the NamedColleciton matched its ID (collectionName).
Having said, this is what I mostly implements the workflow whenever I used the SelectFeatures:
(1) Execute 'RemoveCollectionById' with commandParameter with CollectionName which I will use on SelectFeatures below, and 'ClearSelection' command to clear out all previous result. These two commands can be put as Parallel to reduce to traffic between server and client.
(2) .. do someting to get FeaturesSets, which can be from the QueryTask etc.
(3) Use 'SelectFeatures' with 'CollectionName' with 'ClearCollectionFirst' = False since I already called 'ClearSelection' command before. If you are dealing with only one kind of FeatureSet, you can set this True, but you don't need to call 'ClearSelect' command. Josh, that is why I don't understand how 'ClearSelect' resolved your issue. The reason I set 'CollectionName' is to put the featureset to the NamedCollection so that I can keep the history. By the way, with GE 4, there are some new In Arguments on 'SelectFeatures' so that you can set/overwrite 'Description Format' or 'Long Description Format' with which it can overwrite whatever the Layer's feature description and long feature description configuration.
(4) To put the featureset to the default Default colleciton, you can use either 'SelectAllResults' which is not suggested command list on RunExternalCommand for your information, or to use 'AppendToDefaultCollecitonById'
There are lots of performance improvement on 'ClearSelection' command on GVS 2. Before GVS 2, that command suffered lots of speed to complete its job depending on the number of features on the defaultCollection.
Wish this can help someone understand more.
0 -
Set the Clear Collection First parameter to True in the Select Features activity in your workflow.
0
Please sign in to leave a comment.
Comments
4 comments