This topic contains 2 replies, has 0 voices, and was last updated by david.smith 7 years, 5 months ago.

  • Author
    Posts
  • #963

    tect22

    Hi 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.

  • #964

    chanarbon

    Great addition to the knowledge in the usergroup

  • #965

    david.smith

    Mixing SS1 and SS2.

    You could just use pure JavaScript on your buttons:

    Code:
    window.location = window.location.href+’&xml=T’

You must be logged in to reply to this topic.