Best answer

Fresh KDS error: Cannot read properties of undefined (reading 'split')


Hi!

 

I’m trying to integrate Shopify and Fresh kds. 

What I need is that a when a new order comes to Shopify it get sent to Fresh KDS. 

 

I alway get an: Cannot read properties of undefined (reading 'split')

 

Can you help me with what I’m doing wrong :-) 

Thanks. 

 

icon

Best answer by ken.a 10 July 2023, 12:31

View original

11 replies

Userlevel 7
Badge +14

Hi @elin 

Good question.

Can you post a screenshot of the returned error message?

It’s likely related to the Items section.

Make sure the Item Name value doesn’t have any commas.

 

Hi this is the error I get

 

Userlevel 7
Badge +6

Hi @elin,

I’m jumping in to see if I can help!

I did some digging into this, and it seems like the error you’re seeing Cannot read properties of undefined (reading 'split') is a known bug with the Fresh KDS integration. Our team is aware of the issue and we're working with Fresh KDS on a fix. I've added your email address as another affected member. That does a few things:

  • Bring this to the attention of the integration developers
  • Help track and prioritize fixes
  • Allows us to notify you via email if/when this is fixed

Unfortunately, I do not have an ETA, but I’ve added you to the list of members affected by this issue so we can let you know as soon as we have any updates.

Userlevel 1

I’m also running into this issue while testing the Shopify + Fresh KDS integration.  I’ve pinned it down to orders which contain at least one product that does not have a variant.  If an order contains only products with variants, it gets correctly pushed to the KDS.  If at least one product does not have a variant, the ‘Line Items Variant Title’ modifier (circled below) will contain empty fields, which I suspect is what the split (or more accurately it’s return value access) is upset about. In that test order, the first two line-item products do not have variants and the third does.

The official response in this thread suggests that the solution involves working with Fresh KDS, which may be because they require that additional modifier field for each item.  If that is the case, at least an interim solution might be to simply default any undefined variants/modifiers to ‘Default’ or an empty string to make Fresh KDS happy.

Please advise on whether an interim solution is possible and if there’s any progress towards an ETA. 

 

 

Userlevel 7
Badge +6

Hi there @xenn,

Unfortunately, there are no other workaround regarding this bug. However, you can maybe use Text in Formatter by Zapier - Default function to return a default value if the text is empty. If a line-item field is provided, a line-item field is returned. I haven’t tested this out myself, but it’s worth a try.

That said, I have added you as another affected member to the bug report. While we can’t provide an exact timeframe for the bug’s fix. We will keep you in the loop via email once there is.

I appreciate your patience and understanding.

Userlevel 1

Looks like my reply got lost in moderation somewhere along the way.  Trying again…

I’m new to Zapier but the ‘Text in Formatter - Default’ workaround doesn’t appear to be an option due to the null line-items being dropped from the Line-Item object.  You can reproduce it by adding a ‘Text to Line-Item’ transform with text ‘,,Small’ and then try the ‘Default’ workaround or a ‘Line-Item to Text’ transform to get back to the original ‘,,Small’ text.  In both cases, a test shows that the null values are missing from the Line-Item object.  The test output for the first ‘Text to Line-Item’ transform does return the correct null values but once the line-item object is accessed later, they’re gone and the only element in the list is ‘Small’.  This appears to be known behavior based on this old thread, but it doesn’t look like I can use the workaround there since I don’t have control over the creation of the line-item object.

Unless I’m misunderstanding, this would suggest that the issue may actually be on your end.  Unless your backend is keeping track of the null modifiers under the hood so that they can be passed to Fresh KDS with their corresponding item, the association between the modifier and the item will be lost once the null modifiers are dropped and the modifier line-item array no longer aligns with the other line-item arrays.

Is my understanding correct of how null line-items are handled?  If the null modifiers are indeed somehow being passed to Fresh KDS, is there a way I can access them from the line-item object so that I can try mapping them to a new line-item with default values?

Thanks.

 

Userlevel 7
Badge +11

Hi @xenn! 👋

Ah, ok there’s two issues here. One relates to the bug Ken mentioned where a blank line item in the Modifiers field will throw that “Cannot read properties of undefined (reading 'split')” error. The second is an issue with how the Formatter app handles blank/null line items, as it ignores them. 

I’m not sure you’d need control over the line-item object to use the workaround in that thread you found. The workaround mentioned would allow you to replace blank line item values with another value. So you could potentially swap a null line item value with “0” for example. Now, I’m not sure if the Modifiers field would accept a value of 0 but here’s an example of how you’d do that: 
6e7a1d21d8e130fa425f40401cf7cf99.png
This would output the line items as:
1b842931a6e2f57d88692bff0f443b26.png

If the Modifiers field is expecting a specific value like “None” or “N/A” etc. when there’s no modifier selected, then you’d need to use that value instead of “0” in the formula, to allow Fresh KDS to send the order without error.

Can you give that a try and let us know if that does the trick?

Userlevel 1

Looks like it’s working.  I’m now able to successfully send all orders to Fresh KDS.  Thanks for the assist!

Userlevel 7
Badge +6

That’s fantastic news @xenn! Glad to hear Sam’s suggestion worked!

If you have any other questions, please don’t hesitate to reach out to the Community. We’re always happy to help! 🤗

I am having this issue still, what is the solution?

Userlevel 7
Badge +11

Hi @lifire 👋

Sorry to hear you’re being affected by these errors as well. I’ve gone ahead and added you to the bug report. I can’t give any sort of estimate as to when this might be resolved but adding you to it does help to increase it’s priority and allows us to notify you as soon as a fix is put in place.

In the meantime, as these errors occur when there is a blank value for a line item in the Modifiers field, what you can do is try the previously mentioned workaround of using a Formatter (Text > Spreadsheet-Style Formula) action to set a values for any blank line items:

So you could potentially swap a null line item value with “0” for example. Now, I’m not sure if the Modifiers field would accept a value of 0 but here’s an example of how you’d do that: 
6e7a1d21d8e130fa425f40401cf7cf99.png
This would output the line items as:
1b842931a6e2f57d88692bff0f443b26.png

If the Modifiers field is expecting a specific value like “None” or “N/A” etc. when there’s no modifier selected, then you’d need to use that value instead of “0” in the formula, to allow Fresh KDS to send the order without error.

 

Hope that helps. If you run into any trouble implementing that workaround just let me know and I’ll be happy to assist! 🙂

Reply