Toolbox Server Script, Batching text conversion

Hey Everyone :wave:

A while back I asked about converting a string to date as part of a backend workflow . I successfully got this working as recursive workflow doing the lift line by line using the Data Converter plugin.

When I’m working over a couple of thousand records however this is pretty painful and it’s much faster to do this in batches of say 50 records at a time. The problem is the plugin can’t work on a list :sob:

Toolbox’s server script looks to be the goods and I’ve done a little playing around including reading Toolbox plugin help - server script - #3 by paul29 and the excellent examples from @viquarahmed07 but doco is thin on the ground and I’m not sure i have the context right.

What I’m doing is converting a unix time string into a list of dates. I then have a steps further in the workflow that takes the result of this step and updates each record in the batch. So for this step I want to create a list of dates from the list of text.

Here’s my Server script

heres my error

reading the error it looks like the ThingList isn’t being populated but If I pop that in the data field, then it won’t know its a list (at least that what Im assuming) . Of course I could have the code utterly wrong as well :roll_eyes:

I’d like to nail how to user server scripts because this kind of problem happens all the time and while theres tons of examples doing this at the front end, I’d really like to learn how to do this away from the user and slowing their experience.

Cheers - John

3 Likes

Good Afternoon, I’ve spent my last two weekends on this issue myself (my app needs to upload .csv files with hundreds of rows in each file).

As a precursor, i’m not familiar with Javascript, so i’ve been just trying a bunch of semi-random code snippets in the ServerScript action form the toolBox plugin,

using examples such as: Parse a text to a date - #2 by pork1977gm (tried idk how many different iterations of that implementation) which, after reading up a bit online and thru google should work,

but ultimately it was this post that helped me get my first successful text-to-date conversion: Toolbox plugin help - server script - #4 by paul29
(the link to that app’s editor showed me how to properly use the “data” field in that plugin’s configuration)

so here’s what i tried first (just to see if it manged to return the text in that dynamic field):

And sure enough, that’s all i apparently need? I hope there’s no kind of error this causes, and i’ll be doing some more testing, but jeez that was simple AF :rofl:

For Reference, here’s my OG .csv file :
image

And here’s what i get in my Database (date datatype):
image

2 Likes

Yes you can’t leave your data field empty – the script is calling on an empty object.

In your script, your strDate and Date objects rely on the array of strings to be non empty. It’s why you’re getting an object null error.

Add a query in the data field for the data that the script is meant to be working on