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
    SUGGESTED

    Also from a SQL point of view you could do a SQL Trigger that when it is created, if it is an Auto: Opportunity to see if there is a quote associated with it and at that point to update with the Reference of it. 

  • 0 in reply to Matthew Shaw

    Thank you Matthew:  I have tried to stay away from SQL triggers in CRM and use TLS.  However, I have found that although TLS are supposed to behave similar to SQL triggers, they don't seem to and I have a lot of trouble understanding what theTLS's are actually doing.

    I was using SQL server with databases prior to working with CRM..so I have an understanding of SQL triggers.  I have been feeling more and more that I should just use the SQL triggers.

    Do you find that you use SQL triggers frequently?  Thanks!

  • +1 in reply to Michele Gaw
    verified answer

    Hi Michele

    It's my background, I don't know JavaScript so don't use TLS, we have developers who from time to time will use them. 

    But I'm much more comfortable in SQL and have done lots of work in there (e.g. On opportunities workflows to auto create communications, or populate Sage 200 with the CRM Order number) 

    Depending on the table / situation I would do triggers, scheduled jobs or call on a stored procedure  

Reply
  • +1 in reply to Michele Gaw
    verified answer

    Hi Michele

    It's my background, I don't know JavaScript so don't use TLS, we have developers who from time to time will use them. 

    But I'm much more comfortable in SQL and have done lots of work in there (e.g. On opportunities workflows to auto create communications, or populate Sage 200 with the CRM Order number) 

    Depending on the table / situation I would do triggers, scheduled jobs or call on a stored procedure  

Children
No Data