on 07-03-2019 11:22 PM
I have a datafield Country on a custom entity Customer. I have added the valuelist annotation to that field and made it fixed-values which all appears to work. However, when I create a new customer, I want the country to default to 'US'. Is there a way to set the default value in the DEFINE method of the MPC_EXT class or do I have to extend the Object Page of my List Report Fiori Elements application to set the default country?
what is your architecture?
i tried with cds+bopf, you just have to add a determination to set the default value, it can be easily done.
if you use odatamodel createentry, you can set the default value in the parameter, I didn't try.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are on a HANA 2.0 system, but we chose to use strictly Gateway Services without CDS (although I think we will eventually move to using CDS). Sadly, I could not find a way to accomplish pre-populating default values with the generated object page, so I chose to create my own UI5 application from scratch using a smart table and a smart form where I can do the necessary coding in the controller.
Hi,
Did you try this : https://ui5.sap.com/#/topic/11ff444f82e14eb3a2e8eca0065a5055
And look at here : https://answers.sap.com/questions/622321/how-to-use-default-value-annotation-for-input-para.html
Regards,
Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had looked at the first link and attempted to override getPredefinedValuesForCreateExtension(), but it was not clear from the documentation where that code needed to be - in the Component.js or in a Controller Extension?? Also, it appeared that it would only work with the createWithFilter setting, not the standard create screen. If you have seen a working example of this override, please point me to it.
I also attempted setting the metadata property for default value in the DEFINE method of my MPC_EXT class (I'm not using CDS). That metadata property doesn't appear to do anything. Here is the code I used for that:
me->model->get_entity_type( 'Customer' )->get_property(
'Country' )->set_default_value( lv_def_country ).
I didn't try the first link, in one project of mine, I wanted to do the same but with Field Control by default. The solution I found (it is a workarount) was to do a read() query with a specific key to return all default values during the creation process.
The second link is after looking at more deeply is to have default value during the search. So in your case it is not relevant.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.