HTML Portlet: getValue I've got an HTML portlet co...
# suitescript
r
HTML Portlet: getValue I've got an HTML portlet containing a list of custom links for Customer Dashboards. Some of the links require we pass the internalID of the customer record as part of the URL, which I've been able to include by setting a variable such as var nsInternalID = params.entity; I now need to get the value of an existing field so I can include that as a variable on certain links. I (think) I'm close using _var ABC = currentRecord.getvalue({fieldId: 'custom_field_name'})_ but I'm getting the error message Cannot find function getValue in object. I'm missing something or is there a better way to tackle this? Thanks -
b
share the code
r
I'm now trying source value of a custom field (in example below, abc) so it too can be passed as a variable. Here's what I've tried ... am I missing function(currentRecord)?
/**
* @NApiVersion 2.x
* @NScriptType Portlet
* @NModuleScope SameAccount
*/
define(['N/url', 'N/record', 'N/currentRecord'],
function(url, record, currentRecord)
/**
* Definition of the Portlet script trigger point.
*
* @param {Object} params
* @param {Portlet} params.portlet - The portlet object used for rendering
* @param {number} params.column - Specifies whether portlet is placed in left (1), center (2) or right (3) column of the dashboard
* @param {string} params.entity - (For custom portlets only) references the customer ID for the selected customer
* @Since 2015.2
*/
function render(params) {
var scheme = 'https://';
var host = url.resolveDomain({
hostType: url.HostType.APPLICATION
});
var currentRecObj = currentRecord.get ();
_*`var abc = currentRecObj.getValue('name_of_field');`*_
newLinkURL= scheme + host + '/app/common/search/searchresults.nl?searchid=12345&Entity_InternalID=' + params.entity + _*abc*_ ;
params.portlet.title = 'test portlet';
params.portlet.html = '<a href="' + newLinkURL + '">New Custom Link</a>' ;
}
return {
render: render
};
});
b
N/currentRecord is for use in client script
Specifically when you are on a record page
CurrentRecord will not work in serverside scripts like a portlet script
r
Ok - thanks. Is there a workaround?
b
you probably want to use N/search or N/record to get the information you need
r
@battk Thanks again for taking the time to reply. I was able to source the field without error using N/search (and learned a few things in the process)!