Accessing the text value of custom column with NetSuite SuiteScript - javascript

I am working with NetSuite's server-side SuiteScript and need to access the display value of several custom Transaction Column Fields. The fields in question are each set up as type "List/Record" and are associated with existing Custom Lists.
Working in the NetSuite Script Debugger, I have inspected the values returned from nlapiLoadRecord('salesorder', orderInternalId). Looking at the Items in the resulting object (e.g. obj.sublists.item.line 1) I see that some of these List/Record custom fields provide both a number (the ID of the selected List entry) and a string (the displayed text value of the List entry), but other custom fields do not.
For example, I have two custom fields with IDs custcol1 and custcol2. These are both of type "List/Record". When the sales order is loaded, nlapiLoadRecord provides the fields "custcol1" (number) and "custcol1_display" (string) for custcol1, but only "custcol2" (number) for custcol2. I do not see any difference in the settings for these two custom fields, so it is unclear why one provides the string and the other does not.
I need to retrieve the string values for both fields. Is there a setting change I need to make so custcol2 will automatically return a "custcol2_display" value? Or is there another API call I can use to take the number value from "custcol2" and look up the associated string value in the underlying Custom List?

Try using record.getLineItemText('item', 'custcol2', linenum)
For debugging, I tend to use Firebug - it's a lot more effective than the NS debugger and quicker than logging statements for just testing things out.

I just noticed this is two years old, but I think you can put columnname.id to get the data value. It works for standard columns but not sure about custom ones.
One thing I have learned to use is the NetSuite debugger, I don't use it like a standard debugger but rather like the javascript console. Just paste in some code into the box and then debug it, it is great for seeing what the dang property values are and the data in them which seems to be a crapshoot in NetSuite.

Related

Alfresco custom UI controls - Associations

I'm trying to build a custom UI control in alfresco to display the associations of an object type that I have.
Basically I have two object types; Code, which is a key value pair, and CodeScheme which contains multiple child associations to codes, it's essentially a mirror of a map structure I have in a different system.
The problem I have is that the codes are automatically generated, so they get the UID names, whereas really I'd like to present them as 'key=value', 'key=value', etc (ideally I'd like to present it as a table).
I've already created a custom control and added it to share-config-custom, and confirmed that the configuration is working correctly. What I'm not really clear on now is:
a) How to attach a javascript to the control so that I can process the association data.
b) How to get hold of the codes in javascript, and read their properties.
I'm just looking for a push in the right direction.
Thanks :)
One idea would be to use a form filter. Your form filter could iterate over the child references, fetch each child node, grab the data you want to display and then add one or more new properties with that data.
Then, your form control is hooked to the fields your form filter dynamically added to the form data. It can then read and display the data as needed.
Without a form filter I think you'd have to use JavaScript to parse the child association refs and use AJAX calls to fetch each child's node data, then format that as needed. The form filter idea would be less traffic from the browser.

Adobe DTM and arrays with varying numbers of elements

On our site, we have pages that can be assigned tags, and I'm having issues with figuring out how to handle this with Adobe DTM/Analytics. Each page can have between 1 and n tags being captured in an array. I can see them in the developer console just fine, ex:
> data.page.termIds
< [513, 1787, 115, 4330]
Each element corresponds to the tag ID.
I've been searching online but can't find any answers that really help me. This blog post is close, but it looks like they need to create a separate data element for each element in the array. I also found this question in the adobe forums, but it's similar to the blog post.
Does anyone know if this is even possible? Are we expected to create a block of data elements, with each one assigned to an array index?
Do not bother with the JS Object option unless you want to target a top level js object/variable. So for example foobar is okay but foo['bar'] or foo.bar is not. If you want to target anything "nested", skip JS Object and use Custom Script to check for it and return it, instead. This is because DTM doesn't do a good job of parsing or checking if the parent nodes exist before returning it. This is basically what was already said in the blog link you mentioned.
As for what the Data Element is returning and how to use it...the Data Element itself will have a return value of exactly what you return. So if you return an object, it will be an object. If you return an array, it will be an array. The trick (or caveat, or bug, depending on how you want to look at it) is how you reference or use the Data Element within the tools and rules.
The long story short of it is this: If you intend to use the %data_element_name% syntax (e.g. in any of the built in form fields in the rules, config settings, etc.) then you should only have your Data Element return a string type value (this is basically the issue the forum post link had, and I assume the issue you are running into).
If you want to be able to access it as some other type (e.g. the array, or js object in general), you need to use _satellite.getVar('data_element_name') syntax. The obvious drawback to this is it basically makes using DTM in a "non-coder" way useless in that you cannot use this in any of the built-in fields in rules. You can only use it in contexts where you can write javascript, e.g. Data > Custom type Conditions or in Javascript / 3rd Party Tag containers.
But one question for you is, what are you ultimately using the Data Element for? For example, if the end game here is you are looking to populate a prop or eVar or some other variable with a comma delimited string.. well just return your array as such in your Data Element and then you can use the %data_element_name% syntax.
Capturing the data is one thing and formatting is another.
My question is how do you need to see this data organized in reporting? Capturing the array itself doesn't do much unless you know what format you need it in. Are you hoping to capture these IDs and classify them? Do you want to see the array list by page?
Can you provide more detail on how you'll be reporting on these values?

What does the collection returned by CrmRestKit.RetrieveMultiple look like?

In a form in CRM2011 I am using a JavaScript function to retrieve some attributes from a custom entity unrelated to the one in the form.
I have a successful call to CrmRestKit.RetrieveMultiple but I don't know what the returned collection comprises. Can someone point me in the right direction, please?
To be a little more specific about the requirement: the query returns a set of Field schema names; i.e. the column being queried is in a custom entity and contains schema names of Fields. I want to match each one I retrieve against the calling form's collection of Field-based controls so that I can perform an action on matching ones. Any assistance towards that would also be gratefully received, thanks.
The easiest way I have found to know what you'll be working with is to take the output and run it through JSON.stringify() and write the contents of that out to the page.
For bits like this I usually just debug with IE. That will allow you to add breakpoints and inspect the object.
Related info: Debugging Script with the Developer Tools.

Rally App SDK 2.0: Hardcoded data values for rallymultiobjectpicker

Is it possible to input hardcoded values for a rallymultiobjectpicker? I have tried using the same method as a rallycombobox, but it does not seem to work. Is the rallymultiobjectpicker limited to getting values from a modelType? Is there any way to get values from a field on a artifact? Or is it strictly for objects? I suppose the alternative would be to use a rallycombobox with the multiSelect set to "true". However, there are no physical checkboxes, and the text field can become very crowded if there are many options selected.
Using hardcoded values for rallymultiobjectpicker is not currently supported, but that option will be available in a future version of the SDK.

Array of objects in Javascript - Struts Forms

This is for a web application using struts.
I have an array of objects in my Form that gets listed in a table. A user can add/edit/delete from the table. How would I send the changed table back to the Action class?
Will I need to create a string or array of strings, and parse that into an object? Is there a way that java/struts handles objects that are to be modified in the jsp? Or does this need to be cared for in javascript?
Struts binds the request parameters onto the ActionForm object based on name of the input.
actionFormObj.setBla(String x) { ... } matches <input name="bla"... in the form.
When you have related inputs, you can use maps or arrays for ActionForm properties and Struts is smart enough to treat them as well. See here.
Additionally, if your table contains read-only data that you switch to input when editing, you might have to deal with a lot of hidden fields in your form. If you still consider JavaScript as an option, you could create a POST request based on a JavaScript object (that you create with whatever data you wish from the table) and then use jQuery to send it. See here.
Indexed properties in struts, apparently takes care of this.

Categories