I am working in a system that auto creates an opportunity when a quote is created. I would like for some data from the quote to be populated on the opportunity. A simple example would be the Quote Reference ID. I would like this to populate in the description field of the Opportunity. Right now it just says "Auto:"
I tried to add this as a table level script on the Opportunity (Insert Record). However, it does not appear to fire. Do table level scripts not fire for an opportunity when they are auto created by a Quote? Or perhaps I have structured my Table Level Script incorrectly? Maybe I should have used a Post Insert Script on the Quote record???
This is what I have on the Opportunity entity for the table level script. However, it does not appear to fire. Any assistance would be greatly appreciated. Thank you!
function PopulateQuoteData()
{
//Get the primary key of the inserted record
var oppoRecord = CRM.FindRecord("Opportunity",WhereClause);
var oppoID = oppoRecord.oppo_opportunityid;
//Transfer values from Quote to Opportunity=======================================
//Values from Quote Record---------------------------------------------------------
var quoteRecord = CRM.FindRecord("Quotes", "quot_opportunityid="+oppoID);
var quoteRef = quoteRecord.quot_reference;
var oppoRef = quoteRef.slice(2); //Removing Q- from start of quote reference
//Update Opportunity record-------------------------------------------------------
while (!oppoRecord.EOF)
{
oppoRecord.oppo_description = oppoRef; //Reference
oppoRecord.NextRecord();
}
oppoRecord.SaveChangesNoTLS();
//End Transfer values from Quote to Opportunity====================================
}
function InsertRecord()
{
// Handle insert record actions here
PopulateQuoteData();
}
function PostInsertRecord()
{
// Handle post insert record actions here
}
function UpdateRecord()
{
// Handle update record actions here
}
function DeleteRecord()
{
// Handle delete record actions here
}