This topic contains 1 reply, has 0 voices, and was last updated by gourisankar 6 years, 4 months ago.

  • Author
    Posts
  • #21227

    Brandon

    So I am trying to have the items of a purchase order populate the items field on a new transfer order via a button on the PO. From there the user can make any changes they want to the record before submitting it and creating the TO. The main issue is I don't know how to populate a blank TO from script. I have it redirect there via a url string, but I'm sure there is a better way to do it.

    In summary.

    -User clicks "create TO" button on a PO

    -takes user to the "create TO" page where all the items (and some various info) is pre populated depending on the PO.

    -User edits the record and then submits it.

    ———-

    //create_to_button

    var newId ;

    var newType ;

    function beforeload(type)

    {

    if(nlapiGetContext().getRole() == '3')

    {

    if(type =='view' || type == 'edit')

    {

    newId = nlapiGetRecordId();

    newType = nlapiGetRecordType();

    if(newType == 'purchaseorder')

    {

    var strURL = "https://system.na2.netsuite.com/app/accounting/transactions/trnfrord.nl"

    var scriptbutton = 'window.open(' + String.fromCharCode(39) + strURL + String.fromCharCode(39) + ')' ;

    //nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, 'URL: '+strURL + '&id=' + newId);

    form.addButton('custpage_createpo', 'Create TO', scriptbutton);

    }

    }

    }

    }

    function loadTO() //(request, response)

    {

    nlapiLogExecution('DEBUG','<Before Load Script> type: '+type, 'hello');

    nlapiLoadRecord(newType, newId);

    }

    ——–

    Any ideas or advice is appreciated.

    -Brandon
    This is a cached copy. Click here to see the original post.

  • #21228

    gourisankar

    Hi brandon,

    you can use nlapiSetRedirectURL to open a new window.

    for your requirement below should work

    var param = new Array();

    params['id'] = purchaseorderid;

    params['transform'] = 'purchord';

    nlapiSetRedirectURL ('RECORD','transferorder',null,true,param)

You must be logged in to reply to this topic.