Using an npm lib (Luxon) in an app param

Hello, I’m using the Google Sheets app to log some information Zolo Sign is sending us via a Webhook.

I wanted to add a human friendly time into the sheet records, using Luxon to set the time with our timezone (Pacific). I’ve required Luxon into the google sheet action code, but when I try and output into the spreadsheet rows, I get the error that DateTime i.e. Luxon is not defined.

Can we use npm package items in the spreadsheet app rows?

Hi @indexsmithy - welcome to the community! Here’s a simple example that demonstrates how to use Luxon to generate and return the current date/time from a code step:

const { DateTime } = require('luxon')
return DateTime.now()

And here’s a link to a workflow with that code:

Does that help? If not, can you share any sample code or a link to your workflow?

Hey Pravin, thanks so much for the response!

So in my action I defined it just like you showed, but in the google sheets param rows, I used:

`{{DateTime.now().setZone('America/Los_Angeles').toLocaleString(DateTime.DATETIME_FULL)}}`

And that’s what gave me the “DateTime is not defined”. Should it work in those rows using the double {{ syntax, or do you think it should still work?

If you’re not sure why, I’ve got a very simple workflow I can share showing what I tried.

Thanks again

@indexsmithy - thanks for the clarification! While you can reference previous step exports and run some basic Javascript in step inputs, npm packages are not supported. My recommendation is to add a Node.js code step before the Sheets action and return the date/time value you want to reference. E.g., add the following code to the Node.js code step:

const { DateTime } = require('luxon')
return DateTime.now().setZone('America/Los_Angeles').toLocaleString(DateTime.DATETIME_FULL)

Then reference the return value in the Google Sheets action. E.g., if you name the code step pacificTime enter {{steps.pacificTime.$return_value}} in the input for the Google Sheets action.

I hope that helps!

Brilliant, that is perfect. Thank you!