This project has moved. For the latest updates, please go here.

Error generating NameValueList

Coordinator
Aug 3, 2011 at 1:56 PM

I was generating a NVL and got the following error:

Failed:

Property: ObjectID on criteria: CriteriaObjectID must have a ParameterValue. Ignored.

Why?

Coordinator
Aug 3, 2011 at 2:40 PM
Edited Aug 19, 2011 at 2:05 AM

As I see it, NameValueList are helper objects that shouldn't be dynamic and thus shouldn't accept parameters. If you need two ways of showing  data on the same table you should have two different NVL. This way you can cache each one.

Say we are talking about the Users table and you want a NVL showing only active users and another showing all users, irrespective of their active status. You should have two NVL:

  • AllUsersNVL
  • ActiveUserNVL

Back to the point, CslaGenFork isn't expecting ANY parameter value on the Criteria Properties collection. If you create your NVL using the creation gestures from Schema Columns panel, the default behaviour as set on the Add default Criteria to NameValueList ... option, is to create an empty Criteria. This means a Criteria with no Criteria Properties.

NOTE - This option is on the Project Properties panel, tab Creation and sub-tab General Defaults

The tooltip for this setting says (or should say, in fact it is misplaced)

If checked,
- ReadOnly collections and Name Value lists are created with a parameterless Get Criteria;
- EditableRoot and DynamicEditableRoot collections are created with a parameterless Create and Get Criteria.

But you can still add a kind of "minor" parameter to NVL, in case you want to restrict the data in the table always the same way. Of course you could use a different stored procedure for each NVL. This is just an alternative. How do you do that?

  1. Edit Criteria Properties and add a property (say IsActive)
  2. Bind it to the database column Users.IsActive
  3. Fill the Parameter Value according to dta type in Property Type (in this case it should be true for getting a list of active users or false for obtaining a list a inactive users )

Et voilá! You can use the same Stored Procedure, but in this case the SProc is passed the Parameter Value and returns a different result according to that value.

CGF won't check if Parameter Value is correctly filled; it just checks it is filled. If you forgot to fill it, you receive the error report above.


Rule

On NameValueList only use Criteria Properties when you need to pass the Parameter Value to the SProc. Otherwise, don't use Criteria Properties.


POST SCRIPTUM - For more demanding scenarios, you can use ReadOnlyObject/ ReadOnlyCollection, for instance when you need a tree combo box.

Coordinator
Aug 9, 2011 at 11:18 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.