Skip to main content
penone
Participating Frequently
June 4, 2019
Question

Run a calculation script on import

  • June 4, 2019
  • 1 reply
  • 325 views

I have a script in a field that takes 3 other fields and formats them into 1 address field that is formatted nicely.

Works great if the user is inputting them in but I would like it to work if I import data into those 3 fields - but it is not.

Code is below. I have this as a calculation script:

event.value = this.getField("shipper_name").value + "\n"

+ this.getField("shipper_address1").value + "\n";

if (this.getField("shipper_address2").value!="")

    event.value += this.getField("shipper_address2").value + "\n";

event.value += this.getField("shipper_city").value + ", "

+ this.getField("shipper_state").value

+ " " + this.getField("shipper_postal_code").value;

I figure it has to do because the script is triggered only after the field is existed and when importing no field is getting entered/exited - therefore the script does not run.

Is there a way to have the script trigger when the data is imported or maybe when the file is opened?

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
June 4, 2019

When the data is imported: Only if you do it using a script.

When the file is opened: Sure. Add this code as a doc-level script (not inside a function):

this.calculateNow();