Issue with Duplicate Rows When Using Smartsheet API in Integration with NetSuite

Hello!
I've encountered an issue while integrating NetSuite and Smartsheet via API. The script works inconsistently and occasionally creates duplicate rows in the Smartsheet table.
Current Script Logic:
- A record is created in NetSuite, triggering the script.
- The script collects data about the parent row.
- A request is sent to add a row to the table via the API method
.../sheets/{sheetId}/rows
. - The script waits for a response with the ID of the created row.
- If no ID is received (error or empty response body):
- A 2-minute wait period is initiated.
- The API search method
.../search?query=
is called to find the row by its content. - If the row is found (status code 200), its ID is retrieved, and the script continues.
- If the row is not found, another attempt is made to add it using
.../sheets/{sheetId}/rows
.
- This process repeats up to 5 times before the script terminates.
Issue:
The error SSS_REQUEST_TIME_EXCEEDED
(request timeout exceeded) occurs in NetSuite. However, the key problem is:
- When adding the parent field, a timeout error sometimes occurs.
- A search request using
.../search?query=
returns a 200 status code. However, the row does not actually exist in the table! Even after waiting for 2 minutes. - When attempting to add the row again, it successfully gets added. As a result, duplicate rows appear in the table.
Example: I attempt to add a row with the value “IT3775”, encounter a timeout error, wait 2 minutes and search for “IT3775”, get a status code of 200 (although the row is still not there), then try to add the row again and end up with duplicates.
Below I've provided the script execution logs from NetSuite (some fields are hidden as a security measure), as well as screenshot from the SmartSheet table so that you can see the problem clearly.
line 2347 - First attempt to add a parent line. (An error was occurred in the script, but eventually this field appears in the SmartSheet table).
line 2348 - Second attempt to add a parent line (successful).
line 2349 - Child fields.
P.S.I will provide the script code if needed.
Questions:
- Why does the .../search?query= method return status code 200 if the row is not in the table yet? (Why don't they return 204 or 404, for example?).
- How can this situation be handled properly to avoid duplicate rows?
- Could this issue be caused by a delay in data processing on Smartsheet’s side?
I’d appreciate any ideas or experiences in solving similar issues!
Thank you!
Best Answer
-
@Noterfull you will want to build more robust processing flags / handling into your sheet. For example, when you add the parent row, you can also add a specific flag for "needsChild" = true. Now you can search for needs child = true which is much easier to process. You should also use webhooks to process events rather than wait for indexing (this isn't a huge deal on SMAR but it is awful on microsoft graph and is in general good practice).
Recommended workflow
create row
create row webhook
get row
add child to row and uncheck needsChild
in event webhook fails
use the needsChild flag to cron process any missed webhook eventsPrincipal Consultant | System Integrations
Prime Consulting Group
Email: info@primeconsulting.com
Follow us on LinkedIn!
Answers
-
Hi @Noterfull,
It looks like the problem might be due to the fact that you’re attempting to add parent and child rows. I was able to determine that one user found the solution to this problem was to loop through the predefined items list and send POST requests to add child rows, linking them to the parent using the parentID.
Since it appears that your parent row is created successfully and the ID is provided, but the row is not showing until the second attempt, I’d recommend trying the above potential solution. If that doesn’t work, I’d suggest asking your question here: Community Forum for Smartsheet API.
Thanks,
Georgie
Need more information? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
@Noterfull you will want to build more robust processing flags / handling into your sheet. For example, when you add the parent row, you can also add a specific flag for "needsChild" = true. Now you can search for needs child = true which is much easier to process. You should also use webhooks to process events rather than wait for indexing (this isn't a huge deal on SMAR but it is awful on microsoft graph and is in general good practice).
Recommended workflow
create row
create row webhook
get row
add child to row and uncheck needsChild
in event webhook fails
use the needsChild flag to cron process any missed webhook eventsPrincipal Consultant | System Integrations
Prime Consulting Group
Email: info@primeconsulting.com
Follow us on LinkedIn! -
@prime_nathaniel Hello!
Sorry for not responding to your advice sooner. I’ve implemented what you described above, and I believe it will completely solve my problem. It’s currently going through the testing phase. I’m very grateful for your help! -
@Noterfull
No worries, happy its working out. don't forget to add a cron handler for backup since webhooks are by design not guarantees of processing.Principal Consultant | System Integrations
Prime Consulting Group
Email: info@primeconsulting.com
Follow us on LinkedIn!
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 67.9K Get Help
- 474 Global Discussions
- 207 Use Cases
- 517 Announcements
- 5.5K Ideas & Feature Requests
- 87 Brandfolder
- 157 Just for fun
- 83 Community Job Board
- 521 Show & Tell
- 36 Member Spotlight
- 3 SmartStories
- 309 Events
- 37 Webinars
- 7.3K Forum Archives