The sample script is a client side script triggered on save that would prohibit users to save a record with any inactive items on a transaction.
1. Create sample script.
function mySaveRecord(){
for (var i = 1; i <= nlapiGetLineItemCount('item'); i++) { // Loop through each of the items in the sublist
var itype = nlapiGetLineItemValue('item', 'itemtype', i); // Get the item type
var recordtype = '';
switch (itype) { // Compare item type to its record type counterpart
case 'InvtPart':
recordtype = 'inventoryitem';
break;
case 'NonInvtPart':
recordtype = 'noninventoryitem';
break;
case 'Service':
recordtype = 'serviceitem';
break;
case 'Assembly':
recordtype = 'assemblyitem';
break;
case 'GiftCert':
recordtype = 'giftcertificateitem';
break;
default:
}
var isinactive = nlapiLookupField(recordtype, nlapiGetLineItemValue('item', 'item', i), 'isinactive');
var item_name = nlapiLookupField(recordtype, nlapiGetLineItemValue('item', 'item', i), 'itemid');
if (isinactive == 'T') {
alert('Unable to save record. Item ' + item_name + ' is inactive.');
return false;
}
}
return true;
}
2. Save this as a JS file and deploy
3. Navigate to Customization > Scripting > Scripts > New
4. Upload Script File
5. Select Client
6. On Script record:
- Enter Name7. Under Deployments subtab:
- Save Record Function: mySaveRecord
- Applies To: Sales Order8. Save.
- Deployed: Yes
- Status: Release
DISCLAIMER: The sample code described herein is provided on an"as is" basis, without warranty of any kind, to the fullest extentpermitted by law. Oracle + NetSuite Inc. does not warrant or guarantee theindividual success developers may have in implementing the sample code on theirdevelopment platforms or in using their own Web server configurations.
Oracle +NetSuite Inc. does not warrant, guarantee or make any representations regardingthe use, results of use, accuracy, timeliness or completeness of any data orinformation relating to the sample code. Oracle + NetSuite Inc. disclaims allwarranties, express or implied, and in particular, disclaims all warranties ofmerchantability, fitness for a particular purpose, and warranties related tothe code, or any service or software related thereto.
Oracle + NetSuite Inc. shall notbe liable for any direct, indirect or consequential damages or costs of anytype arising out of any action taken by you or others related to the samplecode.
No comments:
Post a Comment