I am new at scripting. I am using this suitelet from NS answers . When the users run this script it just ends and leaves at a blank page. How can get this to go back to the home page after running this suitelet. I do know it would be nlapiSetRedirectURL('SUITELET', 'CARD_-29'); but I am having trouble placing this in my script below. Any help would be great.
/**
* Module Description
*
*/
/**
* @param {nlobjRequest} request Request object
* @param {nlobjResponse} response Response object
* @returns {Void} Any output is written via response object
*/
function formSuitelet(request, response){
if ( request.getMethod() == 'GET' )
{
var form = nlapiCreateForm('Bulk Close RMA');
form.addSubmitButton('Submit');
response.writePage( form );
}else{
var searchresults = nlapiSearchRecord(null,'customsearch_pc_bulk_close_rma');
// 'customsearch_pc_bulk_close_rma' is the internal ID of the custom saved search used to filter the records that the user would like to close
// make sure you have internal id in results on saved search.
for ( var i = 0; searchresults != null && i < searchresults.length; i++ )
{
var searchresult = searchresults[ i ];
var recID = searchresult.getValue('internalid');
nlapiLogExecution('debug', 'searchresult'+i, recID);
var rec = nlapiLoadRecord('returnauthorization', recID);
var lineNum = rec.getLineItemCount('item');
nlapiLogExecution('debug', 'lineNum', lineNum);
for ( var j = 1; lineNum != null && j <= lineNum; j++ )
{
nlapiLogExecution('debug', 'j', j);
var cLine = rec.selectLineItem('item', j);
nlapiLogExecution('debug', 'cLine', cLine);
rec.setCurrentLineItemValue('item', 'isclosed', 'T');
rec.commitLineItem('item');
}
var id2 = nlapiSubmitRecord(rec);
nlapiLogExecution('debug', 'id2', id2);
}
response.write('done');
}
}