leftinvestment.blogg.se

Custom calculation script for multiplying percentages
Custom calculation script for multiplying percentages








custom calculation script for multiplying percentages

To learn more about the event object, take a look at – make sure to click on the button in the upper left corner to display the navigation pane if it’s not shown You cannot do that. There are other ways to highlight the field in question besides changing the text color, the border color or the fill color could be changed instead, or in addition, just make sure that you are not making the form impossible to read. So, having a text field contain that error message might be a good idea. Using this method has implications on the form submission process: The form no longer can verify that the data is correct, so the submission function needs to do another round of validation to see if any of the required fields are not correct (one way to do that is to test all relevant fields to see if the text color is using the error color, or we can use global variables to store the validation state).Īnother thing I like to do is to display the validation error message on the form in an otherwise hidden field: The problem with our last solution is that if the user saves a partially filled form, and picks it up at a later time, that error message that popped up is long gone, and the only indication that there is something wrong with the form is the modified field color. This is not always desired (for more complicated data, it will probably be much easier to take a look, correct that one typo and continue with the rest of the form), so my preference is actually to mark the field so that the user knows which field needs to be corrected, and have the validation script not report a validation error back to the field: event.rc = true In that case, the previous value of the field is restored, and the user has to enter the data again. When you play around with the function, you’ll notice that the validation function is only called when the focus leaves the field, so you have to click outside of the field to actually make that error message pop up.

custom calculation script for multiplying percentages

In the latter case, we set rc to false, and also display an error message. The member ‘rc’ (or return code) is used to communicate back if the validation was successful or not.

#Custom calculation script for multiplying percentages code

This script also includes a check for an empty string, so that the user can wipe out a wrong string and start from scratch.Īs I mentioned before, information is passed to the validation function in the event object, and in the code we see that the member ‘value’ is used to communicate the current value of the field. If (event.value != "" & event.value != "AAAA" & event.value != "BBBB")Īpp.alert("The entered value needs to be either 'AAAA' or 'BBBB'!") To make things easier to copy&paste, here is the script again: event.rc = true










Custom calculation script for multiplying percentages