Skip to main content
Solved

Incorrect Date Calculations When Creating Sales Order Through API

  • 12 June 2024
  • 6 replies
  • 39 views

Hi community,

 

The system I am creating sales orders on is having some discrepancies between the manually created sales orders and API-created sales orders. When the delivery route assigned to a customer has a trip the next day and you manually create a sales order with a Requested Date of next-day, the sales order auto-fills its Pick On date for today as expected. When doing it via API, it skips the next-day trip and auto-fills the Pick On date for the day before the next trip even if that is next month. 

I already set the PX-CbApiBusinessDate when creating the sales order and made sure the time zone is correct in my user profile. Is there something I can do like set the Created Date value of the sales order or adjust the date via API after the record is created?

 

Please let me know if I need to clarify anything!

 

Thank you.

6 replies

Userlevel 7
Badge +5

What are you sending for the date value in your API call? Just the date or do you include a time value in the JSon?

Just the date formatted ‘yyyy-MM-dd’

Userlevel 7
Badge +5

made sure the time zone is correct in my user profile.

The date in user profile does not affect the API calls. 

Try sending the datetime with the timezone shift component

Userlevel 7
Badge +5

So, I don’t have the perfect answer for you which means you’ll have to do some experimentation to see what works and if you can come up with a rule.

Depending on the date field, it can store more than just the date.

You can add more to the JSon value. The following will set the field to July 21st, 2022 at midnight (GMT) offset to the Eastern Timezone (for half of the year):

"2022-07-21T00:00:00-04:00"

Another way to test is to set your profile timezone to GMT. Enter an order through the UI. Then set your profile to another timezone and enter an order. Then set your profile to yet another timezone and create a third order.  Then review what is stored in the database for those three orders.

I never dug more into the subtleties with this as the project ended. I’m in the PST zone and the orders were going into ACM for a company on the east coast of the US so I had to keep the dates straight in my head during testing. In addition, some date fields don’t care about time components which makes the above act differently when you compare entering orders into the UI.

@Dmitrii Naumov, thank you for that info I did not know that. I would have assumed user profile timezone mattered especially since I am using the user credential authentication flow!

 

When I look at my JSON response data, everything looks to be correct: 

{
"CreatedDate": {
"value": "2024-06-12T18:44:10.347+00:00"
},
"Date": {
"value": "2024-06-12T00:00:00+00:00"
},
"EffectiveDate": {
"value": "2024-06-12T00:00:00+00:00"
},
"LastModified": {
"value": "2024-06-12T18:44:10.347+00:00"
},
"RequestedOn": {
"value": "2024-06-17T00:00:00+00:00"
},
"custom": {
"Document": {
"UsrNVFSDeliveryDate": {
"type": "CustomDateTimeField",
"value": "2024-06-13T00:00:00"
}
}
}
}

This is every date-related value I receive in my sales order creation response unless it is something in my cookies that shows the issue?

 


[
"Locale=Culture=en-US&TimeZone=GMTM0500G; expires=Sat, 15-Jun-2024 18:44:06 GMT; path=/",
"CompanyID=xxxxxxx; expires=Sat, 15-Jun-2024 18:44:06 GMT; path=/",
"UserBranch=xxxxx; path=/",
"Locale=Culture=en-US&TimeZone=GMTM0500G; expires=Sat, 15-Jun-2024 18:44:06 GMT; path=/",
"CompanyID=xxxxxxx; expires=Sat, 15-Jun-2024 18:44:06 GMT; path=/",
"UserBranch=xxxxxxx; path=/",
"requestid=xxxxxxxx; path=/",
"requeststat=xxxxx; path=/"
],

 

Userlevel 7
Badge

Hi @jmu216 were you able to find a solution? Thank you!

Reply