Using SuiteScript, we can set the return authorization status by setting the orderstatus field to any of the following values.
- Return Authorization:Pending Approval', 'RtnAuth:A'
- Return Authorization:Pending Receipt', 'RtnAuth:B'
- Return Authorization:Cancelled', 'RtnAuth:C'
- Return Authorization:Partially Received', 'RtnAuth:D'
- Return Authorization:Pending Refund/Partially Received', 'RtnAuth:E'
- Return Authorization:Pending Refund', 'RtnAuth:F'
- Return Authorization:Refunded', 'RtnAuth:G'
- Return Authorization:Closed', 'RtnAuth:H'
Example: This sample script should change the Return Authorization status to Pending Receipt.
var rec = nlapiLoadRecord('returnauthorization','1779'); //1779 should be a valid internal id
rec.setFieldValue('orderstatus','B');
var id = nlapiSubmitRecord(rec);
nlapiLogExecution('DEBUG','id',id);
Note: However, try to set the orderstatus field to 'H'
rec.setFieldValue('orderstatus','H');
which should ideally close the Return Authorization, the system will return this error.
> INVALID_KEY_OR_REF: Invalid orderstatus reference key H.
In this case, you need to iterate to the entire item sublist and set the isclosed field to True.
Here is the script to accomplish this:
var rec = nlapiLoadRecord('returnauthorization','1778');
for(var i=1;i<=rec.getLineItemCount('item');i++){
var isClosedVal = rec.getLineItemValue('item','isclosed',i);
if(isClosedVal == 'F'){
rec.setLineItemValue('item','isclosed',i,'T');
}
}
nlapiSubmitRecord(rec);DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Netsuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Netsuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Netsuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Netsuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
No comments:
Post a Comment