function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KarenCKarenC 

strange issue with trigger and button....



I don't know java, however, I received some help and wrote a button to clone a quote...see revise button below..

Here is the code behind the button:  

 

 

{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}result = sforce.connection.query("select id,opportunityid from Quote where id = '{!Quote.Id}'")window.top.location.href =    "{!URLFOR( $Action.Quote.NewQuote ,null,[clone=1,id=Quote.Id,retURL="/"&Quote.Id],true)}&oppid=" +result.records.OpportunityId +"&00N60000001rya1=1&00N60000001rtxU={!Quote.Version__c+1}"

 

When the insert on the cloned quote is done a before insert trigger is fired.  The purpose of the trigger is to find the max revision number within a quote within an opportunity and then increment the revision number by one.

 

The trigger works fine as long as I have all the fields displayed on the screen below.  The weird part is once I remove some of these fields from the page layout the trigger no longer works.  I don't want to leave the fields (such as revision_chkbox__c) as these fields are behind the scene fields as switches.  

 

Sorry for long post -

 

Please advise,,,,I am banging my head against the wall....

 

 
trigger quoteversioning on Quote (before insert) {
    Quote q;
    for (quote insertedquote : Trigger.new) {
        if (insertedquote.revision_chkbox__c == true) {
            q = [select version__c from quote
                where quote_number_test__c = :insertedquote.quote_number_test__c and
                      opportunityid = :insertedquote.opportunityid
                order by version__c desc
                limit 1];
            insertedquote.version__c = q.version__c + 1;
        }
    }
}