Expand your SuiteScript skills in the Sustainable SuiteScript community for NetSuite developers.

Dynamic External URLs pt 2

Created: September 7, 2017

Yesterday we expanded on this week's example by adding dynamic external URLs to our search result List. Perhaps your external system has more of a RESTful URL pattern. Rather than using URL parameters, your system may use a more path-like structure to access resources.

For instance, perhaps you have that system located at http://myservice.com, and the typical path to a Project in that system is like http://myservice.com/project/12345/

It is common to store the ID of a record from an external system in NetSuite's externalid field, so we would need to employ the dynamic property of setURL:

list.addColumn({
  id: 'recordurl',
  type: ui.FieldType.URL,
  label: 'Project Link'
}).setURL({
  url: 'recordurl',
  dynamic: true
})

Then we would update our data source to set the recordurl field correctly:

function resultToObject(result) {
  return {
    recordurl: 'http://myservice.com/project/' + result.id
    // ...
  }
}

And that's it! We'd have another style of dynamic links to our external system.