OnFleet Task Creation always creating tasks -4 hours

Hello n8n team,

I have a Cloud workflow that reads some data and passes it to OnFleet App to create tasks. Prior to the n8n upgrade, this workflow worked correctly.

Now when it runs, it always offsets the task CompleteBefore and CompleteAfter by -4 hours. If I send 7 AM, the task gets created with a CompleteAfter of 3 AM. This is not affected by any changes to the timezone in the workflow or to the console itself.

I created a new workflow just in case this was something related to the original workflow having an element that did not get converted correctly after the platform update, but the same thing occurs with a brand new workflow.

No error messages are reported, because the workflow works fine, it is just the tasks that are created which have the wrong date.

Workflow is MSQL query to OnFleet Create Tasks.

Hi @misace, welcome to the community! I am sorry you are having trouble.

Based on your description, I suspect this may be due to a time zone discrepancy between your n8n instance and your OnFleet account or the browser you are reviewing these tasks with. The way n8n interacts with the OnFleet API hasn’t been touched in several months, so I don’t think n8n is sending anything else now compared to what it did before your latest upgrade.

Unfortunately, OnFleet does not provide dev accounts from the looks of it (their sign up link on their dev portal simply links to their pricing page), so I won’t be able to verify this first hand.

Can you confirm how exactly you are creating your tasks? Are you using an expression in the Complete Before and Complete After fields, and if so can you share the exact expression you have and its input data?

Also, can you fetch an example task you have created using the aforementioned expression using the Task → Get operation of the OnFleet node and share the JSON result you are seeing? I’d like to see if this includes any offset.

Here is the input data. I did test the different time zone offsets and no combination of changing those made a difference that I could tell.

[
{
“Customer”: “0003975”,
“Name”: “CUSTOMER1”,
“Tasks”: “437523 CAN LEAVE OUT SIDE”,
“ReqShipDate”: “2023-08-09T00:00:00.000Z”,
“Street”: “STREET”,
“Street2”: " ",
“City”: “CITY”,
“State”: “STATE”,
“Zip”: “ZIP”,
“Country”: “USA”,
“PhoneNumber”: “123-456-7890”,
“TotalOrdered”: 20,
“Mass”: 330.5,
“StartTime”: “07:30:00”,
“EndTime”: “17:00:00”,
“CompleteAfter”: “08/08/2023 07:30:00”,
“CompleteBefore”: “08/08/2023 17:00:00”,
“ServiceTime”: 15
},
]

Here is the output for a created task.

[
{
“id”: “U1Q0d1O6rSuCu8y~zgtl67jr”,
“timeCreated”: 1691412312000,
“timeLastModified”: 1691412312436,
“organization”: “XFgOn2KgIAD1d6O4GSpsIsT",
“shortId”: “186d135f”,
“trackingURL”: “Track Your Driver”,
“worker”: null,
“merchant”: "X
FgOn2KgIAD1d6O4GSpsIsT”,
“executor”: “XFgOn2KgIAD1d6O4GSpsIsT",
“creator”: “uxA0m6gw1BGqOJJg33uA07qv”,
“dependencies”: [],
“state”: 0,
“completeAfter”: 1691479800000,
“completeBefore”: 1691514000000,
“pickupTask”: false,
“notes”: “”,
“completionDetails”: {
“failureNotes”: “”,
“successNotes”: “”,
“failureReason”: “NONE”,
“events”: [],
“actions”: [],
“time”: null,
“signatureUploadId”: null,
“photoUploadId”: null,
“photoUploadIds”: null,
“firstLocation”: [],
“lastLocation”: [],
“unavailableAttachments”: []
},
“feedback”: [],
“metadata”: [],
“overrides”: {
“recipientName”: “CUSTOMER1”,
“recipientNotes”: null,
“recipientSkipSMSNotifications”: null,
“useMerchantForProxy”: null
},
“quantity”: 20,
“additionalQuantities”: {
“quantityA”: 0,
“quantityB”: 0,
“quantityC”: 0
},
“serviceTime”: 15,
“identity”: {
“failedScanCount”: 0,
“checksum”: null
},
“appearance”: {
“triangleColor”: null
},
“scanOnlyRequiredBarcodes”: false,
“container”: {
“type”: “ORGANIZATION”,
“organization”: "X
FgOn2KgIAD1d6O4GSpsIsT”
},
“trackingViewed”: false,
“recipients”: [],
“destination”: {
“id”: “yatjz4OJmpF*yfNeaSAFxWbA”,
“timeCreated”: 1691412312000,
“timeLastModified”: 1691412312396,
“location”: [
-74.0646994,
40.352604
],
“address”: {
“apartment”: “”,
“state”: “STATE”,
“postalCode”: “ZIP”,
“number”: “17”,
“street”: “STREET”,
“city”: “CITY”,
“country”: “United States”,
“name”: “CUSTOMER1”
},
“notes”: “437523 CAN LEAVE OUT SIDE”,
“metadata”: [],
“googlePlaceId”: “ChIJO9Xh0kcwwokRg-TzYPoLKPM”,
“warnings”: [],
“useGPS”: false
}
}
]

Here is the Get Task result.

[
{
“id”: “UbTSQw4VmkpIKnMApx87Sren”,
“timeCreated”: 1691411320000,
“timeLastModified”: 1691411320432,
“organization”: “XFgOn2KgIAD1d6O4GSpsIsT",
“shortId”: “ae024179”,
“trackingURL”: “Track Your Driver”,
“worker”: null,
“merchant”: "X
FgOn2KgIAD1d6O4GSpsIsT”,
“executor”: “XFgOn2KgIAD1d6O4GSpsIsT",
“creator”: “uxA0m6gw1BGqOJJg33uA07qv”,
“dependencies”: [],
“state”: 0,
“completeAfter”: 1691479800000,
“completeBefore”: 1691514000000,
“pickupTask”: false,
“notes”: “”,
“completionDetails”: {
“failureNotes”: “”,
“successNotes”: “”,
“failureReason”: “NONE”,
“events”: [],
“actions”: [],
“time”: null,
“signatureUploadId”: null,
“photoUploadId”: null,
“photoUploadIds”: null,
“firstLocation”: [],
“lastLocation”: [],
“unavailableAttachments”: []
},
“feedback”: [],
“metadata”: [],
“overrides”: {
“recipientName”: “CUSTOMER1”,
“recipientNotes”: null,
“recipientSkipSMSNotifications”: null,
“useMerchantForProxy”: null
},
“quantity”: 20,
“additionalQuantities”: {
“quantityA”: 0,
“quantityB”: 0,
“quantityC”: 0
},
“serviceTime”: 15,
“identity”: {
“failedScanCount”: 0,
“checksum”: null
},
“appearance”: {
“triangleColor”: null
},
“scanOnlyRequiredBarcodes”: false,
“container”: {
“type”: “ORGANIZATION”,
“organization”: "X
FgOn2KgIAD1d6O4GSpsIsT”
},
“trackingViewed”: false,
“recipients”: [],
“estimatedCompletionTime”: null,
“estimatedArrivalTime”: null,
“destination”: {
“id”: “WqfjmpldezjZVSkxQfu4qLhS”,
“timeCreated”: 1691411320000,
“timeLastModified”: 1691411320403,
“location”: [
-74.0646994,
40.352604
],
“address”: {
“apartment”: “”,
“state”: “STATE”,
“postalCode”: “ZIP”,
“number”: “17”,
“street”: “STREET”,
“city”: “CITY”,
“country”: “United States”,
“name”: “CUSTOMER1”
},
“notes”: “437523 CAN LEAVE OUT SIDE”,
“metadata”: [],
“googlePlaceId”: “ChIJO9Xh0kcwwokRg-TzYPoLKPM”,
“warnings”: [],
“useGPS”: false
},
“delayTime”: null,
“eta”: null
}
]

Good morning, I saw that you were out and I had posted some info when that happened. Have you been able to review the data I posted to see if that helps?

Thanks so much for confirming @misace and apologies for the late reply, I must have somehow missed your answer.

I assume you are using these values “as is” in your expressions, like so?

Can you try using expressions like below (replacing America/New_York with your actual time zone) and confirm if this helps?

{{ DateTime.fromFormat($json.CompleteAfter, "MM/dd/yyyy HH:mm:ss", { "zone": "America/New_York" }).toISO() }}

This should parse your existing value in a timezone-aware way, and I hope it prevents other services down the line from applying their own logic to your existing timestamp.

I will actually be out again next week but perhaps @Jon or @EmeraldHerald can take a look into this if this doesn’t solve the problem.

3 Likes

That solution worked great. The offset is no longer present. Appreciate the assistance.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.