Clear Input-Field to empty string ""
Question

Hi There,

i build a webapp where an text input is made into an input-field. After input a ClientAction ist processed on which end it should set the input-field to empty for the next input.

I tried this by a simple assign var = "", but this doesnt work. On debuging i can see, that the variable is set to "", but at the end the of the client action the input-field has still the text from beginning in it. 

If i do set any content (e.g. "0") to the var instead an empty string ("") it works. 

So, how is it possible to get the input field empty at the end of my client action?

Thank you for any hint!

Hendrik

Solution

Hi there, 

i solved the Problem with a little workaround. 

I do not call the Client Action direktly. Instead i first call an action with even one line Javascript:

setTimeout($actions.DataActionNachScan,1);

Somehow it needed at least one millisecond between the onchange and the reset of the variable. 

Thanks,
Hendrik

mvp_badge
MVP

Hi Hendrik,

Can you please share the image of your assignment or sample oml because usually you can easily make text input box empty by assigning = "" value to it.

I hope variable associated with your input box don't have any default value assigned.

Regards,

Manish Jawla

Thanks for your fast reply.

The Variable has no default assigned. I tried it once by assigning "" as default but it makes no different, so i deleted the default value. 

Sharing oml is a little bit difficult because lot of dependencies. But here are screenshoots:

On the first screenshoot you can see the "" assignment to variable "scan". On the secont the "0". The input field of the screenshoot on both is after client action.

Something i noticed by taking the screenshoots: In the second screenshoot with "0" the cursor is set back to the input box, in the first one not.

mvp_badge
MVP

Hi Hendrik,

I am attaching the sample oml.

This is really simple operation don't know why you are facing this issue.

Please try to compare the code with oml and let me know if this helps.


Regards,

Manish Jawla

SetBlank.oml


Hi Manish,

thanks for your sample. It works, but the difference to my code is that i trigger the action with on change event from the input. That seems to be the problem. I tried to insert a button in my code and it works.

But button is not realy a solution for me. The input text comes by a scanner and should immediately trigger the client action. 

Maybee it works if i simulate the button click by some javascript-code. But that seems to be just a workaround

Regards
Hendrik

Hi!

Your app is Reactive or Traditional ? 

If is traditional , verify if you are refreshing the field or if the screen is loaded again!

Stay safe

Graça 

Sorry, i forogt to mention: its reactive.

Hi @Hendrik_S , this shouldn't happen actually, make sure whether any default value assigned to the variable what you binded to the text box, second - if you're redirecting the screen at the flow end , check if you used any OnInitialiZe like events , you may set that variable there.



Thanks,

Sandeep.

Solution

Hi there, 

i solved the Problem with a little workaround. 

I do not call the Client Action direktly. Instead i first call an action with even one line Javascript:

setTimeout($actions.DataActionNachScan,1);

Somehow it needed at least one millisecond between the onchange and the reset of the variable. 

Thanks,
Hendrik

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.