Search Results for 'script'
-
Search Results
-
I’m working on a merge record script to be able to take two records and merge them together. This isn’t too bad for almost all of the field types except for the photo and file attachment types. How do I copy the attachments from one record to another for the file and photo fields?
(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.