1

enter image description hereIn my inputFields of zapier, there's one field where the user can enter the date but I want the zapier to work only if I write the date in "2020-09-18T15:30" otherwise it should show a message that the data entered does not match the format specified. I tried this but it's not working.

const activityEditableFields = async (z, bundle) => {
    if (bundle.inputData.dueDate) {
     (/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z/.test(`${bundle.inputData.dueDate}`))
    }

here duedate in the field and I am giving the format that if there is data in it then it should match the specified format but there's no difference in the zap. If you can help me as soon as possible. Do reply.

enter image description here

2 Answers2

0

This shouldn't be necessary. Per the docs:

DateTime fields let users enter dates and times, using their human readable values, machine readable datetimes, or standard English words for time like tomorrow. Zapier interperpates the date input from users and outputs a standard ISO 8601 datetime to your API.

If you declare the field as a datetime, then bundle.inputData.dueDate will always be a proper ISO 8601 datetime.

xavdid
  • 5,092
  • 3
  • 20
  • 32
  • okkay the date is automatically taken in ISO 8601 datetime but in the response its adding 5 hours 30 min then showing. I dont want that to happen. It should print the date as entered in the inputField. – Sweta Kumari Sep 14 '20 at 09:34
  • Can you update your question with the input and output you're seeing/expecting? it sounds like it's working as intended, but is confusing – xavdid Sep 14 '20 at 21:01
  • I have updated my question with the inputField, where I am giving input and the response which I am seeing. And as you can see, in the response, it is not same as the input given. – Sweta Kumari Sep 15 '20 at 09:10
0

The easiest way I could find to workaround this issue was to use with JS code only the first 10 characters of the ISO8601 Zapier date.

bundle.inputData.dueDate.substr(0,10)

or to use moment to parse date (This library is supported by Zapier):

const moment = z.require('moment');
....
moment(bundle.inputData.dueDate).format("YYYY-MM-DD HH:MM:SS UTC")

The only drawback is that you need to use the code editor

tzam
  • 1,802
  • 3
  • 14
  • 15