This topic contains 2 replies, has 0 voices, and was last updated by david.smith 7 years, 5 months ago.
-
AuthorPosts
-
May 30, 2017 at 8:41 am #963
tect22Hi Guys,
Sharing to you a snippet I made to quickly view the XML of the record.
Details: It adds two buttons, one will open the XML View on the same window, the other one will open it in a new tab hence the label NW.
Code:
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define([‘N/runtime’,’N/ui/serverWidget’],
/**
* @param {runtime} runtime
* @param {serverWidget} serverWidget
*/
function(runtime,serverWidget) {/**
* Function definition to be triggered before record is loaded.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord – New record
* @param {string} scriptContext.type – Trigger type
* @param {Form} scriptContext.form – Current form
* @Since 2015.2
*/
function beforeLoad(scriptContext) {
var form = scriptContext.form;
if(runtime.executionContext === runtime.ContextType.USER_INTERFACE)
if(scriptContext.type === scriptContext.UserEventType.VIEW){
form.addButton({
label:’XML View’,
id:’custpage_xml_view’,
functionName:’nlapiChangeCall({“xml”:”T”})’
});
form.addButton({
label:’XML View NW’,
id:’custpage_xml_view_nw’,
functionName:’window.open(nlapiResolveURL(“RECORD”,nlapiGetRecordType(), nlapiGetRecordId()) + “&xml=T”)’
});
}
}return {
beforeLoad: beforeLoad
};});
Hope this help you in some way.Regards.
This is a cached copy. Click here to see the original post. -
June 1, 2017 at 9:21 pm #964
chanarbonGreat addition to the knowledge in the usergroup
-
June 2, 2017 at 12:00 pm #965
david.smithMixing SS1 and SS2.
You could just use pure JavaScript on your buttons:
Code:
window.location = window.location.href+’&xml=T’ -
AuthorPosts
You must be logged in to reply to this topic.