简体   繁体   中英

Module for replacing data in read-only fields in SuiteScript 2.0?

I am trying to build a Netsuite script to do the following:

  1. Load a saved search with transaction records
  2. Update value in the (read-only) "URL" field with a new hyperlink from a CSV list

I'm unable to find a SuiteScript 2.0 module which can interact with this read-only field. Here's the code I've been testing in the console so far. It successfully loads the saved search and results set in the browser console using the results.columns format (including an Internal File ID and the existing URL), but I'm not sure which module will allow me to actually replace that value with a new value.

 /**
 *  @NApiVersion 2.0
 *  @NScriptType ClientScript
 *
 *  1. Load saved search for files to update
 *  2. For each record in saved search, set URL field to new URL value  
 */

require(['N/search', 'N/file'], function(search, file) {
    var searchobj = search.load({
        id: 'customsearch_url'
    })
    var results=searchobj.run();
        console.log(results);
    results.each(function(result) {
        console.log(result);
        var URL = result.getValue(results.columns[4])
        console.log(URL);
        var fileId = result.getValue(results.columns[3])
        var fileObj = file.load({
            id: fileId
        })
        console.log(fileObj)
        return true;
    });
});

What's the best way to write this script to replace the value in the URL field with a new hyperlink?

To create/update/delete any record in NetSuite you need to use N/record module. First you should load/create a record which would return record object and then you can use record.setValue function to set/update values.

Or if you only want to update body fields, you can use record.submitFields instead.

What you are trying to do is not possible, NS URLs are system generated and cannot be updated/edited. That is the reason why it is (Read-Only), meaning you can ONLY read the data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM