cancel
Showing results for 
Search instead for 
Did you mean: 

How to use SmartField with value help on default oDataModel to create new entity?

axeldion
Explorer
524

Hi,

I have my default oDataModel defined in my manifest.json as "". This oDataModel has a entity called "ZC_MAINT_ZLABELS_PRINT" with some properties. 1 of these properties is Plant and has a value help defined in CDS (RAP).

I want to put a SmartField in my application for property Plant (So I don't need to create a value help myself):

<form:SmartForm id="idNewLabelSmartForm" class="editableForm" editable="true"> <form:Group id="idNewLabelGroup"> <form:GroupElement id="idNewLabelGroupElement"> <smartField:SmartField id="idPlantNewLabelprinterSmartField" value="{Plant}" entitySet="ZC_MAINT_ZLABELS_PRINT"/> </form:GroupElement> </form:Group> </form:SmartForm>

Now when I select a value from my value help or enter a value in the SmartField directly it is cleared automatically and my SmartField is empty again. How do I fix this issue? In the sample code ".bindElement(/abc)" is executed but this is something I cannot do as the entity does not exist yet.

Thanks!

View Entire Topic
AlexNecula
Active Contributor

Hi,

Try to use the method createEntry of the model. It returns a context that you can bind.

The field values will be updated automatically by the smartfields so you will only have to call submitChanges() when pressing Save.

Alex

axeldion
Explorer

Thanks! Resolved my issue