In a application composed by many screens, I need to populate some fileds with default values.
The same also as Search parameters.
For example take a CRM application: A the begin of the User session, he/she put in an entity some values, as for exampe Customer code, Agreement data, etc.
Next, every screen that he/she open, at the begin the program get the default values for Customer code, Agreement data, etc from the above entity and puts the data in the appropiate fields.
If there is a browser screen, before to show the screen, in the Search fields the program puts Customer code, Agreement data, etc. in the filter fields.
Please, anyone can address me to some example to do that ?
I think that the easyest way is to popup a screen after user login and save default values in user session. Than, in other screens check if values are set în usersession and populate fields în current screen.
I am writing from my mobile, look for get usersession source and set parameters în the forum.
Do you always just want to set default values for a single entity, but for all instances that get created, or do you have multiple entities that have similar attributes where all of them should be populated with the default vaules?
Perhaps you cab share a sample domain model that illustrates the situation better.
I made it quite a complete example because it seems there is potential to create an application component out of it.
CUBA example: Default Values for session
This example shows how to define default values for a given user. Those default values will be used in other screens where those values can be placed into.
Example:
A Customer has an attribute name. In the default values screen a global name attribute value can be entered (e.g. “Fred”). For every invocation of the customer editor screen, the name field of the Customer will be set to the value “Fred”.
The Order and an Invoice entities both have values for dueDate and customer. In the default values screen a global dueDate and customer attribute value can be entered (e.g. “01/02/2019” & “Customer: Fred”). For every invocation of the invoice and order editor screen, the dueDate field will be set to the value “01/02/2019” and the customer field will be set to the value “Customer: Fred” .
How it looks in action
How to use it
In order to use it the following steps have to be taken:
In the DefaultValues interface an additional field has to be registered: `String ASSIGNED_TO = “defaultValue-assignedTo”;
add an additional field to default-values-screen.xml defines which default values are possible for the application: <pickerField width="100%" id="assignedToField" metaClass="sec$User" caption="msg://user"/>
register new field in ApplicationDefaultValuesScreen in the init method like this:
Other tahn populate edit screens in the application, my use case require also that if there is a browser screen in the Search fields I need to put default values.
So the subseguent searches are limitated by the parameters setup as default vaues.
If I understand you right you need to set default filter with some values in it. It is possible to do with the Generic Filter component in no-code way - learn more about features of the Generic Filter here.