• Austin_Steve
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 9
    Replies

If I have multiple workflows on a single object is there a way I can guarantee one will happen before another? For example when the stage changes to Closed Won,  I would like a field on the opportunity object to get updated (using a workflow) before the email gets sent out (also using a work flow).

When you choose the new button and a record is created and your in the edit screen, is there a way to hide fields that I don't  want populated at first?

 

Thanks

 

Steve

 

I am trying to populate a formula field, and I'm getting the error:

"Formula(s) that reference this field are no longer valid: Compiled formula is too big to execute (5,048). Maximum size is 5000 characters.

 

Fields involved in the erroneous formula: 

Fixed__c = Check Box field

Invoice_Discount__c = percent field

Quote_Discount_Amount__c = formula field 

                   IF( Quote_Price__c > 0, Quote_Price__c - ( Quote_Price__c *  Quote_Discount__c ), 0)

Actual_Project_Price__c = Roll up sum field

 

Formula generating the error:
IF (  Fixed__c = TRUE,
   IF ( Invoice_Discount__c > 0,  Quote_Discount_Amount__c  - ( Quote_Discount_Amount__c *  Invoice_Discount__c ), Quote_Discount_Amount__c),  
   IF ( Invoice_Discount__c > 0, Actual_Pjoject_Price__c - (Actual_Pjoject_Price__c * Invoice_Discount__c ), Actual_Pjoject_Price__c))

 

Obviously this formula is not 5000 characters. Check syntax button says it's 984 characters long.  Why am I getting the error that formula is too big?

 

Thanks in advance for any help

 

steve

 

All,

 

I created a trigger to update a field on the Contacts object associated with a closed Opportunity.  Apparently one of our Accounts have more than 100 Contacts. I got an error that said  "caused by: System.Exception: Too many DML rows: 102"

What is the limit of records I can update in a single DML statement within a trigger?

 

Thank you in advance

 

Steve Hughes

 

I'm Trying to write a trigger that I can call from multiple custom objects.  I would like the trigger to pass an id from the object which is currently in focus to a class.  

Resource contains the field hourly rate, which is needed on both the Resource Assignment, and Time objects. Both are related to the Resource object.Ultimately the hourly rate field from the Resource Assignment, and Time objects are used in calculations on another object so a Rollup field is not an option.  

Here is how I envision it going:

 

trigger RAHourlyRate on Resource_Assignment__c(before insert, before update) {
     HourlyRate.Rate(/*pass the resource ID from the Resource Assignment Ojbect*/);
}
trigger TimeHourlyRate on Time(before insert, before update) {
     HourlyRate.Rate(/*pass the resource ID from the Time Management Ojbect*/);
}

public class HourlyRate{ 
  

  public static void Rate() { 
	/*Variable to receive the Resource ID passed from either the Resource assignment or Time Objects*/
   
    
    for(Resource r:[SELECT id, Hourly_Rate__c FROM Resource__c
            WHERE id = :Variable passed in from trigger]) {
      Resource_Assignment__c.hourly_rate__c = r.hourly_rate__c;
    } 
    Update Resource_Assignment__c;
    
  } 
} 

 

How do I pass the resource ID from the trigger to the class?
Will this work how I envision it or is this completely incorrect?

Thank you in advance for your help.

 

Recieving the error (NullPointerException) Unable to save resoure(s), when I try to compile the code below. 

 

Any guidance would be greatly appreciated. Thanks in advance.

 

 

public with sharing class TestUpDtCnt {

static testMethod void ActUpdateTest(){
//create the test account
Account a = new Account(Name='My Test Account',
industry='corporate');
insert a;

//create the test contact
Contact c = new Contact(
FirstName='Tester10101',
LastName='Tester10101',
CompanyInterest__c='NetSim',
accountid = a.id);
insert c;

Set<String> accSet = new Set<String>();
List<Contact> cnts = new List<contact>();

for (Account a2 : [select id from Account where name = 'My Test Account'] ){
accSet.add(a2.id);
}

cnts = [Select ID from Contact where accountid in:accSet];

try{
for (Account acct : [select id from Account where id in:accSet]){
for(Contact ct:cnts){
if (acct.Type == 'Customer - Netsim' || acct.Type =='Customer - NetsimOD'){
ct.Customer_Type__c = 'Former';
}
update cnts;
}
}
}catch (System.DmlException e){
System.debug('we caught a dml exception: ' + e.getDmlMessage(0));
}
}
}

 

 

I am getting the error above.  The code is below. I have systematically removed all code from this trigger to try and pinpoint what is generating this error. This what is left and it still generates the error;

 

 

trigger UpdCnt on Account (after update) {
List<Contact> cnt = new List<Contact>();
}

Obviously this trigger does nothing.  If I take out the one line that's in there it will Save to the Server.  

 

Any suggestions?

 

Austin_Steve

 

 

 

All,

 

I was wondering if it is possible to call a visualforce page from a trigger. I have a field on my account object that if it is true, I would like to call another visualforce page.  

 

Thanks,

 

Steve

 

I'm writing a trigger, and in an "If" statement I'm trying to test if the picklist option that was selected, starts off the "Cer" (there are about 15 options that start off with Cer). Instead of putting in each possible option that has "Cer" in an if or case statement, I would just like to test and see if the selection starts off with "Cer". I have tried using both these statements but ran into problems.

account.field.contains('Cer')  account.field.startswith('Cer')

That field on the account page is not mandatory (nor can it be). So the trigger works well if that field has a value, however if there is no value, I get an error that says:

Error:Apex trigger CalcMRRv2 caused an unexpected exception, contact your administrator: CalcMRRv2: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.CalcMRRv2: line 56, column 11

I would like to be able to use If (acc.field == 'Cer*'){

or something similar, but the wild card didn't seem to work.  Any suggestions?

 

Thanks

 

Steve

 

I'm trying to calculate the Monthly Recurring revenue, and place it on a field on the Opportunity screen.  I am running into a number of errors trying to do it my way.  I was wondering if anyone can help out with this calculation. Here is what I have so far.

 

trigger CalcMRR on Opportunity (after update) {
list<OpportunityLineItem> opps = new List<OpportunityLineItem>();
list<Opportunity> Oppts = new List<Opportunity>();
Set<String> OppSet= new Set<String>();

    for(Opportunity Opp : Trigger.new) {  
        OppSet.add(Opp.ID);
    }
   
  Oppts = [Select id, Month__c, Contract_Months__c  from Opportunity where ID in :OppSet limit 1];
  Opps =  [Select Id, OpportunityId, PricebookEntryId, Quantity,
            TotalPrice, UnitPrice, ListPrice, ServiceDate, Description,
            PricebookEntry.Name, PricebookEntry.ProductCode, PricebookEntry.Product2id
            From OpportunityLineItem
            Where PricebookEntry.ProductCode = 'Software'
            And opportunitylineitem.opportunityid IN :Oppset];
   
     for(Opportunity Opp: Trigger.new){
        for (OpportunityLineItem olist: Opps){
        if (Opp.Month__c!=null)
         Opp.Month__c = Opp.Month__c + olist.TotalPrice/Opp.Contract_Months__c;
         else
         Opp.Month__c = olist.TotalPrice/Opp.Contract_Months__c;
         }
     }
     if (Oppts.size() >0){
        update Oppts;
     }
}

 

Thank you in advance for any help you can offer.

 

Austin Steve

 

I am very new to salesforce, and even newer to Apex.  I'm trying to update a field on my account object, after an opportunity has been closed - won. Here is my first attempt;

 

trigger AccountTypeUpdate on Opportunity (after update) {
   
    Account myAccount=trigger.update[0];
    if (opportunity.StageName = 'A - Closed Won') {
     myAccount.type = 'Customer';
     update myAccount;
    }    //else nothing
}

 

Evidently it doesn't work, and I realize I would have to select the account associated with that opportunity, I'm just not sure how to go about doing that.  Any help would be greatly appreciated.  

When you choose the new button and a record is created and your in the edit screen, is there a way to hide fields that I don't  want populated at first?

 

Thanks

 

Steve

 

I am trying to populate a formula field, and I'm getting the error:

"Formula(s) that reference this field are no longer valid: Compiled formula is too big to execute (5,048). Maximum size is 5000 characters.

 

Fields involved in the erroneous formula: 

Fixed__c = Check Box field

Invoice_Discount__c = percent field

Quote_Discount_Amount__c = formula field 

                   IF( Quote_Price__c > 0, Quote_Price__c - ( Quote_Price__c *  Quote_Discount__c ), 0)

Actual_Project_Price__c = Roll up sum field

 

Formula generating the error:
IF (  Fixed__c = TRUE,
   IF ( Invoice_Discount__c > 0,  Quote_Discount_Amount__c  - ( Quote_Discount_Amount__c *  Invoice_Discount__c ), Quote_Discount_Amount__c),  
   IF ( Invoice_Discount__c > 0, Actual_Pjoject_Price__c - (Actual_Pjoject_Price__c * Invoice_Discount__c ), Actual_Pjoject_Price__c))

 

Obviously this formula is not 5000 characters. Check syntax button says it's 984 characters long.  Why am I getting the error that formula is too big?

 

Thanks in advance for any help

 

steve

 

All,

 

I created a trigger to update a field on the Contacts object associated with a closed Opportunity.  Apparently one of our Accounts have more than 100 Contacts. I got an error that said  "caused by: System.Exception: Too many DML rows: 102"

What is the limit of records I can update in a single DML statement within a trigger?

 

Thank you in advance

 

Steve Hughes

 

I'm Trying to write a trigger that I can call from multiple custom objects.  I would like the trigger to pass an id from the object which is currently in focus to a class.  

Resource contains the field hourly rate, which is needed on both the Resource Assignment, and Time objects. Both are related to the Resource object.Ultimately the hourly rate field from the Resource Assignment, and Time objects are used in calculations on another object so a Rollup field is not an option.  

Here is how I envision it going:

 

trigger RAHourlyRate on Resource_Assignment__c(before insert, before update) {
     HourlyRate.Rate(/*pass the resource ID from the Resource Assignment Ojbect*/);
}
trigger TimeHourlyRate on Time(before insert, before update) {
     HourlyRate.Rate(/*pass the resource ID from the Time Management Ojbect*/);
}

public class HourlyRate{ 
  

  public static void Rate() { 
	/*Variable to receive the Resource ID passed from either the Resource assignment or Time Objects*/
   
    
    for(Resource r:[SELECT id, Hourly_Rate__c FROM Resource__c
            WHERE id = :Variable passed in from trigger]) {
      Resource_Assignment__c.hourly_rate__c = r.hourly_rate__c;
    } 
    Update Resource_Assignment__c;
    
  } 
} 

 

How do I pass the resource ID from the trigger to the class?
Will this work how I envision it or is this completely incorrect?

Thank you in advance for your help.

 

Recieving the error (NullPointerException) Unable to save resoure(s), when I try to compile the code below. 

 

Any guidance would be greatly appreciated. Thanks in advance.

 

 

public with sharing class TestUpDtCnt {

static testMethod void ActUpdateTest(){
//create the test account
Account a = new Account(Name='My Test Account',
industry='corporate');
insert a;

//create the test contact
Contact c = new Contact(
FirstName='Tester10101',
LastName='Tester10101',
CompanyInterest__c='NetSim',
accountid = a.id);
insert c;

Set<String> accSet = new Set<String>();
List<Contact> cnts = new List<contact>();

for (Account a2 : [select id from Account where name = 'My Test Account'] ){
accSet.add(a2.id);
}

cnts = [Select ID from Contact where accountid in:accSet];

try{
for (Account acct : [select id from Account where id in:accSet]){
for(Contact ct:cnts){
if (acct.Type == 'Customer - Netsim' || acct.Type =='Customer - NetsimOD'){
ct.Customer_Type__c = 'Former';
}
update cnts;
}
}
}catch (System.DmlException e){
System.debug('we caught a dml exception: ' + e.getDmlMessage(0));
}
}
}

 

 

Hey All,

 

When Opportunity Stage== Received Specimen,

then Account.Type should be changed to "Customer".

 

Is apex trigger used to accomplish the task???Please suggest me. Any code provided, is appreciated.

 

Thanks-- Deepthi

All,

 

I was wondering if it is possible to call a visualforce page from a trigger. I have a field on my account object that if it is true, I would like to call another visualforce page.  

 

Thanks,

 

Steve

 

I'm trying to calculate the Monthly Recurring revenue, and place it on a field on the Opportunity screen.  I am running into a number of errors trying to do it my way.  I was wondering if anyone can help out with this calculation. Here is what I have so far.

 

trigger CalcMRR on Opportunity (after update) {
list<OpportunityLineItem> opps = new List<OpportunityLineItem>();
list<Opportunity> Oppts = new List<Opportunity>();
Set<String> OppSet= new Set<String>();

    for(Opportunity Opp : Trigger.new) {  
        OppSet.add(Opp.ID);
    }
   
  Oppts = [Select id, Month__c, Contract_Months__c  from Opportunity where ID in :OppSet limit 1];
  Opps =  [Select Id, OpportunityId, PricebookEntryId, Quantity,
            TotalPrice, UnitPrice, ListPrice, ServiceDate, Description,
            PricebookEntry.Name, PricebookEntry.ProductCode, PricebookEntry.Product2id
            From OpportunityLineItem
            Where PricebookEntry.ProductCode = 'Software'
            And opportunitylineitem.opportunityid IN :Oppset];
   
     for(Opportunity Opp: Trigger.new){
        for (OpportunityLineItem olist: Opps){
        if (Opp.Month__c!=null)
         Opp.Month__c = Opp.Month__c + olist.TotalPrice/Opp.Contract_Months__c;
         else
         Opp.Month__c = olist.TotalPrice/Opp.Contract_Months__c;
         }
     }
     if (Oppts.size() >0){
        update Oppts;
     }
}

 

Thank you in advance for any help you can offer.

 

Austin Steve