Populating Criteria values (non-AutoSearch fields)
I would like to be able to populate criteria fields with with a key value...
say customer_id in the case of a customer report. I am using and end-user
solution with some custom data views and the user has the ability to create
their own.
What I would like to be able to do is if they create a criteria field that
is equal, mandatory and not auto-search then I will fill it in for them.
I know you can do this in code by iterating through the SQL.Criteria list
and locating the field and populating it etc, etc.
But it seems you can only do this when you have auto search criteria set up
and you can use the report events of GetAutoSearchValues or
[Before]/AfterAutoSearchDialogCreate.
Or the other option is to get the reports DataModule.DataViews[0].SQL object
and change it there (or possibly all instances of a customer_id criteria
field in many dataviews). All well and good.
How do you do this if you want to change the customer_id criteria if it is
the only criteria (no autosearch fields) and you don't want to over-right
the Report dataviews OnBeforeGenerateSQL event in the case where it might be
a custom dataview created by the developer with OnBeforeGenerateSQL code
writtin in the dataview that you still want to run.
Any suggestions?
Jarrod
say customer_id in the case of a customer report. I am using and end-user
solution with some custom data views and the user has the ability to create
their own.
What I would like to be able to do is if they create a criteria field that
is equal, mandatory and not auto-search then I will fill it in for them.
I know you can do this in code by iterating through the SQL.Criteria list
and locating the field and populating it etc, etc.
But it seems you can only do this when you have auto search criteria set up
and you can use the report events of GetAutoSearchValues or
[Before]/AfterAutoSearchDialogCreate.
Or the other option is to get the reports DataModule.DataViews[0].SQL object
and change it there (or possibly all instances of a customer_id criteria
field in many dataviews). All well and good.
How do you do this if you want to change the customer_id criteria if it is
the only criteria (no autosearch fields) and you don't want to over-right
the Report dataviews OnBeforeGenerateSQL event in the case where it might be
a custom dataview created by the developer with OnBeforeGenerateSQL code
writtin in the dataview that you still want to run.
Any suggestions?
Jarrod
This discussion has been closed.
Comments
You should extract the dataviews in code. You can eliminate the custom
dataview templates by checking the class type of the dataview when it is
extracted. If it is not a custom dataview class, then you can extract the
criteria field and see if their Autosearch property is set to false and it
is Mandatory and the Operator is dacoEqual. Then you 'll know that this
dataview's criteria field can be programatically updated with the
customer_id key value.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
What seems to be happening though is that when I set the customer_id value
it gets saved with the template. So the next time around when I am checking
for a blank value it is not populating with the new customer_id. Anyway
around this?
Jarrod
Yes, it will save this criteria value in the template. In the
Report.Template.OnSaveStart event, you can locate the search field that you
changed earlier when the template was loaded. Then clear the value out so
that it will get saved with no value associated with it. Now the next time
the report is loaded, the criteria can be assigned any new value you desire.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com