• mahesh reddy 4
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 3
    Replies
The requirement is i want to send an email alert to appointment after every three days upto date of on boarding expires. I am using trigger to achieve this requirement. Please suggest me how to achieve this requirement. 
Hi, In one application i want to merge the opportunities under the account object. Please share the apex code for this requirement..As soon as possible..Thanks in Advance.
I am getting field integrity exception in trigger while inserting records?
I wrote one after insert and after update trigger. when i change the status field to closed the trigger is executing. Problem is when i click that record
and update with the same data the trigger executing same? It updating the inventory again and again ? Any idea?
I have created three custom objects all are linked using master detail relationship(one is master and two are childs.). How can i display all the fields of three objects in a single vf page? Any help please?
what is dynamic apex? what is the use of it? please tell me the link to access content on dynamic apex?
There are two objects.obj1 and obj2. I am writing trigger on obj1.status is a picklist field on obj1.if status=new in obj1 i can able to select type=prospect in obj2.Here objects are not related.Is it possible with triggers?
There are two objects.obj1 and obj2. I am writing trigger on obj1.status is a picklist field on obj1.if status=new in obj1 i can able to select type=prospect in obj2.Here objects are not related.Is it possible with triggers?
Need help with a test class for the following Class. I am new to development and need to get this class above 75%. I didn't write this class so I am kinda stuck. Any help would be great. 

Class
trigger CreateAssetonClosedWon on Opportunity (after insert, after update) {
  Map<String, AssetRollup__c> rollupMap = AssetRollup__c.getAll();
 
     for(Opportunity o: trigger.new){
      if(o.isWon == true && o.HasOpportunityLineItem == true){
         String opptyId = o.Id;
         OpportunityLineItem[] OLI = [Select UnitPrice, Quantity, PricebookEntry.Product2Id,
                                             TotalPrice,
                                             PricebookEntry.Product2.Name, Description, Converted_to_Asset__c,
                                             PricebookEntry.Product2.Create_Asset__c, PricebookEntry.Product2.Sales_Order_Group__c
                                      From OpportunityLineItem
                                      where OpportunityId = :opptyId
                                        and Converted_to_Asset__c = false
                                        and PricebookEntry.Product2.Create_Asset__c = true];
         Asset[] ast = new Asset[]{};
         Asset hotline;
         Asset a = new Asset();
         for(OpportunityLineItem ol: OLI){
            a = new Asset();
          a.AccountId = o.AccountId;
            a.Product2Id = ol.PricebookEntry.Product2Id;
            a.Quantity__c = ol.Quantity;
            a.Price =  ol.TotalPrice;
            a.PurchaseDate = o.CloseDate;
            a.Renewal_Date__c = o.CloseDate.Month() + '/' + o.CloseDate.Day();
            a.Status = 'Purchased';
            a.Description = ol.Description;
            a.Name = ol.PricebookEntry.Product2.Name;
        // TODO:extend this to support matching on sales order group from AssetRollup__c and build a list of rollups         
        if(ol.PricebookEntry.Product2.Sales_Order_Group__c=='International Hotline'){
          if(hotline == null) {
            hotline = a;
            AssetRollup__c rollup = rollupMap.get(ol.PricebookEntry.Product2.Sales_Order_Group__c);
            if (rollup != null){
              hotline.Name = rollup.Asset_Name__c;
              hotline.Product2Id = rollup.ProductId__c;
            }
          }
          else {
            hotline.Quantity__c += a.Quantity__c;
            hotline.Price += ol.TotalPrice;
          }
        }
        else{
              ast.add(a);
        }
           
            ol.Converted_to_Asset__c = true;
       }
       if(hotline != null) {
         ast.add(hotline);
       }
      update OLI;
      
      insert ast;
     }
    }
}

Test Class


@isTest
Public class testReassignCNO {
    
     static testMethod void testPardotScore() {
    
        Account a = new Account();
        a.name = 'TNW (for Competitor Profile)';
        a.OwnerId = '005A0000000gWDt';
        insert a;
       
        Contact q = new Contact();
        q.FirstName = 'Test';
        q.LastName = 'User 1';
        q.pi__score__c = 20;
        q.accountId = a.Id;
        q.OwnerId = '005A0000000gWDt';
        q.No_Longer_Employed__c = true;
        insert q;
       
         Contact c = new Contact();
        c.FirstName = 'Test2';
        c.LastName = 'User 2';
        c.pi__score__c = 20;
        c.accountId = a.Id;
        c.OwnerId = '005F0000003kNza';
        insert c;
        
        a.assign__c = True;
        update a;
       
        
       
    }
}