cancel
Showing results for 
Search instead for 
Did you mean: 

sap.fe.macros.Field - How do i get the base control (e.g: sap.m.Input)

smok1
Explorer
0 Kudos
338

G'day,

Can I know how do I get the inner control of the sap.fe.macros.Field control? (something like getInnerControl method for Smartfields). I did get the controlEdit function, however when i try to change the valueState there, it didn't work. 

The question is because I'm trying to programmatically reset the value for a sap.fe.macros.Field to blank/null after an error state is set by a value help validation (via annotations) as per this example. (https://sapui5.hana.ondemand.com/test-resources/sap/fe/core/fpmExplorer/index.html#/buildingBlocks/f...).

Using the context.setProperty method works only if the fields is not in a value state error. When i try to Message Manager to remove the error message and reset the value, it didn't work either.

@nicolas_lunet 

nicolas_lunet
Advisor
Advisor
0 Kudos

Hello smok1,

When the error was introduced following a value help / annotation validation, the expectation is that the user has to go in and manipulate the data to fix this.

UI5 models have a very deep integration with the error management / value state so the only way to resolve this is through the model as well.

Accessing the inner control is not something that we recommend / that we offer. Depending on the situation, the inner control may change, and we don't want to encourage code that relies on the internal structure.

What you should be able to try however is to use the `setValue` method to reset the value to `null|undefined`

View Entire Topic
smok1
Explorer
0 Kudos

@nicolas_lunet I've already tried setValue to '' or null (I'm assuming on the fe.macros.Field control itself) and it's not working either. 

nicolas_lunet
Advisor
Advisor
0 Kudos
Weird, I just did the following on this page
nicolas_lunet
Advisor
Advisor
0 Kudos

Weird,

 

I just did the following on this page https://sapui5.hana.ondemand.com/test-resources/sap/fe/core/fpmExplorer/index.html#/buildingBlocks/f...

Type 444 in Dynamic Field Control (Path Based) -> UI turns red

sap.ui.getCore().byId("sap.fe.core.fpmExplorer.fieldEdit::Default--FieldControlValue").setValue(0) -> all good again

Make sure you are on the FieldAPI when doing so 🙂

smok1
Explorer
0 Kudos
@nicolas_lunet I think the issue happens when the error comes out of a Value help annotation as per my original post. Try clearing the error validated by ValueListForValidation
nicolas_lunet
Advisor
Advisor
0 Kudos
Yes that's the use case i tried on the linked page and that works well, the value state gets removed once a proper value is defined.
smok1
Explorer
0 Kudos
@nicolas_lunet I see you're doing it for a dropdown. But what if it's for a field with a value help (not dropdown via annotations) and you want to clear the field to clear (blank) and not set to any value from the value help? That's the use case I'm after
nicolas_lunet
Advisor
Advisor
0 Kudos
If you take the same sample, remove ValueListForFixedValue and add ValueListForValidation: '' then you get the use case you want.