Discussions
Creating Quote from Project Record Script
I'm trying to create a quote via a script from a project record. The project record contains all the information I need to create the quote, but for some reason when I use a client side script to create the quote - I get the following error message:
An unexpected error occurred in a script running on this page.
createChangeOrderButton (button)
customscript_g5_cs_project
INVALID_CUSTOMER_RCRD
This customer record -1 is not valid. Please create the customer first.
I've created a client side button with the following code:
function createChangeOrderButton(){ var projectId = nlapiGetRecordId(); var customer = nlapiGetFieldValue('parent'); //create quote var recQuote = nlapiCreateRecord('estimate'); var recQuoteId = recQuote.getId(); nlapiSetFieldValue('custbody_reseller',3415); nlapiSetFieldValue('custbody_distributor',3414); nlapiSetFieldValue('custbody_end_user',13814); nlapiSetFieldText('custbody_order_type','Contract - New'); nlapiSetFieldValue('custbody_bill_to_tier',1); nlapiSetFieldValue('custbody_ship_to_tier',1); nlapiSetFieldText('probability','60%'); nlapiSetFieldValue('entity',3415); recQuote.selectNewLineItem('item'); recQuote.setCurrentLineItemValue('item', 'item', 24); recQuote.setCurrentLineItemValue('item', 'project', projectId); recQuote.commitLineItem('item'); var reqQuoteId = nlapiSubmitRecord(recQuote, false, true); var quoteURL = nlapiResolveURL('RECORD', 'estimate', recQuoteId, true); window.open(quoteURL, '_blank'); }