getting a duplicate error when adding items to a s...
# suitescript
g
getting a duplicate error when adding items to a sales order in Suitescript. Item is not duplicate tho?
n
What's the exact error?
g
ERROR! TransactionID: 122154820 MESSAGE: This record has already been created. To prevent creating a duplicate, this request has been cancelled.7/7/2020 054331.923
n
What is the flow? Are you creating the sales order using SuiteScript? If yes, which script type are you using?
g
scheduled script. pulling in data from a sales channel
n
Are you using Matrix items?
g
nope
n
Can you share the code?
g
posted it
a
are you saving on each loop? that could be why its hitting a duplicate error
g
yes
i shouldnt be?
a
Saving a record is a Database Write, so I recommend loading the record, making all the changes to the record you want, and then saving after you are finished editing.
g
THANKS!!
also, any way to delete multiple sales orders? for variousreasons i am testing this live and i need to create 7 orders each time
😱 2
so time consuming this way
a
You can Mass Delete certain records but you need to have the appropriate permission level. I’d be terrified to use it in production, so I actually recommend biting the bullet and deleting them one by one just to make sure you don’t inadvertently destroy anything valuable.
n
You also need to take that search out of the loop. First, search all of the items based on the vendor SKU. Once you have the result, loop it and set the line items and then in the end save the sales order.
For searching item using SKU, you need to use filter expressions as itemid does not accept anyof filter.