Search Results for 'script'
-
Search Results
-
(I am moving this from another Forum as the question is more Script based.)
My knowledge of JavaScript is VERY rudimentary although I am generally familiar with object oriented programming and can pick things up quickly with working examples.
I first tried this without being in a function, and didn’t get an error, but then also do not get a result in the Script Field.
SO I changed the script to below and now get an odd error like it can no longer find the very same field record.
(If I “Paste” in from the snippet editor, I get the very same field id so that is not the error!?)
function calculation_result () { var length = record.getFieldValue('fld-0f39aaf844314fde8b5af7adb5d3bd5f'); var value_unit = record.getFieldValue('fld-616fa42329f347148fa7813db6a3289b'); var result_unit = record.getFieldValue('fld-3148ad66cbb14d5b875ee8b26429cdec'); var result = ""; if (result_unit == "inches") { if (value_unit == "feet") { result = length * 12; } else if (value_unit == "yard") { result = length * 36; } else if (value_unit == "cm") { result = length * 2.54; } else if (value_unit == "metre") { result = length * 0.0254; } else { result = length; } } if (result_unit == "feet") { if (value_unit == "inches") { result = length / 12; } else if (value_unit == "yard") { result = length / 3; } else if (value_unit == "cm") { result = length * 30.48; } else if (value_unit == "metre") { result = length * 0.3048; } else { result = length; } } if (result_unit == "yard") { if (value_unit == "inches") { result = length / 36; } else if (value_unit == "feet") { result = length / 3; } else if (value_unit == "cm") { result = length * 0.0109361; } else if (value_unit == "metre") { result = length * 1.09361; } else { result = length; } } if (result_unit == "cm") { if (value_unit == "inches") { result = length * 2.54; } else if (value_unit == "feet") { result = length * 30.48; } else if (value_unit == "yard") { result = length * 91.44; } else if (value_unit == "metre") { result = length * 100; } else { result = length; } } if (result_unit == "metre") { if (value_unit == "inches") { result = length / 39.37; } else if (value_unit == "feet") { result = length * 0.3048; } else if (value_unit == "cm") { result = length / 100; } else if (value_unit == "yard") { result = length * 0.9144; } else { result = length; } } return result; } calculation_result();This gives me the error:
ReferenceError: Can’t find variable: record. Column:20, line:2
I must be missing something very simple about field declarations that I can’t see.
Hi,
I’m afraid I’m new to Tap Forms, although I am familiar with several other database applications – mainly ProVue’s Panorama.
I’m also a beginner at JavaScript. I’ve done quite a bit of coding in the past with languages like Basic and Fortran, and in Excel. I have used JavaScript at a very basic level in web page designs but that’s it so sorry if some of my questions are very basic.
How do I move the focus of a script between records? That is, what is the scripting equivalent of the menu commands Goto … Next Record/Previous Record/First Record/Last Record? I want to get a field value from one record and add/subtract to a different field in a previous record. I’m aware there is an issue regarding how the records might be sorted, which leads me to my second question …
How do I script sorting of records?
Thanks,
Larry