how can I trigger the onchange again? (when clear the input autocomplete)

Hello Community!

I did this input with autocomplete, but I have some problem because whenever I clear the contents of the input, the on-change event of the input is not triggered and allows behavior that I don´t wish according to my business rules.  How can I do to run the Onchange again and fix this behavior? 

Because isn´t supposed to allow creating a loan without student selected. 

I attached the oml. 

Best regards, 

Jessica Marques. 

Solution

Hi Jessica,

Replace the first IF node of the SaveRequest screen action with the below condition

Trim(Student_Search) = ""
or
StudentId = NullIdentifier()

Hope this helps you!


Regards,

Benjith Sam

Solution

Hello Jessica.

There are probably overlapping functions on the javascript OnChange (check here the same issue) because of AutoComplete and your definition of On Change.

Like Benjith said, you must do an extra validation before saving. Imagine the user edited the field value by playing with debug. Your event can't detect that so the invalid information would pass.

Benjith Sam wrote:

Hi Jessica,

Replace the first IF node of the SaveRequest screen action with the below condition

Trim(Student_Search) = ""
or
StudentId = NullIdentifier()

Hope this helps you!


Regards,

Benjith Sam

 thanks for the help, now it works!

I know that the function Trim is for removes space characters, but I didn´t really understand how it works for this case... Can you explain to me?

 Regards, 

Jessica Marques. 

Nuno Reis wrote:

Hello Jessica.

There are probably overlapping functions on the javascript OnChange (check here the same issue) because of AutoComplete and your definition of On Change.

Like Benjith said, you must do an extra validation before saving. Imagine the user edited the field value by playing with debug. Your event can't detect that so the invalid information would pass.

 Hi,

thanks for the indication, I had read this post but I couldn't find an alternative to help me. 

Regards, 

Jessica. 

Jessica Marques wrote:

I know that the function Trim is for removes space characters, but I didn´t really understand how it works for this case... Can you explain to me?

 Trim is to be sure you are comparing with "", " ", "  " and all other possible empty strings. By trimming the string, you are making sure no spaces are in there.

 

Jessica Marques wrote:

 Hi,

thanks for the indication, I had read this post but I couldn't find an alternative to help me. 

The alternative is to do what Benjith said. You have to do a final check on the Save action. The OnChange is a help for the user. For safety, your process can't depend only on that check and must recheck.

Jessica Marques wrote:

Hi,

thanks for the indication, I had read this post but I couldn't find an alternative to help me. 

Regards, 

Jessica. 

In addition with Nuno's explanation for your query.. thank you Nuno :)

The additional condition which I introduced is to handle the case if the Student_Search value is empty/blank. To make the validation bullet proof, you can also add  one more check i.e. introduce an aggregate (after the IF node) with Student as source entity with Filter condition toLower(student.name) = toLower(Student_Search) 

If the aggregate.List.Empty value is True, terminate the action flow with a error feedback message. Basically it will force the end-user to strictly select any of the autocomplete dropdown option without any post search value edit.

Hope this helps you!


Regards,

Benjith Sam

Hi! 

Another solution can be , not use the 

OnSearchStudentChange

action and  use the 

Input_AutoComplete_GetIdentifier

in the 

SaveRequest

action , as I did in the application attached.


Hope this helps. 

Regards

Graça

Maria da Graça Peixoto wrote:

Hi! 

Another solution can be , not use the 

OnSearchStudentChange

action and  use the 

Input_AutoComplete_GetIdentifier

in the 

SaveRequest

action , as I did in the application attached.


Hope this helps. 

Regards

Graça

 Hi Graça, 

Thank you for this idea. 

I did as you said with "student",  and with  "book" too.


Best Regards, 

Jessica Marques. 

Nuno Reis wrote:

Jessica Marques wrote:

I know that the function Trim is for removes space characters, but I didn´t really understand how it works for this case... Can you explain to me?

 Trim is to be sure you are comparing with "", " ", "  " and all other possible empty strings. By trimming the string, you are making sure no spaces are in there.

 

Jessica Marques wrote:

 Hi,

thanks for the indication, I had read this post but I couldn't find an alternative to help me. 

The alternative is to do what Benjith said. You have to do a final check on the Save action. The OnChange is a help for the user. For safety, your process can't depend only on that check and must recheck.

 Hi Nuno, 

Thanks for the explanations. 

Regards,

Jessica Marques. 

 

Benjith Sam wrote:

Jessica Marques wrote:

Hi,

thanks for the indication, I had read this post but I couldn't find an alternative to help me. 

Regards, 

Jessica. 

In addition with Nuno's explanation for your query.. thank you Nuno :)

The additional condition which I introduced is to handle the case if the Student_Search value is empty/blank. To make the validation bullet proof, you can also add  one more check i.e. introduce an aggregate (after the IF node) with Student as source entity with Filter condition toLower(student.name) = toLower(Student_Search) 

If the aggregate.List.Empty value is True, terminate the action flow with a error feedback message. Basically it will force the end-user to strictly select any of the autocomplete dropdown option without any post search value edit.

Hope this helps you!


Regards,

Benjith Sam

 

Hi Benjuth Sam, 

OK. I will do, thanks for the help!

I always learn a lot here on the forum.

Cheers, 

Jessica Marques.