• whatever
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 4
    Replies

I'm attempting to write a generic field check that our users can easily update for merging with conga docs. 

I have a custom object that maps fields that are required for the docs to properly complete. I then create a sql query from those results and run it against the appropriate oject:

 

 

Map<id,Conga_Merge_Fields__c> reqFields = new Map<id,Conga_Merge_Fields__c>([select ID,field_name__c,object_name__c,deal_type__c from Conga_Merge_Fields__c where Object_Name__c = 'Property']);

 

 

Map<id,Merge_Fields__c> reqFields = new Map<id,Merge_Fields__c>([select ID,field_name__c,object_name__c from Merge_Fields__c where Object_Name__c = 'Property']);
for (Conga_Merge_Fields__c field : reqFields.values() )
{
query = query+field.Field_Name__c;
}
query = query+' from Property__c where id = \''+currentOpportunity.Property__c+'\'';
Property__c prop = Database.query(query);

I then query the DB with the query string and get the fields/values that are required.

 

I'm stuck on how i can loop over each returned field to check if it's null/blank/0. Is there any way to do this?  I need to know which field failed to properly direct the users on what needs to be fixed.

I'm working on going through our triggers and ensuring they will preform with a bulk load. There is a trigger that I'm lost on how to remove the select statement from the loop. The purpose of the trigger is to ensure 3 fields are unique in the database.

 

trigger PROP_LotBlockPlanIsUnique on Property__c (before insert, before update)

{

 

    for (Property__c currentProperty : Trigger.new)
    {

 

    for (Property__c currentProperty : Trigger.new)    

    {

 

list <Property__c> properties =

                [select id, name from Property__c where

                 Block_Number__c =: currentProperty.Block_Number__c and

                 Plan_Number__c =: currentProperty.Plan_Number__c and

                 Lot_Number__c =: currentProperty.Lot_Number__c and

                 id <>: currentProperty.id limit 1];

//If we have any properties with this LOT BLOCK PLAN - notify user.             

if (properties.size() <> 0 )

{

//Error

string errorMessage = 'Property Lot Block Plan is in use for property: ';

 

currentProperty.addError(errorMessage + properties[0].name);

currentProperty.Lot_Number__c.addError(errorMessage + properties[0].name);

}

     }

}

 

 

How could I move that query outside of the loop? I think my only option is to create a new field which concatenates the three fields together and use that in a query.

I have a custom number field on the Opportunity object: Desired DCR with a default value of 1.2. When I create a new opportunity the field is set to the default value correctly. When I convert a lead this field is left blank is this normal functionality? 

 

I have a workaround but this behaviour is difficult to understand. 

Thanks.

Hey,

 

    I have made many changes in a sandbox. Custom objects, Workflow, Leads/Account/Contact field removals, additions. Triggers, custom validation.

 

Just wondering what the easiest way to move this into production. Creating a change set and pushing the changes to the production instance? This would be a fairly huge changeset - curious about the most efficient way. All data in production (except leads) can be removed. 

 

 Thanks.

Hey,

 

      I've been having problems creating a custom object from an apex trigger on leads. Essentially I need a few extra objects created (and populated) if a lead is converted. The following trigger was just a test to see if creating a custom object when the convert button is triggerd would work - however it doesn't. Any help would be appreciated.

 

trigger LeadConvert on Lead (before update) {

    // insert a custom object associated with the contact
    GIC_Deal__c obj = new GIC_Deal__c();
    obj.Name = 'temp';
    insert obj;
}

 

Hi all'

 

I got a exception as below. Any suggestions? Thanks in advance:

 

"Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger RentMergeTrigger caused an unexpected exception, contact your administrator: RentMergeTrigger: execution of BeforeUpdate caused by: System.Exception: Too many script statements: 10201: Class.RentMerge.RentCalculate: line 70, column 8"

 

Code:

 

 public void RentCalculate(Account a){

      Integer i = 1;

  Decimal DCR = 0;
  Decimal GrossMonthlyRent = 0;
  Decimal H42=0;
  Decimal K38=0;
  Decimal GrossMonthlyExpense=0;
  Decimal TotalExpenses=0;
  Decimal BridgeCapitalRoundup=0;
  Decimal BridgeC=0;
  Decimal PMT1st=0;
  Decimal PMT2nd=0;
  Decimal JV_GIC_Consultant_Fee=0;
  do
  {
       GrossMonthlyRent=i;
     if (a.CMA_Property_Value__c > 250000){JV_GIC_Consultant_Fee=8500;}
     else{JV_GIC_Consultant_Fee=7500;}
     
     if (a.Condo_Fees__c == 0){
    GrossMonthlyExpense=GrossMonthlyRent*0.15;
   }else{
    GrossMonthlyExpense=a.Condo_Fees__c;
   }
     
       H42=(GrossMonthlyRent*(1-0.05))-GrossMonthlyExpense-a.Rent_Tax__c;
 
   
   
   
    //////////////////Caculate the updated TotalExpenses --> updated PMT1 and PMT2
       BridgeC=a.X2nd_Mtg_Amount__c  +a.X3rd_Mortgage_Amount__c  + a.X4th_Mtg_Amount__c +a.X1st_Writ_Amount__c + 
        a.X2nd_Writ_Amount__c +  a.X3rd_Writ_Amount__c
          +  a.X1st_Caveat_Amount__c  +  a.X2nd_Caveat_Amount__c  +  a.X3rd_Caveat_Amount__c + 
          a.Misc_Expense_1__c  +  a.Misc_Expense_2__c  +  a.Misc_Expense_3__c  +  a.Misc_Expense_4__c
           +  a.Misc_Expense_5__c  +  a.Misc_Expense_6_Amount__c +
           a.Arrears_Estimate__c  +  a.Foreclosure_Legals_Estimate__c +  a.LTV_Insurance__c + 
           a.Taxes__c   + a.Processing_Fee_Bridge_Capital_GIC__c  +
           a.Appraisal__c  +  a.Title_Insurance__c  +  a.Real_Property_Report__c  + 
           a.Renovations_Interior__c  +  a.Renovations_Exterior__c  +  a.Renovations_Extras__c
           +  a.Payout_Penalty_Mortgage_1__c  +  a.Payout_Penalty_Mortgage_2__c  + 
           a.Payout_Penalty_Mortgage_3__c  +  a.Payout_Penalty_Mortgage_4__c    +
           (GrossMonthlyRent-a.Rent_Payoff_Monthly__c)*6 + a.Legal_Fees_Purchase__c + 
           a.Legal_Fees_Purchase_Dispursments__c  +  a.Legal_Fees_Placing_New_Financing__c  +  
           a.Legal_Fees_Placing_New_Fin_Dispursment__c   +  a.Legal_Fees_Sell__c  + 
           a.Legal_Fees_Sell_Dispursment__c  +  a.Investor_Fee_1st_Mortgage__c  + 
           a.Carrying_Costs__c  +  JV_GIC_Consultant_Fee  + 
           JV_GIC_Consultant_Fee  +  a.Reserve_Contingency__c + 
           GrossMonthlyRent*6  + a.Selling_Realtor_Fees__c  +  a.Listing_Realtor_Fees__c;
    BridgeCapitalRoundup=(Decimal)(math.round(BridgeC*1.05/1000))*1000;
       TotalExpenses = a.X1st_Mtg_Amount__c + BridgeC + (BridgeCapitalRoundup/1.05)*(0.03+0.02) ;
 
       If(TotalExpenses <= a.CMA_Property_Value__c*0.75)
       {
        PMT1st = TotalExpenses  * ((0.058 / 12) / (1-math.pow((1+(0.058 / 12)),(-25*12))));
        PMT2nd = 0;
       }
       else
       {
        PMT1st = a.CMA_Property_Value__c*0.75  * ((0.058 / 12) / (1-math.pow((1+(0.058 / 12)) , (-25*12))));
          PMT2nd = (TotalExpenses - a.CMA_Property_Value__c*0.75)* ((0.15 / 12) / (1-math.pow((1+(0.15 / 12)) , (-25*12))));
       }
       ////////////////////
       
       K38=PMT1st+PMT2nd;


       DCR=H42/K38;//line70
       
       if (DCR <= 1.2 && i<20000){
         i++;       
       }else{
        i=0;
       }
       
  }while (i>0);
     

     a.Rent__c=GrossMonthlyRent;
      
       //}//end "for"
   }//end of method

I have a custom number field on the Opportunity object: Desired DCR with a default value of 1.2. When I create a new opportunity the field is set to the default value correctly. When I convert a lead this field is left blank is this normal functionality? 

 

I have a workaround but this behaviour is difficult to understand. 

Thanks.

Hey,

 

      I've been having problems creating a custom object from an apex trigger on leads. Essentially I need a few extra objects created (and populated) if a lead is converted. The following trigger was just a test to see if creating a custom object when the convert button is triggerd would work - however it doesn't. Any help would be appreciated.

 

trigger LeadConvert on Lead (before update) {

    // insert a custom object associated with the contact
    GIC_Deal__c obj = new GIC_Deal__c();
    obj.Name = 'temp';
    insert obj;
}

 

Hi, 

 

Can anyone suggest a solution to overcome the error of "Too many script statements: 200001" in apex class.

 

I wanted to display the sum of resource amount in opportunity products for an Opportunity sorted by Account wise.

 

below is the sample code:

 

query resource amount from opportunity products sort by account name

 

put the opportunity inside SET to avoid duplicates (uniqoppid)

 

put the account id inside SET to avoid duplicates ( uniqaccid)

 

for(each unique account)

{

for(each unique opportunity)

{

for( sum resource amount from all opportunity products)

{

if(uniqoppid == opportunity in opportunity products && uniqaccid == opportunity product->opportunity->account id)

{

//code to display the resource amount

}

}

}

}

 

the above code in red line is the problem. It shows too many script statements: 200001

 

 

Message Edited by Shalini on 06-09-2009 06:03 AM
Hi All,
 
I have a query on web-to-lead. I have created two web-to-lead HTML pages for different record types basing on the fields and the lead records needs to be created in thier respective record types when the form is submitted, but all the lead forms which get submitted are getting created in the default record type and not in their respective record types. How can I solve this issue?
 
Thanking You
Bharat Baradia