You need to sign in to do that
Don't have an account?

Update to an existing trigger...switching from a custom quote object to the standard quote object
Good afternoon. Before I start contracting work out, I thought I would ask here. We have a custom object for quotes and we are in the process of switching to the standard object. During our original implementation, a trigger was built so that everytime a quote was created, or a subsequent quote was created on an opoortunity, it would give the quote a "number" which in turn, make that number a letter. So, you end up with quote revisions.
So on the trigger, I no longer want to reference the customer quote object (in bold), I want to reference the standard which would be Quote__c (I assume). Here is a small portion of the trigger as it is today. When I change the bold text to Quote__c, this is the error:[Error] Error: Compile Error: Invalid SObject type name: Quote__c at line 1 column 32
trigger PrimaryQuoteTrigger on SFDC_520_Quote__c (before insert, before update, before delete, after insert, after update) {
// Rules:
// #1 Can't delete primary quote
// #2 Primary quote cannot be un-marked primary. A different existing quote must be marked primary which will unmark the others.
// #3 Only one primary quote per oppy
// #4 First quote on oppy must be primary
Any help would be appreciated. Thanks, Nikki ~
So on the trigger, I no longer want to reference the customer quote object (in bold), I want to reference the standard which would be Quote__c (I assume). Here is a small portion of the trigger as it is today. When I change the bold text to Quote__c, this is the error:[Error] Error: Compile Error: Invalid SObject type name: Quote__c at line 1 column 32
trigger PrimaryQuoteTrigger on SFDC_520_Quote__c (before insert, before update, before delete, after insert, after update) {
// Rules:
// #1 Can't delete primary quote
// #2 Primary quote cannot be un-marked primary. A different existing quote must be marked primary which will unmark the others.
// #3 Only one primary quote per oppy
// #4 First quote on oppy must be primary
Any help would be appreciated. Thanks, Nikki ~
Cyrus T
www.levementum.com
All Answers
Cyrus T
www.levementum.com
Error: Compile Error: Entity is not api accessible at line 1 column 32
Review all error messages below to correct your data.
Apex trigger StandardQuoteRevisionNumTrigger caused an unexpected exception, contact your administrator: StandardQuoteRevisionNumTrigger: execution of BeforeInsert caused by: System.StringException: Invalid id: 6018393: External entry point
Above the number (6018393) is the opportunity number just FYI.
Here is the trigger:
trigger StandardQuoteRevisionNumTrigger on Quote (before insert) {
List<Id> oppys = new List<Id>();
for (Quote quote : Trigger.new) {
oppys.add(quote.Opportunity__c);
}
List<Quote> quotes = [SELECT Id, qrnum__c, Opportunity__c FROM Quote WHERE Opportunity__c IN :oppys];
for (Quote quote : Trigger.new) {
Double qrNum = 0;
for (Quote quote2 : quotes) {
if (quote2.Opportunity__c == quote.Opportunity__c) {
qrNum++;
}
}
quote.qrnum__c = qrNum+1;
}
for (Integer i = Trigger.new.size()-1; i>-1; i--) {
Quote quoteA = Trigger.new[i];
for (Integer j = i-1; j>-1; j--) {
Quote quoteB = Trigger.new[j];
if (quoteA.Opportunity__c == quoteB.Opportunity__c) {
quoteA.qrnum__c = quoteA.qrnum__c + 1;
}
}
}
}
Cyrus T
www.levementum.com
List<Id> oppys = new List<Id>();
to
List<string> oppys = new List<string>();
and that did the trick! Pretty excited that I was able to accomplish this! Thanks again for your tip! It helped get me 90 % there! I really appreciate it!