has anyone found a good workaround to the "you can...
# suitescript
h
has anyone found a good workaround to the "you cannot edit the end of a group" message when dealing with item groups on sales orders via script?
j
what are you actually trying to do when you are getting this error?
h
dynamically add items to a group that exists on the order basically, we have lines that are tagged in an order to add to an item group, I collect those items and then add them to the existing item group on the order. I shouldn't be adding past the count of items that exist to add and I have in my script to skip end of group item type but no luck
j
Are you using insertLine ?
you should be able to call
insertLine()
using the line index that’s 1 less than the index of the group end.
🙌 1
h
I'll give that a try - thank you for the tip!
s
I think using a custom grouping field is a better approach. I prefer to add a custom field and assigned a value. However, I found this approach to be more useful for custom groups than the default grouping behavior.
n
If you want to ignore the end of group item, use the itemtype field from the lines and skip if the item type is EndGroup
h
@NickSuite I did try that but I must be missing something because I'm still getting the error. I am going to try the insertline approach today to see if I can figure it out
👍 1
@jen your solution worked - thank you!
❤️ 1
🎉 1