Table level script on Opportunity auto created by Quote

SOLVED

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
}

Parents
  • 0

    Michele

    I think that they do fire but they may loose contextual information.  A quote is a child of an opportunity.  An opportunity is in turn a child of company and person.  A lot has to happen to ensure referential integrity when a quote us created.

    And other stuff is firing like updating escalation and journal tables.

    If we insert a new Quote the following will happen (I think)

    The Oppo is created.
    The Oppo is updated
    The Quote is then updated
    The Quote is further 
    The Oppo is updated again

    Try and do a an investigation of the contextual information that is maintained as an 'auto' created opportunity is inserted.

Reply
  • 0

    Michele

    I think that they do fire but they may loose contextual information.  A quote is a child of an opportunity.  An opportunity is in turn a child of company and person.  A lot has to happen to ensure referential integrity when a quote us created.

    And other stuff is firing like updating escalation and journal tables.

    If we insert a new Quote the following will happen (I think)

    The Oppo is created.
    The Oppo is updated
    The Quote is then updated
    The Quote is further 
    The Oppo is updated again

    Try and do a an investigation of the contextual information that is maintained as an 'auto' created opportunity is inserted.

Children