NetSuite Dev Tools – Chat-GPT & Copilot

It seems AI is quickly making its way into developers’ tool bags. Here are some of my initial observations.

Chat-GPT: It’s great for writing functions or stubbing off SuiteScripts. I have not had much luck with a scope greater than a single function. I submitted the following to Chat-GPT and was happy with what it spit out.

Write a Suitelet in SuiteScript version 2.1 that does nothing.”

It responsede as follows:

/**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 * @NModuleScope SameAccount
 */
define([], function() {

  /**
   * Definition of the Suitelet script trigger point.
   * @param {Object} context
   * @param {ServerRequest} context.request - Encapsulation of the incoming request.
   * @param {ServerResponse} context.response - Encapsulation of the Suitelet response.
   * @Since 2015.2
   */
  function onRequest(context) {
    // Do nothing
  }

  return {
    onRequest: onRequest
  };

});

It was faster to use Chat-GPT to create this script, which I will use in debugger (after making the necessary changes), than it would have been to copy and rename a template. You can do the same for event scripts, map/reduce, scheduled, etc. It understands them all.

Copilot: I am much keener on Copilot than Chat-GPT in its current state. Copilot costs $10/month after a month free trial. It's worth it! Copilot will interrogate other open files/programs in vsCode, adding intellisense which incorporates functions from those files. Copilot can write whole functions, but not whole scripts. If you write a comment ahead of writing the function name, it reads your comment and incorporates that into its suggestion. In this example, I have a library open (logic_lib_v21_submitsql.js) in another tab. That library has a method called submitSQL() which accepts 2 parameters, a PL/SQL query and parameters used in the query. After writing the comment and naming the function, here was it's first suggestion.

Notice that it does not understand that companyname is not a field in the contact table. A join is required to reach companyname. It also gets the where clause wrong in the query.

When I hit [Alt] + ], here was the second suggestion, much improved! The join is still missing, but the where clause is correct. It ads a try/catch block and returns a single contact, which matches the comment.

Next, a couple of minor tweaks, adding a join to include customers, where Copilot was smart enough to auto-complete the join…

In summery (and I need to wrap it up), it’s been fun to see how AI is progressing in my industry. As developers, we are all joking now that Open AI is going to replace us. I’m old enough to know this is not true, but it can certainly change the way we write code. I’m all about efficiency, and these new AI-based tools are poised to significantly ramp up productivity.

Cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s