NetSuite - Custom Fields - Linked to Address Book but Inaccessible through JavaScript

Currently in the process of creating a Sales Order script to extract a custom field linked to the chosen shipping address. While I have successfully retrieved all address fields (such as city and zip), I am facing challenges when attempting to access any custom fields associated with the address.

Here's an example of the script:

var custid = document.getElementById("hddn_entity_fs").value;
var shiptoid = document.getElementById("hddn_shipaddresslist2").value;

var customer = nlapiLoadRecord("customer", custid);
var itemCount = customer.getLineItemCount('addressbook');

for (var i = 1; i < itemCount; i++) {
  if (customer.getLineItemValue('addressbook', 'id', i) == shiptoid) {

    //this section functions
    var zip = customer.getLineItemValue('addressbook', 'zip', i);
    console.log('zip:' + zip);

    //the following part encounters issues
    var custrecord19 = customer.getLineItemValue('addressbook', 'custrecord19', i);
    console.log('custrecord19:' + custrecord19);
  }
}

I know there must be a simple solution that I'm overlooking. Any insights or assistance you can provide would be greatly valued!

Sending gratitude your way,

Answer №1

Custom fields linked to addresses are stored within the address record itself.

For example, in SS1.0 dynamic mode (which is server-side only), you can access them like this:

var customer = nlapiLoadRecord('customer', custid, {recordmode:'dynamic'});
...
customer.selectLineItem('addressbook', i);
var addr = customer.editCurrentLineItemSubrecord('addressbook', 'addressbookaddress');
console.log(addr.getFieldValue('custrecord19'));

In SS1 server-side scripts that are not dynamic, you would use this approach:

var addr = custRec.viewLineItemSubrecord('addressbook', 'addressbookaddress', i);
console.log(addr.getFieldValue('custrecord19'));

In SS2.0, which works on both client and server side, you can do it like this:

var addr = custRec.getSublistSubrecord({sublistId:'addressbook', fieldId:'addressbookaddress', line:i});
console.log(addr.getValue({fieldId:'custrecord19'}));

An account may utilize a combination of SS1 and SS2 scripts.

To make everything compatible, I recommend converting your current client script to SS2. Here's an outline of a client script:

/**
 * @NApiVersion 2.x 
 * @NScriptType ClientScript
 */
define(['N/currentRecord', 'N/ui/message', 'N/url', 'N/https', 'N/search'],
    function(rec, msg, url, http, search) {



        return {
            fieldChanged : function(){ console.log('fired field changed');},
            postSourcing: function(){ console.log('fired sourcing');}
        };
    });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Shadows on menu buttons transform when clicked using React and CSS

I'm currently working on customizing the styling of a menu using CSS in a project that involves the use of "react-horizontal-scrolling-menu". While I've been successful in styling the menu items with .menu-item:hover & .menu-item:active, I am ...

Having trouble launching my Angular project

After encountering issues with my Angular project, I decided to reinstall Node.js and Angular CLI. However, when attempting to run ng serve, I was met with this error: view the image here I conducted a thorough search on Google for a solution, which direc ...

Unexpected behavior encountered with JQueryUI modal functionality

Today marks my first experience with JqueryUI. I am attempting to display a conditional modal to notify the user. Within my ajax call, I have this code snippet: .done(function (result) { $('#reportData').append(result); ...

Extract the value from JSON data

I am faced with the challenge of extracting the value of slug from each child in a JSON dataset. The issue lies in the fact that I cannot predict how many children will be generated whenever new data is received. The generation of nested children is dynam ...

The focus is being lost on the ng-model when used within an ng-repeat

Within my JavaScript code, I am initiating a new question object like this: $scope.newQuestion = { answers: [] }; This is how it reflects in the HTML: <div class="row" ng-repeat="answer in newQuestion.answers"> <div class="input-field col m ...

Refresh text displayed on a button with the help of setInterval

I need help updating the text on a button with the id fixed-button at regular intervals. Here is the code I am currently using: <script type="text/javascript"> $(function() { $('#fixed-button').setInterval(function() { ...

Transforming a dynamic background image into dynamic HTML elements

Having trouble parsing a background image to HTML elements. The images are retrieved from a database and the HTML elements are dynamically created. However, the image is not displaying. I attempted to include JavaScript in the while loop but encountered ...

What is the best way to trigger the download of an image file created by PHP to a user's computer?

My PHP code (upload.php) allows users to upload an image from index.html, resize it, add a watermark, and display it on the same page. Users can download the watermarked image by using the 'Save image as...' option. The resized image is saved in ...

Using a JavaScript command, connect a function from one file to another file

I attempted to import a function because I want to click on <il> servies</il> and scroll to the services section on the home page. However, I simply want to click on the li element in the navbar and scroll to the service section on the home pag ...

Tips for utilizing a Three.js curve to guide the movement of a mesh along a specified path

Developing an animation, currently at this stage: http://jsfiddle.net/CoderX99/66b3j9wa/1/ Please avoid delving into the code, it's written in CoffeeScript and may not be beneficial for your mental well-being. Imagine a "nordic" landscape with ship ...

Modify the href attribute of an anchor tag that does not have a specified class or

I am currently using an event plugin that automatically links all schedule text to the main event page through anchor tags, like this: <td><a href="http://apavtcongresso.staging.wpengine.com/event/congresso-apavt-2018/">Chegada dos primeiros c ...

Connecting extra parameters to an event listener

Scenario: I am facing a situation where my event handler is already receiving one parameter (an error object). However, I now need to pass an additional parameter when binding the event handler. I am aware of the bind() method, but I am concerned that it ...

Firebase User Becomes Undefined Upon Refreshing the Web Page

My situation is quite straightforward. I have developed a Firebase web application and I am logging in with my Google account. The problem arises when I have to keep logging back in every time the page is refreshed, as depicted in these steps: Initialize ...

Are your GetJSON requests failing to execute properly?

I have a code snippet that executes in a certain sequence and performs as expected. <script> $.getJSON(url1, function (data1) { $.getJSON(url2, function (data2) { $.getJSON(url3, function (data3) { //manipulate data1, data2, ...

What is the best way to dynamically change the color of my component depending on the prop passed to it?

I am facing an issue with the color of my component changing based on the value of the prop 'level'. Despite using states to set the backgroundColor, all components end up having the same color due to the state being altered for every comment. I ...

Can you explain the significance of the colon in this context?

Upon reviewing some SearchKit code snippets (composed with react/jsx and es2015), I came across the following line in a jsx file: const source:any = _.extend({}, result._source, result.highlight) I am curious about the purpose or significance of the colo ...

How to Set Up a Simple Gulp Uglify Configuration

My objective is to compress all .js files within my project and save a minified version in the same directory. Assuming this is the structure of my project directory: project/ gulpfile.js basic.js Project/ Project.js Toolbelt. ...

Utilizing Angular2 to access NPM package (Googleapis)

I am currently developing an Angular2 application that utilizes Webpack for the build process. I want to implement a Google oauth login feature in my application, so I have added the googleapi package from npm. However, I am facing difficulties when trying ...

Utilizing external functions in Node.js by importing them from different files

Struggling to import methods from my ./db/index.js into my server.js file in order to retrieve data from the database and show it. The content of /db/index.js is as follows: 'use strict'; const pgp = require('pg-promise')(); const pg ...

Error: Attempting to assign a value to property 'x' of an undefined object has resulted in a TypeError

When I tried to create an array of randomly generated circles (stars) in my first code, I encountered a TypeError on this line: stars[i].x = Math.floor(Math.random() * w) Even though stars is defined in the code, the issue persisted. $(document).ready(f ...