• Deloitte IT Admin 2
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 2
    Replies
Hi All,

I've created a trigger that pupulate the Account lookup field on my custom object.
As shown in figure, when I create a new custom object, my trigger do not write the Account:
User-added image

But when i press 'Save', the Account field is populated:

User-added image

I would like to pupulate the Account also in the first picture, when I create a new object.

Here's my code:
 
trigger afterPlanningTrigger on Pipeline__c (after insert) {

    for(Pipeline__c p: Trigger.new)
    {
        List<Pipeline__c> pi = [select id, Account__c, Opportunity__r.Account.id,Opportunity__r.Owner.id from Pipeline__c where id=:p.id];
        
        pi[0].Account__c = pi[0].Opportunity__r.Account.id;
        pi[0].Opportunity_Owner__c = pi[0].Opportunity__r.Owner.id;
       
        update pi[0];
    }
}

 
Hi All,

i've got this Save method that gets called when users press a button. If users press it more than one time while the page is not completely loaded, this causes problems. 
Any idea on how to solve this issue? Here's the save method:
 
public PageReference save() {
    
        update ppl ;
        Boolean fyok = true;
        Set<Decimal> fypresent = new Set<Decimal>();
        for (Pipeline_Item__c pl: ppl.Pipeline_Items__r)
        {
            if (pl.Fiscal_Year__c!= null && pl.Fiscal_Year__c!= 0)
            {
                if (fypresent.contains(pl.Fiscal_Year__c)){
                  fyok = false;
                }
                fypresent.add(pl.Fiscal_Year__c);
          } 
        }
        if (fyok){
            for (Pipeline_Item__c pl: ppl.Pipeline_Items__r)
            {
                update pl;
            }
      }
      reload();
      update ppl ;

      fyok = true;
       fypresent = new Set<Decimal>();
        for (Pipeline_Item__c pl: ppl.Pipeline_Items__r)
        {
            if (pl.Fiscal_Year__c!= null && pl.Fiscal_Year__c!= 0)
            {
                if (fypresent.contains(pl.Fiscal_Year__c)){
                  fyok = false;
                }
                fypresent.add(pl.Fiscal_Year__c);
          }
        }
        if (fyok){
            for (Pipeline_Item__c pl: ppl.Pipeline_Items__r)
            {
                update pl;
            }
      }

       updateActualsMor();  
       return null;
     
        reload();
        return null;
    }

 
Hi All,

Here's my table, as shown below. I've inserted the underscores in order to set a standard width. I would like to set the underscores' color in blue, like the background.  
User-added image

That's the code for a cell:
<th data-field="name">__Mar__</th>

How can I set two different colors in this row?

Thankyou

 
Hi All,
I would like to write, instead of N, the current year in this table in a vf page:
 
<th style="width:15%" data-field="name">Yr N</th>            
<th data-field="price" colspan="5">N</th>                 
<th data-field="price" >N+1</th>
<th data-field="price">N+2</th>
<th data-field="price">Beyond N</th>
            
Any idea?

Thankyou!
Hi, I'm trying to write into a field, Actuals_P1_MOR__c, the number 100 (for example). This field belong to Pipeline_Item__c object. So, at the end, I update the List pl that is made of Pipeline_Item__c records, in order to update every Actuals_P1_MOR__c.

But I get this error:

System.LimitException: DML currently not allowed 
 
for (Pipeline_Item__c p : pl)
            {
                
                if (p.Actual_P1_MOR__c== null){
                    p.Actual_P1_MOR__c=0;
                }

                if (p.Pipeline__r.CurrencyIsoCode=='USD')
                {
                    p.Rate_to_USD__c=1;

                } else {

                    p.USD_MOR_1__c=morMap.get('January');
                    p.USD_MOR_2__c=morMap.get('February');
                    p.USD_MOR_3__c=morMap.get('March');

                    
                
                 if (p.Pipeline__r.CurrencyIsoCode=='EUR')
                {
                    String cic = 'EUR';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                   

                }
                else if (p.Pipeline__r.CurrencyIsoCode=='BRL')
                {
                    String cic = 'BRL';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='CAD')
                {
                    String cic = 'CAD';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='PLN')
                {
                    String cic = 'PLN';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='GBP')
                {
                    String cic = 'GBP';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
            }

                if (p.Estimate1__c != null)
                q.Estimate__c += p.Estimate1__c* p.Rate_to_USD__c;

                if (p.Op_P1__c != null)
                q.OP__c += p.Op_P1__c* p.Rate_to_USD__c;

                if (p.Op_P2__c != null)
                q.OP__c += p.Op_P2__c* p.Rate_to_USD__c;

                if (p.Op_P3__c != null)
                q.OP__c += p.Op_P3__c* p.Rate_to_USD__c;

                
                
                if (p.Actual_P1__c != null){                       
                    q.Month1__c += p.Actual_P1__c* p.Rate_to_USD__c;
                    
                    if (p.USD_MOR_1__c != null){
                        
                        q.Month1MOR__c += p.Actual_P1__c*p.USD_MOR_1__c;
                        p.Actual_P1_MOR__c += 100;
                       
                        
                    } else {
                        q.Month1MOR__c = q.Month1__c;

                    }               
                }

                if (p.Actual_P2__c != null){
                q.Month2__c += p.Actual_P2__c* p.Rate_to_USD__c;
                    if (p.USD_MOR_2__c != null){
                        q.Month2MOR__c += p.Actual_P2__c*p.USD_MOR_2__c;
                    } else {
                        q.Month2MOR__c = q.Month2__c;
                    }            
                }
                if (p.Actual_P3__c != null) {
                q.Month3__c += p.Actual_P3__c* p.Rate_to_USD__c;
                    if (p.USD_MOR_3__c != null){
                        q.Month3MOR__c += p.Actual_P3__c*p.USD_MOR_3__c;
                    } else {
                        q.Month3MOR__c = q.Month3__c;
                    }         
               }


            } 

            update pl;             <---------------------------------

Any idea?

Thankyou!
Hi, I'm trying to write into a field, Actuals_P1_MOR__c, the number 100 (for example). This field belong to Pipeline_Item__c object. So, at the end, I update the List pl that is made of Pipeline_Item__c records, in order to update every Actuals_P1_MOR__c.

But I get this error:

System.LimitException: DML currently not allowed 
 
for (Pipeline_Item__c p : pl)
            {
                
                if (p.Actual_P1_MOR__c== null){
                    p.Actual_P1_MOR__c=0;
                }

                if (p.Pipeline__r.CurrencyIsoCode=='USD')
                {
                    p.Rate_to_USD__c=1;

                } else {

                    p.USD_MOR_1__c=morMap.get('January');
                    p.USD_MOR_2__c=morMap.get('February');
                    p.USD_MOR_3__c=morMap.get('March');

                    
                
                 if (p.Pipeline__r.CurrencyIsoCode=='EUR')
                {
                    String cic = 'EUR';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                   

                }
                else if (p.Pipeline__r.CurrencyIsoCode=='BRL')
                {
                    String cic = 'BRL';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='CAD')
                {
                    String cic = 'CAD';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='PLN')
                {
                    String cic = 'PLN';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
                else if (p.Pipeline__r.CurrencyIsoCode=='GBP')
                {
                    String cic = 'GBP';
                    
                    p.Rate_to_USD__c= bemap.get(cic);
                }
            }

                if (p.Estimate1__c != null)
                q.Estimate__c += p.Estimate1__c* p.Rate_to_USD__c;

                if (p.Op_P1__c != null)
                q.OP__c += p.Op_P1__c* p.Rate_to_USD__c;

                if (p.Op_P2__c != null)
                q.OP__c += p.Op_P2__c* p.Rate_to_USD__c;

                if (p.Op_P3__c != null)
                q.OP__c += p.Op_P3__c* p.Rate_to_USD__c;

                
                
                if (p.Actual_P1__c != null){                       
                    q.Month1__c += p.Actual_P1__c* p.Rate_to_USD__c;
                    
                    if (p.USD_MOR_1__c != null){
                        
                        q.Month1MOR__c += p.Actual_P1__c*p.USD_MOR_1__c;
                        p.Actual_P1_MOR__c += 100;
                       
                        
                    } else {
                        q.Month1MOR__c = q.Month1__c;

                    }               
                }

                if (p.Actual_P2__c != null){
                q.Month2__c += p.Actual_P2__c* p.Rate_to_USD__c;
                    if (p.USD_MOR_2__c != null){
                        q.Month2MOR__c += p.Actual_P2__c*p.USD_MOR_2__c;
                    } else {
                        q.Month2MOR__c = q.Month2__c;
                    }            
                }
                if (p.Actual_P3__c != null) {
                q.Month3__c += p.Actual_P3__c* p.Rate_to_USD__c;
                    if (p.USD_MOR_3__c != null){
                        q.Month3MOR__c += p.Actual_P3__c*p.USD_MOR_3__c;
                    } else {
                        q.Month3MOR__c = q.Month3__c;
                    }         
               }


            } 

            update pl;             <---------------------------------

Any idea?

Thankyou!