• Prits
  • NEWBIE
  • 0 Points
  • Member since 2017
  • CRM Admin
  • Learning.com

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies
What is wrong in my apex test class code. i am getting error


public class test_updatecontactrolecount
{
 public static testMethod void testcreateopptywithconditionandrole()
{
//Insert Opportunities 
try
{
    // insert Account
    Account[] Acct = new Account[]
    {
        new Account(name = 'testAcct1')
    };
    insert Acct;
    
    Opportunity Oppty = new Opportunity(Name='Oppty_test1',  StageName='Qualified target', Initial_Interest__c ='Needs Updating', CloseDate= System.Today() );
    insert Oppty;
    
    // insert contact
    Contact[] cont = new Contact[]
    {
        new Contact(LastName = 'testcontact1'),
        new Contact(LastName = 'testcontact2')
    };    
    insert cont;    
    // insert contact role     
    OpportunityContactRole [] ocr = new OpportunityContactRole[]
    {
    new OpportunityContactRole(Role ='PD Contact',OpportunityId=Oppty.id ,Contactid = cont[0].id ,Isprimary = True),
    new OpportunityContactRole(Role ='Upload Contact',OpportunityId=Oppty.id ,Contactid = cont[0].id ,Isprimary = False)
    };
    insert ocr;    
    Oppty.StageName = 'Proposal in Funnel';    
    //Update opportunity
    
    Test.StartTest();
    update Oppty;
    Test.StopTest();
 
           
    Oppty =[SELECT Number_of_Contacts_Roles_Assigned__c,Primary_Contact_Assigned__c FROM Opportunity WHERE Id = :Oppty.Id];
    system.assert (Oppty.Number_of_Contacts_Roles_Assigned__c == 2);
    system.assert (Oppty.Primary_Contact_Assigned__c == True);
}
catch (System.DmlException e)
{
    System.assert(false);
}        

}
  • March 26, 2018
  • Like
  • 0
why I am not getting 2nd email alert
Requirement- I need to send an email alert when RAI start date becomes current date and after every 30 days. For my testing I have made it after every 1 day.
I have used two workflows.
1. When RAI start date is today it will make that date field today again.
2. 2nd workflow will send an email alert and in time trigger it will make the RAI start date today() after one day.
what is happening I am getting first email alert, the RAi start date is converted to today() after 1 day , but I am not getting the 2nd alert. Where I am getting wrong.

Workflow 1
User-added image
workflow 1 and 2 field update
User-added image
Workflow 2
User-added image
 
  • February 21, 2018
  • Like
  • 0
how to hide column header in apex code for visualforce email template for opportunity if the column has no value

for value it works-

                  <apex:outputPanel layout="none" rendered="{!NOT(ISNULL(lineItem.Discount_Applied__c))}">
                             <td>
                                {!lineItem.Discount_Applied__c}
                            </td>                 
                            </apex:outputPanel>  

but in header how can i reference it
  • January 26, 2018
  • Like
  • 0
What is wrong in my apex test class code. i am getting error


public class test_updatecontactrolecount
{
 public static testMethod void testcreateopptywithconditionandrole()
{
//Insert Opportunities 
try
{
    // insert Account
    Account[] Acct = new Account[]
    {
        new Account(name = 'testAcct1')
    };
    insert Acct;
    
    Opportunity Oppty = new Opportunity(Name='Oppty_test1',  StageName='Qualified target', Initial_Interest__c ='Needs Updating', CloseDate= System.Today() );
    insert Oppty;
    
    // insert contact
    Contact[] cont = new Contact[]
    {
        new Contact(LastName = 'testcontact1'),
        new Contact(LastName = 'testcontact2')
    };    
    insert cont;    
    // insert contact role     
    OpportunityContactRole [] ocr = new OpportunityContactRole[]
    {
    new OpportunityContactRole(Role ='PD Contact',OpportunityId=Oppty.id ,Contactid = cont[0].id ,Isprimary = True),
    new OpportunityContactRole(Role ='Upload Contact',OpportunityId=Oppty.id ,Contactid = cont[0].id ,Isprimary = False)
    };
    insert ocr;    
    Oppty.StageName = 'Proposal in Funnel';    
    //Update opportunity
    
    Test.StartTest();
    update Oppty;
    Test.StopTest();
 
           
    Oppty =[SELECT Number_of_Contacts_Roles_Assigned__c,Primary_Contact_Assigned__c FROM Opportunity WHERE Id = :Oppty.Id];
    system.assert (Oppty.Number_of_Contacts_Roles_Assigned__c == 2);
    system.assert (Oppty.Primary_Contact_Assigned__c == True);
}
catch (System.DmlException e)
{
    System.assert(false);
}        

}
  • March 26, 2018
  • Like
  • 0
why I am not getting 2nd email alert
Requirement- I need to send an email alert when RAI start date becomes current date and after every 30 days. For my testing I have made it after every 1 day.
I have used two workflows.
1. When RAI start date is today it will make that date field today again.
2. 2nd workflow will send an email alert and in time trigger it will make the RAI start date today() after one day.
what is happening I am getting first email alert, the RAi start date is converted to today() after 1 day , but I am not getting the 2nd alert. Where I am getting wrong.

Workflow 1
User-added image
workflow 1 and 2 field update
User-added image
Workflow 2
User-added image
 
  • February 21, 2018
  • Like
  • 0