# Export/Lookup Javascript Transformations

**URL:** <https://connective.celigo.com/t/export-lookup-javascript-transformations/1305>\
**Category:** Integrator.io\
**Tags:** export, transformation, ui-ux, lookup, javascript\
**Created:** [January 5, 2021, 10:06pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305 "2021-01-05T22:06:43Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![wadeshelton](https://avatars.discourse-cdn.com/v4/letter/w/49beb7/32.png) [@wadeshelton](https://connective.celigo.com/u/wadeshelton)\
**Post date:** [January 5, 2021, 10:06pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/1 "2021-01-05T22:06:43Z")

</div>

I'm working in the new UI and would like to try the new Javascript transformation on exports/lookups, but I haven't found much documentation on them. I have some transformations that I think would be easier implemented in JS than through handlebars statements. Is there anything available that documents how to use that feature?

---

<div class="post-metadata">

**Author:** ![courtneyjordan](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@courtneyjordan](https://connective.celigo.com/u/courtneyjordan)\
**Post date:** [January 6, 2021, 5:54pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/2 "2021-01-06T17:54:15Z")

</div>

Hi @wadeshelton,

Thanks for letting us know about this need! We don't have any docs on that specifically yet. Are there any particular questions you have? We'll work on getting some docs ready as soon as we can.

---

<div class="post-metadata">

**Author:** ![wadeshelton](https://avatars.discourse-cdn.com/v4/letter/w/49beb7/32.png) [@wadeshelton](https://connective.celigo.com/u/wadeshelton)\
**Post date:** [January 6, 2021, 5:59pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/3 "2021-01-06T17:59:58Z")

</div>

Courtney -

I'm just trying to understand the syntax for the rules. In other places where you can interject Javascript, you can insert function stubs so that you can determine what the parameters and returns look like. There's nothing here for this feature, so I can't determine the object being passed or what should be returned.

---

<div class="post-metadata">

**Author:** ![mattgraney](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/mattgraney/32/6606_2.png) [@mattgraney](https://connective.celigo.com/u/mattgraney)\
**Post date:** [January 6, 2021, 6:26pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/4 "2021-01-06T18:26:50Z")

</div>

Hi Wade,

You can insert a stub once you choose the script file.

Here I haven't selected the script (note the "None" selection):

 ![5301043caa20740200000001-facdf259f2ee436c9d3d32770b1815a9.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/b/b79f044407b0c47be57b01d8a1dfbccb41172661.png)

... and once I select a script, I can insert the transform stub.

 ![5301043caa20740200000001-d03818fbf83e49ed87355925b958b3d8.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/0/0111065112d7f97ba2deeb21dc612a8e37974879.png)

And just in case, here's the stub:

> ```
> / **transformFunction stub:** The name of the function can be changed to anything you like.** The function will be passed one 'options' argument that has the following fields:* 'record' - object {} or array [] depending on the data source.* 'settings' - all custom settings in scope for the transform currently running.* The function needs to return the transformed record.* Throwing an exception will return an error for the record.*/function transform (options) {return options.record}
> ```

---

<div class="post-metadata">

**Author:** ![mattgraney](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/mattgraney/32/6606_2.png) [@mattgraney](https://connective.celigo.com/u/mattgraney)\
**Post date:** [January 6, 2021, 6:31pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/5 "2021-01-06T18:31:13Z")

</div>

And here's a working example I made (testing the limits of my own rudimentary JS skills):

 ![5301043caa20740200000001-5b302404bd9640a2bc531eb74f4c2fbd.png](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/e/e85ed17c23ee6c80d755b71aa63eb7eaa0737be8.png)

---

<div class="post-metadata">

**Author:** ![waltlaws-macdonald](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@waltlaws-macdonald](https://connective.celigo.com/u/waltlaws-macdonald)\
**Post date:** [April 30, 2021, 11:21pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/6 "2021-04-30T23:21:33Z")

</div>

Hey, does this feature work? My code is not saving when I try to use a JS transform

Edit: your function must return "record" - no other return is accepted. That was not super clear first time around :)

---

<div class="post-metadata">

**Author:** ![katelarson](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@katelarson](https://connective.celigo.com/u/katelarson)\
**Post date:** [May 3, 2021, 3:41pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/7 "2021-05-03T15:41:59Z")

</div>

Hi Walt -   
Thanks for updating this post with that information. We plan to create more documentation on using JavaScript transformations for exports and lookups. Please tell us more about your use case when you have a minute. (And that goes for anyone else reading this too!) It's very helpful to our team so that we can document useful examples.

#

---

<div class="post-metadata">

**Author:** ![waltlaws-macdonald](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@waltlaws-macdonald](https://connective.celigo.com/u/waltlaws-macdonald)\
**Post date:** [May 3, 2021, 4:42pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/8 "2021-05-03T16:42:59Z")

</div>

Thanks Kate! I am using the JavaScript transformation to pull certain timestamps out of an array that is not guaranteed to be sorted. This is using the EasyPost tracker API response. This feature is definitely light on docs at the moment, would greatly appreciate more guidance in the future!

Here is the code I ended up with:

```
function transform(options) { let input = options.record let tracking_details = input["tracking_details"] var shipment_created_date = null var actual_picked_up_date = null var actual_delivered_date = null for (var i = 0; i < tracking_details.length; i++) { if (tracking_details[i]["status_detail"] === "label_created") { shipment_created_date = tracking_details[i]["datetime"] } if (tracking_details[i]["message"] === "Picked up") { actual_picked_up_date = tracking_details[i]["datetime"] } if (tracking_details[i]["status"] === "delivered") { actual_delivered_date = tracking_details[i]["datetime"] } } var record = { "shipment_created_date" : shipment_created_date ,"actual_picked_up_date" : actual_picked_up_date ,"actual_delivered_date" : actual_delivered_date ,"estimated_delivered_date" : input["carrier_detail"]["est_delivery_date_local"] } return record}
```

---

<div class="post-metadata">

**Author:** ![katelarson](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@katelarson](https://connective.celigo.com/u/katelarson)\
**Post date:** [May 3, 2021, 4:48pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/9 "2021-05-03T16:48:15Z")

</div>

Thanks, @waltlaws-macdonald. We really appreciate the code example.

---

<div class="post-metadata">

**Author:** ![babatundedallas](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@babatundedallas](https://connective.celigo.com/u/babatundedallas)\
**Post date:** [April 5, 2023, 7:30pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/10 "2023-04-05T19:30:30Z")

</div>

Celigo: Define transformation.

Hi Celigo, I've over 70 records in the **input** section, but only the LAST record is displayed in the **output,** and it was successfully inserted in the destination table inside SSMS.

I need advice on how to have all 70 records listed in the **output** section, so that I can have all records inserted into the destination table.

 ![5301043caa20740200000001-942cceddefc64d2283d0e416c37d158b.jpg](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/2/27b6b5cfebd308cdb2ecc216ec2d37012fd735cc.jpeg)

---

<div class="post-metadata">

**Author:** ![amanjotsingh](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@amanjotsingh](https://connective.celigo.com/u/amanjotsingh)\
**Post date:** [April 5, 2023, 7:46pm UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/11 "2023-04-05T19:46:14Z")

</div>

Hello @babatundedallas  
  
Could you add "\*." to all the fields on the right side?   
Example - change Location\_Code to \*.Location\_Code   
  
Thanks!

---

<div class="post-metadata">

**Author:** ![rameshbugatha](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@rameshbugatha](https://connective.celigo.com/u/rameshbugatha)\
**Post date:** [January 18, 2024, 6:09am UTC](https://connective.celigo.com/t/export-lookup-javascript-transformations/1305/12 "2024-01-18T06:09:31Z")

</div>

Hi

I am integrating workday to netsuite we used post method and its running good for multiple records and for single record we are getting evaluation failed invalid transformation error.what i understand in debugging for multiple we have square brackets i mean array that s its passing records for single object we are not getting square bracket and we have only curly brackets.please let me know its urgent.
