Numeric variable for a record producer

carls
Kilo Explorer

G'Day ServiceNow Gurus,

I was asked to create a numeric field. This can be a number up to 100.00, displayed to 2 decimals. Maximum value is 100.00.   Minimum value is 0.01

Apparently there is not numeric variable type.

Variable Types - ServiceNow Wiki

The closest if a numeric scale but it is not good enough.

Any ideas how can I achieve the bold statement in a record producer.

Kind regards

Carlos

1 ACCEPTED SOLUTION

Create a new UI macro with above provided code. Now create a another catalog variable of type macro with label. In Type Specification tab select the macro you created.


Capture.JPG


View solution in original post

16 REPLIES 16

ket
Giga Contributor

Sure thing Gurpreet. But the other problem is the HTML field is my required field, once the value is entered still the field is displaying as required.   What should I do about it?



Still the field is required.png


The Machine
Kilo Sage

Hi Carlos,



You could also use a single line text field.   With a onChange client script that uses regex to check for valid format on that field, and also can use a validator that it must be between 0.01 and 100.00.   If it doesn't comply, pop up an alert and clear the field.



Hope that helps!



Mike


Hi Michael,



I like to use a single line text variable. Now, where do I place the scrip? in the default value



Single Line Text.JPG



and how the script will look like in detail (very much appreciated if possible)



Kind regards


Carlos


Hi Carlos,



I believe that to accomplish what you're looking for you will need the type to be UI macro and use the code that Gurpreet already provided.



Thanks,


Berny


Thanks Berny,



Cheers


Carlos