Numeric value validation on save

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I have a page with 5 models. One of the models has a numeric value (double). When I enter an invalid value (string), I don't get any error message. The model saves successfully and just blanks out the number value.

I tried to "Add on-error action" to the button without any luck.
I want to avoid writing the whole save in Javascript.
Photo of Amr

Amr

  • 256 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Well. I think I get what you're asking. You've got a snippet that does attempts to update field values. Then an action to save is set.

If you know which field is supposed to be a numeric value, why not just make sure it's a number before finishing the snippet.
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Can you reproduce this outside of your page i.e. in another page?  If so, post sample XML here.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Amr,  why are you not using normal Salesforce Validation here?  Skuid will post any validation error message on your page. No coding needed. 
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
If you make it a required field, you will get field validation.  Otherwise, either add server side validation per Rob, or implement a custom field renderer (Rob would this work too?).

Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
And there it is. The "Nuts" as they'd say in poker.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
You could do validation in a custom field renderer - to achieve a client side behavior - but the server side solution is so much easier... ie no code. 
Photo of Amr

Amr

  • 256 Points 250 badge 2x thumb
Thanks all for your replies. Sorry for being away for time difference (I am in Australia).
I replicated the same in a simple page with one model. Kindly note here there is no coding involved. Only out of the box save.

Photo of Amr

Amr

  • 256 Points 250 badge 2x thumb
I found a workaround by adding validation rule on Salesforce side.

NOT( ISNUMBER(Text(ts2__Years_of_Experience__c )))

I hope there is a better solution.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Glad you were able to get this working.  Enjoy your Austrailan summer.