• shruthika
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hi all,

 

Am very new in apex code. Here is my new task which tells like there is a renew custom button in agreements when i click that renew button it opens the new page with cloned information of old page except with some fields like Status and Status Category. Now i want a write a trigger in such a way that whenever the renew button is clicked the Status and Status Category should be updated as Activated and save them.

 

Please send me the solution as soon as possible

 

Thanks in Advance,

Shruthika.

Hi all,

 

I have applied this Evaluation Criteria: When a record is created, or when a record is edited and did not previously meet the rule criteria.

 

could anyone please explain me this. Does this Evaluation Criteria applies even for Exiting records which were created before wrting the workflow having Evaluation Criteria:

 

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



Ex: I have some records where Record type is corporate procurement and next  I created a workflow to alert an Email when Record type is corporate procurement by keeping the Evaluation Criteria as When a record is created, or when a record is edited and did not previously meet the rule criteria.

 

so does this send an Email Alert to all the Users records ie.,  The Existing records when once the workflow is made active or only sent to those User Records which are created after Workflow created and enabled as Active.

 

Please give me your suggestions as soon as possible its really urgent.

 

Thanks in Advance,

Shruthika.

Hi all,

 

Could anyone help me in providing the workflow for alerting a mail when we enter the User Contact Email field of agreements.

 

Thanks in advance,

Shruthika.

Hi all,

 

I want to Set the default value to Case Owner which is a standard field.

could anyone please provide me the solution as soon possible.

 

Thanks in advance,

Shruthika.

Hi all,

 

Am very new to the apex code could anyone help me out in writing test class for opportunityLineItem trigger.please give me the solution as soon as possible.

 

Below is the code which i have written..

 

/*###########################################################################
        # The requirement is to inspect all Opportunity Line Items for each updated opportunity
      # If the field Product_Line_F__c  contained one of 4 product line values, it would concatenate an abbreviated code for that product line to Exlusion_Check__c. 
      # It is possible all 4 product lines can be on the same opportunity so Exlusion_Check__c could have all 4 values concatenated. 
      # Each product line code would only appear once no matter how many line items have  the same product line.

########################################################################### */

trigger Opportunity_Product_Line_Check on Opportunity (before update)
{
    String CN_var='';
    String OE_var='';
    String OB_var='';
    String OR_var='';
   
    // Querying for ids and Product Line values on OpportunityLineItem
    List<opportunitylineitem> opppro=[select Id,Product_Line_F__c from OpportunityLineitem where OpportunityId IN :Trigger.newMap.keySet()];
   
    //Iterating loop for every Opportunity
    for(Opportunity opp : Trigger.new)
    {
        //Iterating loop for every OpportunityLineItem
        for(OpportunityLineItem oli : opppro)
        {
            if(oli.Product_Line_F__c=='Connect')        // Comparing Product Line value
            {
                 CN_var = '[CN]';                                // Assigning abbreviated code to the variable
            }
            if(oli.Product_Line_F__c=='OpenEdge')
            {
                  OE_var = '[OE]';
            }
            if(oli.Product_Line_F__c=='ObjectStore')
            {
                  OB_var = '[OB]';
            }
            if(oli.Product_Line_F__c=='Orbix')
            {
                  OR_var = '[OR]';
            }
           
            // Concatenate an abbreviated code
            opp.Exclusion_Check__c = CN_var + OE_var + OB_var + OR_var;
           
            system.debug('*** Filter products checked; applicable code added to filter field ****');
        }
    }
}

 

 

Thanks in advance.....

shruthika...

 





Hi all,


I have written test class for merging trigger and the code coverage is about 56% .. could anyone help me out in increasing code coverage please give me the solution as soon as possible.

 

Below is the code which i have written...



@isTest
private class MQLTEST
{
    static testMethod void myUnitTest()
    {
    // try catch block is used to remove the System.NullPointerException
        try
        {
     //   The format of the String depends on the local date format.
            Date t = date.today();
            Date d = Date.newInstance(t.year(),t.month(),t.day());
               
     //  Query the StageName,MQL Promotion Date, MQL Rejection Date from the standard object ie., Opportunity
                   
            Opportunity opp = [Select StageName, MQL_Promotion_Date__c, MQL_Rejection_Date__c from Opportunity WHERE Name = 'Mql Test'];
           
     //Displays the Stage name in debug log    
                   
            System.debug(' Val '+opp.StageName);
           
     //Returns a Date that contains the value of the specified String. The String should use the standard date format “yyyy-MM-dd HH:mm:ss” in the local time zone  
                
            System.debug('Opp MQl Date Val '+string.valueof(opp.MQL_Promotion_Date__c));
    
     //Checks the       
                   
            if(opp.StageName=='Lead' || opp.StageName=='Qualified Lead')
            {
     //Update the  StageName as D - Qualify
      
                opp.StageName = 'D - Qualify';
                system.debug('** updating test opportunity ');
                update opp;
               
     //Displays the Stage name in debug log           
               
                system.debug(' StageName '+ opp.StageName ); 
               
    // get updated account to verify trigger made correct updates
   
             Opportunity  getOpportunity = [Select StageName from Opportunity WHERE Name = 'Mql Test'];     
            
   
     //Only process if StageName is not equal to either Lead, Qualified Lead or No Opportunity         
               
                if(opp.StageName != 'Lead' && opp.StageName != 'Qualified Lead' && opp.StageName != 'No Opportunity')
                {        
                    System.debug('*** Oppty changed from Lead to something other than Lead or No Opportunity - date set to ' + System.today()+' ****');
                    system.debug(opp.MQL_Promotion_Date__c.isSameDay(d));
                    System.assertEquals(getOpportunity.MQL_Promotion_Date__c,System.today());
                }
                       
    //Only process if StageName is equal No Opportunity
   
                if(opp.StageName == 'No Opportunity')
                {                
                    System.debug('*** Oppty changed from Lead to No Opportunity-date set to'+System.today() +'****');
                    system.debug(opp.MQL_Rejection_Date__c.isSameDay(d));
                    System.assertEquals(getOpportunity.MQL_Rejection_Date__c,System.today());
                }
            } // End of If statement 
        }
       
        catch(Exception e)
        {
            system.debug('Error'+ e);
        }
    }
} // End of MQLTEST

 


 

Thanks in advance.....

shruthika...



Hi all,

 

I am getting an error while writing test class on merging trigger 

 

System.NullPointerException: Attempt to de-reference a null object

 

This is the error am getting please give me the solution as soon as possible.

 

Below is the code which i have written.....

 

@isTest
private class MQL
{
    static testMethod void myUnitTest()
    {
          Date t = date.today();
          Date d = Date.newInstance(t.year(),t.month(),t.day());
   
        //  Query the StageName
       
        Opportunity opp = [Select StageName, MQL_Promotion_Date__c, MQL_Rejection_Date__c from Opportunity WHERE Name = 'MQL'];
       
        System.Debug(' Val '+opp.StageName);
        System.Debug('Opp MQl Date Val '+string.valueof(opp.MQL_Promotion_Date__c));
      
        if(opp.StageName=='Lead' || opp.StageName=='Qualified Lead')
        {
            opp.StageName = 'D - Qualify';
            update opp;
           
            if(opp.StageName != 'Lead' && opp.StageName != 'Qualified Lead' && opp.StageName != 'No Opportunity')
            {        
                //System.assertEquals(opp.MQL_Promotion_Date__c,d);         
                System.debug('*** Oppty changed from Lead to something other than Lead or No Opportunity - date set to ' + System.today()+' ****');
      //  date MQLd=opp.MQL_Promotion_Date__c;
      //  MQLd=date.today();
          //  boolean dueNow = d.isSameDa(opp.MQL_Promotion_Date__c);
            system.debug(opp.MQL_Promotion_Date__c.isSameDay(d));
            }
            if(opp.StageName == 'No Opportunity')
            {
                //System.assertEquals(opp.MQL_Promotion_Date__c,d); 
                System.debug('*** Oppty changed from Lead to No Opportunity-date set to'+System.today() +'****');
                system.debug(opp.MQL_Rejection_Date__c.isSameDay(d));
            }
       }
    }
}



Thanks in advance.....

shruthika...





Hi all,

 

I am getting an error while writing test class on opportunity line item.

 

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (pricebook entry currency code does not match opportunity currency code): [PricebookEntryId]

 

This is the error am getting please give me the solution as soon as possible.

 

Below is the code which i have written.....

 

 

@isTest
private class TestOpportunityProductLineCheck
{
    static testMethod void myTest()
   { 
            Opportunity o = new Opportunity(Id='006T0000008kKcc', Name = 'praveen', StageName='B - Prove', CloseDate = Date.today());
            update o;

            Pricebook2 standardPB = [select id from Pricebook2 where isStandard=true];

            Pricebook2 pb = new Pricebook2(Id='01s30000000A8FCAA0', Name= 'PSC Price Book', IsActive = true);
            update pb;
            
            Product2 prod = new Product2(Name = 'Orbix Product',IsActive = true);
            insert prod;
    
            
            PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = standardPB.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert standardPrice;
        
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id = pb.Id, Product2Id = prod.Id, UnitPrice = 10000, IsActive = true, UseStandardPrice = false);
        insert pbe;

        
        //PricebookEntry pbe = new PricebookEntry(Pricebook2Id = '01s30000000A8FCAA0', Product2Id = prod.id, UnitPrice=100, UseStandardPrice = false, IsActive = true);
         //insert pbe ;
    
            
            //OpportunityLineItem ol = new OpportunityLineItem(OpportunityId = o.id , Quantity = 20 , TotalPrice = 100,PricebookEntryId = pbe.id );
            //insert ol;
    
            OpportunityLineItem oli = new OpportunityLineItem(opportunityId = o.Id, PricebookEntryId= pbe.Id, Quantity = 1, UnitPrice = 7500);
            insert oli;

List<OpportunityLineItem> olis = [Select Id From OpportunityLineItem Where OpportunityId =: o.Id];
        update olis[0];

            
 }
}



 

Thanks in advance.....

shruthika...


Hi everyone  am  very new in writing this apex code.. i have following trigger but any how i was able to write two test classes based on condition but was not able to code into single test class.. could anyone please provide me the code how to combine those two test classes into one.

 

Merging MQL Trigger:

trigger MQL on Opportunity (before update) 
{    
for(Opportunity a : Trigger.new)
{        
Opportunity beforeUpdate = System.Trigger.oldMap.get(a.Id);         
if(beforeUpdate.StageName =='Lead'||beforeUpdate.StageName == 'Qualified Lead')
{   
If(a.StageName != 'Lead' && a.StageName != 'Qualified Lead' && a.StageName != 'No Opportunity')
{         
a.MQL_Promotion_Date__c = System.today();            
system.debug('*** Oppty changed from Lead to something other than Lead or No Opportunity - date set to ' + System.today()+' ****');
}
if(a.StageName == 'No Opportunity')
{
a.MQL_Rejection_Date__c = System.today();  
system.debug('*** Oppty changed from Lead to No Opportunity-date set to'+System.today() +'****');  
}                     
}   

}

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

@isTest
private class TestMQLPromotionDateTrigger
{
     static testMethod void myTest()
 {
    Datetime t = system.now();
    Date d = Date.newInstance(t.year(),t.month(),t.day());
 
opportunity opp1=new opportunity(Name='MQL',ForecastCategoryName='Pipeline',Region__c='EMEA', LeadSource='Progress Employee', CurrencyIsoCode='INR-Indian Rupee', StageName='Qualified Lead', Type='New Customer', Opportunity_Source__c='sales Rep - Direct', Industry__c='Education',  CloseDate = d);

// insert test opportunity
insert opp1;

// get opportunity and change stage

Opportunity updateOpportunity = [Select Name from Opportunity WHERE Name = 'MQL'];
updateOpportunity.StageName = 'D - Qualify';
update updateOpportunity;

// get updated MQL Promotion Date to verify that trigger populated the field with today's date

Opportunity getOpportunity = [Select MQL_Promotion_Date__c from Opportunity WHERE Name = 'MQL'];

Datetime t2 = system.now();         
Date d2 = Date.newInstance(t2.year(),t2.month(),t2.day());

System.assertEquals(getOpportunity.MQL_Promotion_Date__c,d2);
    }
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@isTest
private class TestMQLPromotionDateTrigger
{
     static testMethod void myTest()
 {

    Datetime t = system.now();
    Date d = Date.newInstance(t.year(),t.month(),t.day());

Opportunity opp1 = new opportunity(Name='MQL',ForecastCategoryName='Pipeline',Region__c='EMEA', LeadSource='Progress Employee', CurrencyIsoCode='INR-Indian Rupee', StageName='Qualified Lead', Type='New Customer', Opportunity_Source__c='sales Rep - Direct', Industry__c='Education',  CloseDate = d);

// insert test opportunity
insert opp1;

// get opportunity and change stage

Opportunity updateOpportunity = [Select Name from Opportunity WHERE Name = 'MQL'];
updateOpportunity.StageName = 'No Opportunity';
updateOpportunity.Stage_Reason__c = 'N - No Solution Fit';
update updateOpportunity;

// get updated MQL Rejection Date to verify that trigger populated the field with today's date

Opportunity getOpportunity = [Select MQL_Rejection_Date__c from Opportunity WHERE Name = 'MQL'];

Datetime t2 = system.now();         
Date d2 = Date.newInstance(t2.year(),t2.month(),t2.day());

System.assertEquals(getOpportunity.MQL_Rejection_Date__c,d2);    
    }
}

can anyone please provide me solution for these two test classes into one with the same condition please..!!

Hi.. am very new in writing apex code... could anyone please help me out in providing the test class for the following trigger...

 

Merging MQL Trigger:

trigger MQL on Opportunity (before update) 
{    
for(Opportunity a : Trigger.new)
{        
Opportunity beforeUpdate = System.Trigger.oldMap.get(a.Id);         
if(beforeUpdate.StageName =='Lead'||beforeUpdate.StageName == 'Qualified Lead')
{   
If(a.StageName != 'Lead' && a.StageName != 'Qualified Lead' && a.StageName != 'No Opportunity')
{         
a.MQL_Promotion_Date__c = System.today();            
system.debug('*** Oppty changed from Lead to something other than Lead or No Opportunity - date set to ' + System.today()+' ****');
}
if(a.StageName == 'No Opportunity')
{
a.MQL_Rejection_Date__c = System.today();  
system.debug('*** Oppty changed from Lead to No Opportunity-date set to'+System.today() +'****');  
}                     
}   

}

 

Please anyone  provide me the solution.

Thank you.

 

Hi all,

 

Am very new in apex code. Here is my new task which tells like there is a renew custom button in agreements when i click that renew button it opens the new page with cloned information of old page except with some fields like Status and Status Category. Now i want a write a trigger in such a way that whenever the renew button is clicked the Status and Status Category should be updated as Activated and save them.

 

Please send me the solution as soon as possible

 

Thanks in Advance,

Shruthika.

Hi all,

 

I have applied this Evaluation Criteria: When a record is created, or when a record is edited and did not previously meet the rule criteria.

 

could anyone please explain me this. Does this Evaluation Criteria applies even for Exiting records which were created before wrting the workflow having Evaluation Criteria:

 

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



Ex: I have some records where Record type is corporate procurement and next  I created a workflow to alert an Email when Record type is corporate procurement by keeping the Evaluation Criteria as When a record is created, or when a record is edited and did not previously meet the rule criteria.

 

so does this send an Email Alert to all the Users records ie.,  The Existing records when once the workflow is made active or only sent to those User Records which are created after Workflow created and enabled as Active.

 

Please give me your suggestions as soon as possible its really urgent.

 

Thanks in Advance,

Shruthika.

Hi All,

 

Need help in writing an Apex trigger to assign incoming message from some address say abc@abc.com to a predefined case team member say MyTeam which has one member. How can we do this?

Please help me on this.

Thank you!

 

Regards,

Lakshman

Hi all,

 

I want to Set the default value to Case Owner which is a standard field.

could anyone please provide me the solution as soon possible.

 

Thanks in advance,

Shruthika.

Hi all,

 

Am very new to the apex code could anyone help me out in writing test class for opportunityLineItem trigger.please give me the solution as soon as possible.

 

Below is the code which i have written..

 

/*###########################################################################
        # The requirement is to inspect all Opportunity Line Items for each updated opportunity
      # If the field Product_Line_F__c  contained one of 4 product line values, it would concatenate an abbreviated code for that product line to Exlusion_Check__c. 
      # It is possible all 4 product lines can be on the same opportunity so Exlusion_Check__c could have all 4 values concatenated. 
      # Each product line code would only appear once no matter how many line items have  the same product line.

########################################################################### */

trigger Opportunity_Product_Line_Check on Opportunity (before update)
{
    String CN_var='';
    String OE_var='';
    String OB_var='';
    String OR_var='';
   
    // Querying for ids and Product Line values on OpportunityLineItem
    List<opportunitylineitem> opppro=[select Id,Product_Line_F__c from OpportunityLineitem where OpportunityId IN :Trigger.newMap.keySet()];
   
    //Iterating loop for every Opportunity
    for(Opportunity opp : Trigger.new)
    {
        //Iterating loop for every OpportunityLineItem
        for(OpportunityLineItem oli : opppro)
        {
            if(oli.Product_Line_F__c=='Connect')        // Comparing Product Line value
            {
                 CN_var = '[CN]';                                // Assigning abbreviated code to the variable
            }
            if(oli.Product_Line_F__c=='OpenEdge')
            {
                  OE_var = '[OE]';
            }
            if(oli.Product_Line_F__c=='ObjectStore')
            {
                  OB_var = '[OB]';
            }
            if(oli.Product_Line_F__c=='Orbix')
            {
                  OR_var = '[OR]';
            }
           
            // Concatenate an abbreviated code
            opp.Exclusion_Check__c = CN_var + OE_var + OB_var + OR_var;
           
            system.debug('*** Filter products checked; applicable code added to filter field ****');
        }
    }
}

 

 

Thanks in advance.....

shruthika...

 





Hi everyone  am  very new in writing this apex code.. i have following trigger but any how i was able to write two test classes based on condition but was not able to code into single test class.. could anyone please provide me the code how to combine those two test classes into one.

 

Merging MQL Trigger:

trigger MQL on Opportunity (before update) 
{    
for(Opportunity a : Trigger.new)
{        
Opportunity beforeUpdate = System.Trigger.oldMap.get(a.Id);         
if(beforeUpdate.StageName =='Lead'||beforeUpdate.StageName == 'Qualified Lead')
{   
If(a.StageName != 'Lead' && a.StageName != 'Qualified Lead' && a.StageName != 'No Opportunity')
{         
a.MQL_Promotion_Date__c = System.today();            
system.debug('*** Oppty changed from Lead to something other than Lead or No Opportunity - date set to ' + System.today()+' ****');
}
if(a.StageName == 'No Opportunity')
{
a.MQL_Rejection_Date__c = System.today();  
system.debug('*** Oppty changed from Lead to No Opportunity-date set to'+System.today() +'****');  
}                     
}   

}

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

@isTest
private class TestMQLPromotionDateTrigger
{
     static testMethod void myTest()
 {
    Datetime t = system.now();
    Date d = Date.newInstance(t.year(),t.month(),t.day());
 
opportunity opp1=new opportunity(Name='MQL',ForecastCategoryName='Pipeline',Region__c='EMEA', LeadSource='Progress Employee', CurrencyIsoCode='INR-Indian Rupee', StageName='Qualified Lead', Type='New Customer', Opportunity_Source__c='sales Rep - Direct', Industry__c='Education',  CloseDate = d);

// insert test opportunity
insert opp1;

// get opportunity and change stage

Opportunity updateOpportunity = [Select Name from Opportunity WHERE Name = 'MQL'];
updateOpportunity.StageName = 'D - Qualify';
update updateOpportunity;

// get updated MQL Promotion Date to verify that trigger populated the field with today's date

Opportunity getOpportunity = [Select MQL_Promotion_Date__c from Opportunity WHERE Name = 'MQL'];

Datetime t2 = system.now();         
Date d2 = Date.newInstance(t2.year(),t2.month(),t2.day());

System.assertEquals(getOpportunity.MQL_Promotion_Date__c,d2);
    }
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@isTest
private class TestMQLPromotionDateTrigger
{
     static testMethod void myTest()
 {

    Datetime t = system.now();
    Date d = Date.newInstance(t.year(),t.month(),t.day());

Opportunity opp1 = new opportunity(Name='MQL',ForecastCategoryName='Pipeline',Region__c='EMEA', LeadSource='Progress Employee', CurrencyIsoCode='INR-Indian Rupee', StageName='Qualified Lead', Type='New Customer', Opportunity_Source__c='sales Rep - Direct', Industry__c='Education',  CloseDate = d);

// insert test opportunity
insert opp1;

// get opportunity and change stage

Opportunity updateOpportunity = [Select Name from Opportunity WHERE Name = 'MQL'];
updateOpportunity.StageName = 'No Opportunity';
updateOpportunity.Stage_Reason__c = 'N - No Solution Fit';
update updateOpportunity;

// get updated MQL Rejection Date to verify that trigger populated the field with today's date

Opportunity getOpportunity = [Select MQL_Rejection_Date__c from Opportunity WHERE Name = 'MQL'];

Datetime t2 = system.now();         
Date d2 = Date.newInstance(t2.year(),t2.month(),t2.day());

System.assertEquals(getOpportunity.MQL_Rejection_Date__c,d2);    
    }
}

can anyone please provide me solution for these two test classes into one with the same condition please..!!

Hi.. am very new in writing apex code... could anyone please help me out in providing the test class for the following trigger...

 

Merging MQL Trigger:

trigger MQL on Opportunity (before update) 
{    
for(Opportunity a : Trigger.new)
{        
Opportunity beforeUpdate = System.Trigger.oldMap.get(a.Id);         
if(beforeUpdate.StageName =='Lead'||beforeUpdate.StageName == 'Qualified Lead')
{   
If(a.StageName != 'Lead' && a.StageName != 'Qualified Lead' && a.StageName != 'No Opportunity')
{         
a.MQL_Promotion_Date__c = System.today();            
system.debug('*** Oppty changed from Lead to something other than Lead or No Opportunity - date set to ' + System.today()+' ****');
}
if(a.StageName == 'No Opportunity')
{
a.MQL_Rejection_Date__c = System.today();  
system.debug('*** Oppty changed from Lead to No Opportunity-date set to'+System.today() +'****');  
}                     
}   

}

 

Please anyone  provide me the solution.

Thank you.