• sridharbarla
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 8
    Replies

Hi i am nes to salesforce .

 

 

in opportunity we have order date as one filed

in case order date is overdue then system needs to send email to the opportunity owner repeatedly like Daily or weekly .

 

is it possible this kind of implementation with work flow.

 

if i created work flow with using this criteria

 

 "When a record is created, or when a record is edited and did not previously meet the rule criteria"

and added time dependent trigger to this work flow .

 

 

but this will fire only once right?

 

or it will fire n number of times

 

 

 

Message Edited by sridharbarla on 03-25-2010 11:18 PM

Hai,

 

i written a apex class to generate a manual reference number and this code will execute while before insert and before update

 

but while runnig unit test i am getting code coverage is 63%

 

public class AP04
{   
     public static void addNiceRef(Opportunity[] oppObj)  
     {
            String OppDivisionCode;
            Integer refCountValue = 1000 ;
            for (Opportunity getoppObj1:oppObj)
            {      
              OppDivisionCode = getoppObj1.Division_Code__c ;
             }
              
           if(OppDivisionCode != null)
           {
           //   sObject[] groupedResults =
              for (sObject ar : [select Max(RefNumCount__c) refnum, Division_Code__c from Opportunity where Division_Code__c  = :OppDivisionCode group by Division_Code__c limit 1]) 
              {
               if (String.valueOf(ar.get('refnum')) != null)
               {
                  refCountValue = Integer.valueOf(String.valueOf(ar.get('refnum')));
               }
              
              } 
            for (Opportunity getoppObj2:oppObj)
            { 
               getoppObj2.RefNumCount__c = refCountValue + 1;
               getoppObj2.OLDNICENBR__C = OppDivisionCode + '' + getoppObj2.RefNumCount__c ;
            }
          }

     }
     public static void updateNiceRef(Opportunity[] oppObj)  
     {
             String OpporunityID;            
             String OppDivisionCode;            
             Integer refCountValue = 1000 ; 
             Integer RecordCount = 0; 
             for (Opportunity getoppObj1:oppObj)
            {      
                OppDivisionCode = getoppObj1.Division_Code__c ;
                OpporunityID = getoppObj1.ID;
            }
           if(OppDivisionCode != null)
           {
            for (sObject ar : [select Max(RefNumCount__c) refnum,Division_Code__c from Opportunity where  Division_Code__c =:OppDivisionCode group by Division_Code__c limit 1]) 
             {
                     if (String.valueOf(ar.get('refnum')) != null)
                        {
                         refCountValue = Integer.valueOf(String.valueOf(ar.get('refnum')));
                        }
              }  
           }
            for (Opportunity getoppObj2:oppObj)
            {       
               If(OppDivisionCode == null)
               {
                  getoppObj2.OLDNICENBR__C = null;
                  getoppObj2.RefNumCount__c = 0;
               }
               else
                {
                 getoppObj2.RefNumCount__c = refCountValue + 1;
                 getoppObj2.OLDNICENBR__C =  OppDivisionCode + '' + getoppObj2.RefNumCount__c ;
                }
             }

     }

 

test code for my apex class 

 

@istest
private class Test_AP04_AP05 {


 private static testMethod void TestAP04_5(){
 test.starttest();
    List<Opportunity> myOpportunityList1=new List<Opportunity>(); 
     Account a = new account();
    a.Name = 'Test';
    a.RecordTypeId = '012200000001RhOAAU';
    a.KeyAccount__c = 'No';
    insert a;
   for(Integer i=0;i<5;i++)
   { 
         myOpportunityList1.add(new Opportunity(RecordTypeId = '012200000001RetAAE',name='Testing'+ i ,
         Amount=100000,StageName='Prospecting',
         CloseDate=date.today(),AccountId=a.Id,Division_Code__c = 'UKTY2',Market_Community__c ='Latin_America',
         Trading_Plan__c='No' ));   
         
         myOpportunityList1.add(new Opportunity(RecordTypeId = '012200000001RetAAE',name='Testing'+ i ,
         Amount=1000,StageName='Prospecting',
         CloseDate=date.today(),AccountId=a.Id,Division_Code__c = 'UKTY2',Market_Community__c ='Other',
         Trading_Plan__c='Yes' )); 
             
         myOpportunityList1.add(new Opportunity(RecordTypeId = '012200000001RetAAE',name='Testing'+ i ,
         Amount=1000,StageName='Prospecting',
         CloseDate=date.today(),AccountId=a.Id,Division_Code__c = '',Market_Community__c ='',
         Trading_Plan__c='' ));  
            
         myOpportunityList1.add(new Opportunity(RecordTypeId = '012200000001RetAAE',name='Testing'+ i ,
         Amount=1000100,StageName='Prospecting',
         CloseDate=date.today(),AccountId=a.Id,Division_Code__c = '',Market_Community__c ='Latin_America',
         Trading_Plan__c='No' ));     
    }     
     insert myOpportunityList1;  
     test.stoptest();       
   }   
  
}

 

 

if i am increaing for lopp size it is showing tomany soql quaries

please any body help me on this

Hi ,

i am new to apex programming.

my requirement is like below

opportunity can have Tradin plan

 

Each opportunity can have n number of trading plan but

all trading pan amount can not  greater than the opportunity amount .

  

to check the sum of trading plan amount whether it is greater or less

in validation rules it is not possible so i thought  i  can write  apex trigger

 

but i don't know how to stop data insertion  if codition fails in apex trigger .

below i written apes trigger before insert

please help me on this

 

trigger TradingPlanInsert on Opportunity_Trading_Plan__c (before insert)
{
          
           Id opptID;
           double oppAmount = 0;
           double oppTplanAmount= 0;
           for(Opportunity_Trading_Plan__c newTradinPlanObj: Trigger.new)
           {
          
                opptID = newTradinPlanObj.Opportunity_trading__c;
                oppTplanAmount = oppTplanAmount +  newTradinPlanObj.Plan_Amount__c;
           }
          
         Opportunity_Trading_Plan__c[] oppTradingobj = [Select Id, Name, CurrencyIsoCode, Opportunity_trading__c,
         Plan_Amount__c, Trading_Received_Date__c, Milestone__c, Description__c, GM__c
         FROM Opportunity_Trading_Plan__c  where Opportunity_trading__c = :opptID];
        
         for(Opportunity_Trading_Plan__c oppTexistinObj  : oppTradingobj )
         {
            oppTplanAmount = oppTplanAmount +  oppTexistinObj.Plan_Amount__c;
         }
        
         Opportunity[]  oppobj = [Select Id, StageName, Amount, CloseDate, Type, CurrencyIsoCode   FROM Opportunity where ID =:opptID];
         for(Opportunity oppdetailsObj  : oppobj )
         {
            oppAmount =   oppdetailsObj.Amount;
         }
         if (oppAmount < oppTplanAmount )
         {
           System.Debug('Trading plan  amount more than opportunity amount ');   
         }
          
          

 

 

Message Edited by sridharbarla on 03-08-2010 11:59 PM

Hi any boby help me on validation rule  

 

how to check differnt currency  values from child to parent object (both are different currency type ).

 

 i have created a trading plan  as custom obejct  and  this custom object is child to opportunity object.

Requirement is

   opportunity can have  'n' number of trading plans . and amount of the all trading plans  not greater than the

 opportunity amount

 

my problem is opportunity created in EURO and trading plan creating in GBP so how to check whether user enter values less than the opportunity amount .

 

 

i can't check like  opportunity.amount <> tradingplanamount

because both are different currency types .

is there any way to  compare this kinfd of different currency values?

 

Message Edited by sridharbarla on 03-08-2010 03:20 AM
Message Edited by sridharbarla on 03-08-2010 03:24 AM

Hai  i am new to visual force page

 

How to disaply below query data in visual force page

 

AggregateResult[] oppResult= [select SUM(amount),LeadingConverteamUnit__c from Opportunity where RECORDTYPEID = '012200000001ReyAAE'
 GROUP BY LeadingConverteamUnit__c ];

so now i need to display this groupedResults in table or grid manner how to do this

 --------------------------------------------

| leading unit                   |    amount      |

---------------------------------------------

|sample1                        | 10000           |

|-------------------------------------------

|sample opp2                  | 200000        | 
|-------------------------------------------

|sample Opp3                 | 300000000   |

---------------------------------------------

 

 

Hai

i am new to visual force page

 

i want to dispaly oppottunity data  in two data grids

 

like

 

third party opportunity

select  Name ,amount from opportunity where opprecordtypeID = XXXXXXXXXXXXX; 

 

Internal opportunity .

 

select  Name ,amount from opportunity where opprecordtypeID = yyyyyyyyyyyyyy; 

 

 

 

so what i did is i created a apex class like

 

 

public class GetOpportunityDetails

{
   
List<Opportunity> oppThirdPartyList;

List<Opportunity> oppInterList;


public List<Opportunity> getThirdpartyOpportunity() 
{
    if(oppThirdPartyList== null)
    { 
       oppThirdPartyList= [select name,amount from Opportunity where RecordTypeID=XXXXXXXXX];
     }
    return oppThirdPartyList;
 }

 

 

public List<Opportunity> getInternalOpportunity() 
{
    if(oppInterList== null)
    { 
       oppInterList= [select name,amount from Opportunity where RecordTypeID=yyyyyyyyyyy];
     }
    return oppInterList;
 }

}

 

how to display this two record type data in diffrent grid with using visual force page.

 

please help me

Hi,

i am new to Apex coding

 

i want to generate reference like while creating an opportunity based on some cobination of fileds

Opp Number

DE_HP_1

DE_HP_2

DE_HP_3

RD_HP_1

RD_HP_2

RD_HP_3

RD_SR_1

 

 

so to generate ref like above i am writing apex trigger like before insert

 

         String test1 ; 

         String test2 ;  
         String test3 ;  

         Integer test4 ; 


        for(Opportunity ct: Trigger.new)
       {
           test1 = ct.RECORDTYPEID;

           test2 = ct.LEADINGUNIT__C;

           test3 = ct.DIVISION__C;
       }

        AggregateResult[] groupedResults = [select MaxRefNumCount__c) refnum from Opportunity where RefNumCount__c != null 

and RECORDTYPEID = :test1 and LEADINGUNIT__C :test2 and DIVISION__C :test3]; 
        
        for (AggregateResult ar : groupedResults)  
        {
         test4 = Integer.valueOf(ar.get('refnum'));
        }   
       for(Opportunity ct1: Trigger.new)
       { 
         ct1.RefNumCount__c = test4 + 1;   //RefNumCount__c  is Number filed (18,0)
         ct1.OpprefNUm__C= test2 + '_' + test3 + '_'  ct1.RefNumCount__c  ;
       }

 

but while saving opportunity i am getting error like

System.TypeException: Invalid integer: 319: Trigger.OpportunityBeforeInsert 

i am getting error in    test4 = Integer.valueOf(ar.get('refnum'));

 

any body please help me

How to integrate Salesforce with Amadeus??

can anyone  provide source code or related links?

 

Ragards,

Nilesh

Hi Friends,

 

When we buy web services from websites such as strikeiron etc then in the stub classes we have to specify user name and pasword.

 

 

My question is how do we get that username and password.?.Is there a way to generate?

 

Please help.

 

Thanks,

Trick

  • February 26, 2012
  • Like
  • 0

Hi ,

i am new to apex programming.

my requirement is like below

opportunity can have Tradin plan

 

Each opportunity can have n number of trading plan but

all trading pan amount can not  greater than the opportunity amount .

  

to check the sum of trading plan amount whether it is greater or less

in validation rules it is not possible so i thought  i  can write  apex trigger

 

but i don't know how to stop data insertion  if codition fails in apex trigger .

below i written apes trigger before insert

please help me on this

 

trigger TradingPlanInsert on Opportunity_Trading_Plan__c (before insert)
{
          
           Id opptID;
           double oppAmount = 0;
           double oppTplanAmount= 0;
           for(Opportunity_Trading_Plan__c newTradinPlanObj: Trigger.new)
           {
          
                opptID = newTradinPlanObj.Opportunity_trading__c;
                oppTplanAmount = oppTplanAmount +  newTradinPlanObj.Plan_Amount__c;
           }
          
         Opportunity_Trading_Plan__c[] oppTradingobj = [Select Id, Name, CurrencyIsoCode, Opportunity_trading__c,
         Plan_Amount__c, Trading_Received_Date__c, Milestone__c, Description__c, GM__c
         FROM Opportunity_Trading_Plan__c  where Opportunity_trading__c = :opptID];
        
         for(Opportunity_Trading_Plan__c oppTexistinObj  : oppTradingobj )
         {
            oppTplanAmount = oppTplanAmount +  oppTexistinObj.Plan_Amount__c;
         }
        
         Opportunity[]  oppobj = [Select Id, StageName, Amount, CloseDate, Type, CurrencyIsoCode   FROM Opportunity where ID =:opptID];
         for(Opportunity oppdetailsObj  : oppobj )
         {
            oppAmount =   oppdetailsObj.Amount;
         }
         if (oppAmount < oppTplanAmount )
         {
           System.Debug('Trading plan  amount more than opportunity amount ');   
         }
          
          

 

 

Message Edited by sridharbarla on 03-08-2010 11:59 PM

Hai  i am new to visual force page

 

How to disaply below query data in visual force page

 

AggregateResult[] oppResult= [select SUM(amount),LeadingConverteamUnit__c from Opportunity where RECORDTYPEID = '012200000001ReyAAE'
 GROUP BY LeadingConverteamUnit__c ];

so now i need to display this groupedResults in table or grid manner how to do this

 --------------------------------------------

| leading unit                   |    amount      |

---------------------------------------------

|sample1                        | 10000           |

|-------------------------------------------

|sample opp2                  | 200000        | 
|-------------------------------------------

|sample Opp3                 | 300000000   |

---------------------------------------------

 

 

Hi,

i am new to Apex coding

 

i want to generate reference like while creating an opportunity based on some cobination of fileds

Opp Number

DE_HP_1

DE_HP_2

DE_HP_3

RD_HP_1

RD_HP_2

RD_HP_3

RD_SR_1

 

 

so to generate ref like above i am writing apex trigger like before insert

 

         String test1 ; 

         String test2 ;  
         String test3 ;  

         Integer test4 ; 


        for(Opportunity ct: Trigger.new)
       {
           test1 = ct.RECORDTYPEID;

           test2 = ct.LEADINGUNIT__C;

           test3 = ct.DIVISION__C;
       }

        AggregateResult[] groupedResults = [select MaxRefNumCount__c) refnum from Opportunity where RefNumCount__c != null 

and RECORDTYPEID = :test1 and LEADINGUNIT__C :test2 and DIVISION__C :test3]; 
        
        for (AggregateResult ar : groupedResults)  
        {
         test4 = Integer.valueOf(ar.get('refnum'));
        }   
       for(Opportunity ct1: Trigger.new)
       { 
         ct1.RefNumCount__c = test4 + 1;   //RefNumCount__c  is Number filed (18,0)
         ct1.OpprefNUm__C= test2 + '_' + test3 + '_'  ct1.RefNumCount__c  ;
       }

 

but while saving opportunity i am getting error like

System.TypeException: Invalid integer: 319: Trigger.OpportunityBeforeInsert 

i am getting error in    test4 = Integer.valueOf(ar.get('refnum'));

 

any body please help me