In my last two blogs(Tip 43 & Tip 44), we saw, how to write scripts to do CSV Import job using SuiteScript in different versions.
In this blog, we will be comparing both Suitescript versions with the same task and when to use which version.
SuiteScript 1.0 | SuiteScript 2.0 |
You will get Task ID in Numeric format in response code. | You will get task ID as a combination of some random characters on submitting the task. |
Task ID can be used to get CSV Response File link. | This task ID can’t be used get CSV Response File link. |
You can’t check status of the job in this version. | Provides API to check status of the task. But here is one problem, the Status says “COMPLETED”, even if the CSV Import is not successful. We will discuss about it more below. |
So, now we saw different features provided by NetSuite in different versions.
Now let’s think about how to decide which version of code we should go with.
My answer to this question is analyze the requirement first.
- If requirement is just to execute CSV Import through script, and client is not worried about responses/status, then you can go with either version.
- If requirement is like user wants to know about the Response details like, whether all records imported correctly or not, and they want check that by downloading the response file, you should go ahead with SuiteScript 1.0. You can check my blog(https://ashabarijena.wordpress.com/2023/07/10/tip-44-fetch-csv-import-response-file-link-after-csv-import-using-suitescript/) about how to achieve that. Also, note that SuiteScript 1.0 doesn’t give you task status details. While sending Response file link, let the user know, she/he may need to wait for sometime to download the response file, in case she/he gets any error.
- If the requirement is like, send an update email or do something else, once the CSV Import job is finished, then go ahead with SuiteScript 2.0.
Suggestion to NetSuite: Here I feel little weird regarding the Job status text that we get. Irrespective of the CSV Import creates/updates all records successfully or not, we get status code as “COMPLETED”.
It would have been great, if for unsuccessful job completion, we could get a different status name like “UNSUCCESSFUL” or something like that. At least looking into that status, user will get to know, for this job, not all records have not been through. So let me go ahead and check the response file and figure out the issue. As current feature only provides “COMPLETED”, user has to go to Job status page every time to see which one is successful and which one is not.
Let me know, what do you think.
NOTE: There is an enhancement ticket() raised for adding feature to SuiteScript 2.0 to provide APIs for downloading CSVresponse file. Please vote for that, so that we can have the feature earlier.
Enhancement details: Enhancement 366617: SuiteScript: Import/Export > View CSV Import Status > Ability to get the CSV Response files using script and store them in file cabinet
Hope this blog will help you while deciding which version of code, I should be using.
Happy Coding 🙂
Thank You
Asha