Question

Users have requested to be able to look up certain transaction types by internal ID. I would like to either configure global search to accommodate this request, or create a portlet to handle the need.

For the portlet option, I've created a JS function that takes the transaction type from a drop down and the ID from a text box and substitutes the values into a URL, then I wish to redirect the user to that URL.

Code sample: http://jsfiddle.net/9S9hL/3/

/* Portlet JS*/
function displayPortlet(){
    var title = "Search Transactions by ID";
    var content = "<iframe src='https://system.na1.netsuite.com/core/media/media.nl?id=10118&c=TSTDRV1179914&h=ec379d5559088dbde686&_xt=.html' style='width: 250px; height: 100px;'></iframe>";
    portlet.setTitle(title);
    portlet.setHtml(content);
} 

<!-- HTML file referenced by Portlet JS above-->
<script language='javascript'>
    function checkType(){
        var myType = document.getElementById('transType').value;
        var myID   = document.getElementById('transID').value;
        top.location.href = 'https://system.na1.netsuite.com/app/accounting/transactions/'+myType+'.nl?id='+myID+'';
    }
</script>

<form method='post' action='javascript' enctype='text/plain' onsubmit='checkType(this);'>
    Type: <select name='transType'>
        <option value=''></option>
        <option value='vendbill'>Vendor Bill</option>
        <option value='vendcred'>Vendor Credit</option>
        <option value='custinvc'>Customer Invoice</option>
        <option value='custcred'>Customer Credit</option>
    </select><br/>
    ID: <input type='number' name='transID' style='width: 75%;' /><br/>
    <input type='submit' name='submit' value='Search'' />
</form>

Am I on the right track? Can anyone point out any flaws in my code, logic or action plan? Am I over-thinking this?

I've tried Saved Searches, but the Internal ID as a filter on Saved Searches is in dropdown format, I need a text box. Also, the "Quick Search" portlet that exists in Netsuite does not search Internal IDs.

Thanks in advance.

Était-ce utile?

La solution

You've used getElementById. To make this work you have to add id attribute in you input and select fields.

<select name='transType' id="transType">
<input type='number' name='transID' style='width: 75%;' id="transID"/>

Secondly instead of using top.location.href you can use these two built in Netsuite functions

nlapiResolveURL ( type , subtype , id , pagemode )

nlapiSetRedirectURL ( type , subtype , id , pagemode , parameters )

Check http://suitecoder.appspot.com/static/api.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top