• Itswas
  • NEWBIE
  • 50 Points
  • Member since 2013

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 14
    Replies

trigger ENT_Trigger_insertNonQEIDisbursements on ENT_NMTC_Non_QLICI_Disbursement__c (after insert)
{
    //List<ENT_NMTC_QEI_Non_QEI_Disbursements__c> DisbList = new List<ENT_NMTC_QEI_Non_QEI_Disbursements__c>();
    
 
      
     
       
        if (Trigger.isInsert)
        {   
        
            //Id rtId = [select Id,name from RecordType where name='Non-QEI' and SObjectType='ENT_NMTC_QEI_Non_QEI_Disbursements__c' limit 1].id;
            for(ENT_NMTC_Non_QLICI_Disbursement__c NonDisb : trigger.new)
            {
                List<ENT_NMTC_QEI_Non_QEI_Disbursements__c> DisbListToInsert = new List<ENT_NMTC_QEI_Non_QEI_Disbursements__c>();
                ENT_NMTC_QEI_Non_QEI_Disbursements__c InsertDisb = new ENT_NMTC_QEI_Non_QEI_Disbursements__c(NMTC_Non_QLICI_Disbursement__c=NonDisb.Id,RecordType.name=Non_QEI);
                
                InsertDisb.Deal_Exit_Date__c = NonDisb.Deal_Exit_Date__c;
                //InsertDisb.RecordTypeId = rtId;              
                
                RecordType.Name = 'Non-QEI';
                InsertDisb.Deal_Originated_Date1__c = NonDisb.Deal_Originated_Date__c;
                InsertDisb.Disbursement_Date__c = NonDisb.Disbursement_Date__c;
                InsertDisb.Disbursement_ID__c = NonDisb.NMTC_NonQLICI_Disbursement_ID__c;
                InsertDisb.Disbursement_Source__c = NonDisb.NMTC_Non_QEI_Contribution__c;
                InsertDisb.Not_Yet_Disbursed_Projected_QEI__c = NonDisb.Not_Yet_Disbursed_Projected_QEI__c;
                InsertDisb.Originator_Transaction_ID__c = NonDisb.Product_Originator_Transaction_ID__c;
                InsertDisb.Source_Amount__c = NonDisb.Amount__c;
                InsertDisb.Total_Disbursement_Amount__c = NonDisb.Amount__c;
                DisbListToInsert.add(InsertDisb);  
        
                if(DisbListToInsert.size()>0)
                {
                    insert DisbListToInsert;
                }
            }
    }  
      
      
    
}

 

 

Everything else is working fine accept that I am not able to set a record type for newly inserted record. I have tried many ways and later commented them all. Please guide me through this

Hi

 

I have written a trigger on sandbox. But when I am writing a test class I am getting 0% coverage.

 

I am posting both my trigger and test class here.

 

Can someone please check and tell me where I have gone wrong?

 

trigger CreateNewShowing on pb__Showing__c (after update) {
  integer i=1;
  for (pb__Showing__c  sh : trigger.new) {
    pb__Showing__c s = new pb__Showing__c();
   
   datetime newDate = sh.Provisional_Date_A__c;
   if(sh.Status__c == 'Pending' && sh.Provisional_Date_A__c != Null){
    s.Account__c = sh.Account__c;
    s.pb__Inventory__c = sh.pb__Inventory__c;
    s.Start_Time__c = newDate ;
    s.End_Time__c = newDate.addHours(2);
    insert s;
    }
    pb__Showing__c s1 = new pb__Showing__c();
   
    datetime newDate1 = sh.Provisional_Date_B__c;
    if(sh.Status__c == 'Pending' && sh.Provisional_Date_B__c != Null){
    s1.Account__c = sh.Account__c;
    s1.pb__Inventory__c = sh.pb__Inventory__c;
    s1.Start_Time__c = newDate1 ;
    s1.End_Time__c = newDate1.addHours(2);
    insert s1;
    }
    pb__Showing__c s2 = new pb__Showing__c();
   
    datetime newDate2 = sh.Provisional_Date_C__c;
    if(sh.Status__c == 'Pending' && sh.Provisional_Date_C__c != Null){
    s2.Account__c = sh.Account__c;
    s2.pb__Inventory__c = sh.pb__Inventory__c;
    s2.Start_Time__c = newDate2 ;
    s2.End_Time__c = newDate2.addHours(2);
    insert s2;
    }
    pb__Showing__c s3 = new pb__Showing__c();
   
    datetime newDate3 = sh.Provisional_Date_D__c;
    if(sh.Status__c == 'Pending' && sh.Provisional_Date_D__c != Null){
    s3.Account__c = sh.Account__c;
    s3.pb__Inventory__c = sh.pb__Inventory__c;
    s3.Start_Time__c = newDate3 ;
    s3.End_Time__c = newDate3.addHours(2);
    insert s3;
    }
    pb__Showing__c s4 = new pb__Showing__c();
   
    datetime newDate4 = sh.Provisional_Date_E__c;
    if((sh.Status__c == 'Pending')&&(sh.Provisional_Date_E__c != Null)){
    s4.Account__c = sh.Account__c;
    s4.pb__Inventory__c = sh.pb__Inventory__c;
    s4.Start_Time__c = newDate4 ;
    s4.End_Time__c = newDate4.addHours(2);
    insert s4;
    }
    pb__Showing__c s5 = new pb__Showing__c();
   
    datetime newDate5 = sh.Provisional_Date_F__c;
    if(sh.Status__c == 'Pending' && sh.Provisional_Date_F__c != Null){
    s5.Account__c = sh.Account__c;
    s5.pb__Inventory__c = sh.pb__Inventory__c;
    s5.Start_Time__c = newDate5 ;
    s5.End_Time__c = newDate5.addHours(2);
    insert s5;
    }
   
   }
  }

 

 

Test Class

 

@isTest
private class UnitTestCreateNewShowing {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
     
      
     
     
        User u = [select id from user where LastName = 'Walsh'];
       
        //create test account
        Account a = new Account();
        a.LastName = 'testabcdef';
        a.PersonEmail='test@testsnk.com';
        a.Phone='987654';
        a.OwnerId = u.id;
        a.service_breach__c = false;
        a.pb__Status__c = 'Unqualified';
        insert a;
      
       pb__InventoryItem__c inv = new pb__InventoryItem__c();
        inv.name = 'abc123';
        inv.pb__IsForSale__c = true;
        inv.pb__PurchaseListPrice__c = 12313;
        inv.pb__IsAvailable__c = true;
        inv.Project__c = 'abcdd';
        inv.pb__ItemStatus__c = 'Available';
        inv.pb__IsBlocked__c = false;
        inv.SellerId__c = a.id;
        inv.Area__c = 'Marina';
        inv.Unit_No__c = '12test';
        inv.ItemStage__c = 'Available';
        insert inv;
      
      
       inv.OwnerId = u.id;
       update inv;

       //B
      
       pb__InventoryItem__c inv1 = new pb__InventoryItem__c();
        inv1.name = 'abc123';
        inv1.pb__IsForSale__c = true;
        inv1.pb__PurchaseListPrice__c = 12313;
        inv1.pb__IsAvailable__c = true;
        inv1.Project__c = 'abcdd';
        inv1.pb__ItemStatus__c = 'Available';
        inv1.pb__IsBlocked__c = false;
        inv1.SellerId__c = a.id;
        inv1.Area__c = 'Marina';
        inv1.Unit_No__c = '12test';
        inv1.ItemStage__c = 'Available';
        insert inv1;
      
      
       inv1.OwnerId = u.id;
       update inv1;
      
      
       pb__InventoryItem__c inv2 = new pb__InventoryItem__c();
        inv2.name = 'abc123';
        inv2.pb__IsForSale__c = true;
        inv2.pb__PurchaseListPrice__c = 12313;
        inv2.pb__IsAvailable__c = true;
        inv2.Project__c = 'abcdd';
        inv2.pb__ItemStatus__c = 'Available';
        inv2.pb__IsBlocked__c = false;
        inv2.SellerId__c = a.id;
        inv2.Area__c = 'Marina';
        inv2.Unit_No__c = '12test';
        inv2.ItemStage__c = 'Available';
        insert inv2;
      
      
       inv2.OwnerId = u.id;
       update inv2;
      
       Datetime todays= datetime.now();
      
         pb__Showing__c s = new pb__Showing__c();
         s.Start_Time__c=todays;
         s.End_Time__c=todays.addHours(2);
         s.Account__c=a.id;
         s.pb__Inventory__c=inv2.id;

         s.Provisional_Date_A__c = todays.addDays(2);
         s.Status__c = 'Pending';
         insert s;
      
      
      
   
    }
}

 

 

 

Kind Regards

 

Finney

  • February 14, 2013
  • Like
  • 0

Hi All,

 

how i can show the reports out side of salesforce. i have written Apex classes and VF page for show out report to out side o fsalesforce. if any one have any idea please help me

 

thanks,

sunil

I have requirment to update a field on the account page when a salesperson creates a certain type of task.

 

I have it working fine when I don't have the code checking to ensure that the task creator is the account owner. But I get an error that the Account owner is not a variable when trying to compare. See red text.

 

Any thoughts?  

 

trigger AccountVisit on Task (after Insert) {

      Set<id> accountid = new set<id>();

             for (Task tsk : trigger.new){

                        if  (tsk.Type == 'Meeting'){

                            accountid.add(tsk.whatID);

              }

              }

                  List<account> acctlist = [SELECT id

                                           FROM account

                                           Where ID in :accountid];

For (account acc : acctlist && acc.Owner = tsk.CreatedBy)

       {               acc.Last_Formal_Business_Review__c = system.today();

       }           update acctlist

;  }

 

I want to clone a record in same object uisng textfield......

For example:

 

if i have a Quantity__c field in object and fill the field with some numbers like 1,2,3 ....,and i press the save button, automatically it creates 3records or 2records in samke object as per the basis of quantity field uisng triggers(After insert).......

 

 

 

thanks

=========

Venkat Sforce

trigger ENT_Trigger_insertNonQEIDisbursements on ENT_NMTC_Non_QLICI_Disbursement__c (after insert)
{
    //List<ENT_NMTC_QEI_Non_QEI_Disbursements__c> DisbList = new List<ENT_NMTC_QEI_Non_QEI_Disbursements__c>();
    
 
      
     
       
        if (Trigger.isInsert)
        {   
        
            //Id rtId = [select Id,name from RecordType where name='Non-QEI' and SObjectType='ENT_NMTC_QEI_Non_QEI_Disbursements__c' limit 1].id;
            for(ENT_NMTC_Non_QLICI_Disbursement__c NonDisb : trigger.new)
            {
                List<ENT_NMTC_QEI_Non_QEI_Disbursements__c> DisbListToInsert = new List<ENT_NMTC_QEI_Non_QEI_Disbursements__c>();
                ENT_NMTC_QEI_Non_QEI_Disbursements__c InsertDisb = new ENT_NMTC_QEI_Non_QEI_Disbursements__c(NMTC_Non_QLICI_Disbursement__c=NonDisb.Id,RecordType.name=Non_QEI);
                
                InsertDisb.Deal_Exit_Date__c = NonDisb.Deal_Exit_Date__c;
                //InsertDisb.RecordTypeId = rtId;              
                
                RecordType.Name = 'Non-QEI';
                InsertDisb.Deal_Originated_Date1__c = NonDisb.Deal_Originated_Date__c;
                InsertDisb.Disbursement_Date__c = NonDisb.Disbursement_Date__c;
                InsertDisb.Disbursement_ID__c = NonDisb.NMTC_NonQLICI_Disbursement_ID__c;
                InsertDisb.Disbursement_Source__c = NonDisb.NMTC_Non_QEI_Contribution__c;
                InsertDisb.Not_Yet_Disbursed_Projected_QEI__c = NonDisb.Not_Yet_Disbursed_Projected_QEI__c;
                InsertDisb.Originator_Transaction_ID__c = NonDisb.Product_Originator_Transaction_ID__c;
                InsertDisb.Source_Amount__c = NonDisb.Amount__c;
                InsertDisb.Total_Disbursement_Amount__c = NonDisb.Amount__c;
                DisbListToInsert.add(InsertDisb);  
        
                if(DisbListToInsert.size()>0)
                {
                    insert DisbListToInsert;
                }
            }
    }  
      
      
    
}

 

 

Everything else is working fine accept that I am not able to set a record type for newly inserted record. I have tried many ways and later commented them all. Please guide me through this

How to map a custom field in lead to custom fields in both account and opportunity?..how can i write a trigger?

I've to write a Simple validation in my Custom VF/Apex code where a formula field (Grand Total which depends on 3 other fields) should not exceed a set number. If it does I would write a condition in my Apex code & add a error message to page. 

My Issue is that I think formula fields are only evaluated once the record is saved & when the page loads again & that's the reason I can't check for the modified Grand Total field in my apex code when User saves a record. 

 

Any workaround this , can this be achieved through After Trigger ?

Hi All,

I am an Apex noob and have never written an Apex trigger. I suspect that is what is required to do this. I am using basic Salesforce Accounts and Activities. I have tried to find a similar post on this board but have not found anything that does what I am trying to do - as simple as it may seem ;).

 

I have a read-only custom field in Accounts called CallCount_c (type number). I have a picklist field in Activities (aka Tasks) called MyActivity_c. I would like the custom field in Accounts to reflect the count of Activity records for this account where the MyActivity_c = "Phone Call". The Activity (Task) has a 'Related To" picklist where I choose 'Account" and then select the account to which this Activity is to be related.

 

Does that make sense?

Thanks in advance for reading, replies...

 

Hello All

 

Scenario: I have an Invoicenumber field (its an text data type).So, every user enters his data and save the record. After saving the record it will display the red or green flag

 

red-- indicates invoicenumber already exists,

Green--- indicates not exists the invoicenumber so no problem.

 

I dont want to use Unique check box. Through trigger I like to check whether this Invoicenumber already exists in custom Object or not

 

Could any one have any idea???

Please share ur suggestions?

 

Thankyou

Hi

 

I have written a trigger on sandbox. But when I am writing a test class I am getting 0% coverage.

 

I am posting both my trigger and test class here.

 

Can someone please check and tell me where I have gone wrong?

 

trigger CreateNewShowing on pb__Showing__c (after update) {
  integer i=1;
  for (pb__Showing__c  sh : trigger.new) {
    pb__Showing__c s = new pb__Showing__c();
   
   datetime newDate = sh.Provisional_Date_A__c;
   if(sh.Status__c == 'Pending' && sh.Provisional_Date_A__c != Null){
    s.Account__c = sh.Account__c;
    s.pb__Inventory__c = sh.pb__Inventory__c;
    s.Start_Time__c = newDate ;
    s.End_Time__c = newDate.addHours(2);
    insert s;
    }
    pb__Showing__c s1 = new pb__Showing__c();
   
    datetime newDate1 = sh.Provisional_Date_B__c;
    if(sh.Status__c == 'Pending' && sh.Provisional_Date_B__c != Null){
    s1.Account__c = sh.Account__c;
    s1.pb__Inventory__c = sh.pb__Inventory__c;
    s1.Start_Time__c = newDate1 ;
    s1.End_Time__c = newDate1.addHours(2);
    insert s1;
    }
    pb__Showing__c s2 = new pb__Showing__c();
   
    datetime newDate2 = sh.Provisional_Date_C__c;
    if(sh.Status__c == 'Pending' && sh.Provisional_Date_C__c != Null){
    s2.Account__c = sh.Account__c;
    s2.pb__Inventory__c = sh.pb__Inventory__c;
    s2.Start_Time__c = newDate2 ;
    s2.End_Time__c = newDate2.addHours(2);
    insert s2;
    }
    pb__Showing__c s3 = new pb__Showing__c();
   
    datetime newDate3 = sh.Provisional_Date_D__c;
    if(sh.Status__c == 'Pending' && sh.Provisional_Date_D__c != Null){
    s3.Account__c = sh.Account__c;
    s3.pb__Inventory__c = sh.pb__Inventory__c;
    s3.Start_Time__c = newDate3 ;
    s3.End_Time__c = newDate3.addHours(2);
    insert s3;
    }
    pb__Showing__c s4 = new pb__Showing__c();
   
    datetime newDate4 = sh.Provisional_Date_E__c;
    if((sh.Status__c == 'Pending')&&(sh.Provisional_Date_E__c != Null)){
    s4.Account__c = sh.Account__c;
    s4.pb__Inventory__c = sh.pb__Inventory__c;
    s4.Start_Time__c = newDate4 ;
    s4.End_Time__c = newDate4.addHours(2);
    insert s4;
    }
    pb__Showing__c s5 = new pb__Showing__c();
   
    datetime newDate5 = sh.Provisional_Date_F__c;
    if(sh.Status__c == 'Pending' && sh.Provisional_Date_F__c != Null){
    s5.Account__c = sh.Account__c;
    s5.pb__Inventory__c = sh.pb__Inventory__c;
    s5.Start_Time__c = newDate5 ;
    s5.End_Time__c = newDate5.addHours(2);
    insert s5;
    }
   
   }
  }

 

 

Test Class

 

@isTest
private class UnitTestCreateNewShowing {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
     
      
     
     
        User u = [select id from user where LastName = 'Walsh'];
       
        //create test account
        Account a = new Account();
        a.LastName = 'testabcdef';
        a.PersonEmail='test@testsnk.com';
        a.Phone='987654';
        a.OwnerId = u.id;
        a.service_breach__c = false;
        a.pb__Status__c = 'Unqualified';
        insert a;
      
       pb__InventoryItem__c inv = new pb__InventoryItem__c();
        inv.name = 'abc123';
        inv.pb__IsForSale__c = true;
        inv.pb__PurchaseListPrice__c = 12313;
        inv.pb__IsAvailable__c = true;
        inv.Project__c = 'abcdd';
        inv.pb__ItemStatus__c = 'Available';
        inv.pb__IsBlocked__c = false;
        inv.SellerId__c = a.id;
        inv.Area__c = 'Marina';
        inv.Unit_No__c = '12test';
        inv.ItemStage__c = 'Available';
        insert inv;
      
      
       inv.OwnerId = u.id;
       update inv;

       //B
      
       pb__InventoryItem__c inv1 = new pb__InventoryItem__c();
        inv1.name = 'abc123';
        inv1.pb__IsForSale__c = true;
        inv1.pb__PurchaseListPrice__c = 12313;
        inv1.pb__IsAvailable__c = true;
        inv1.Project__c = 'abcdd';
        inv1.pb__ItemStatus__c = 'Available';
        inv1.pb__IsBlocked__c = false;
        inv1.SellerId__c = a.id;
        inv1.Area__c = 'Marina';
        inv1.Unit_No__c = '12test';
        inv1.ItemStage__c = 'Available';
        insert inv1;
      
      
       inv1.OwnerId = u.id;
       update inv1;
      
      
       pb__InventoryItem__c inv2 = new pb__InventoryItem__c();
        inv2.name = 'abc123';
        inv2.pb__IsForSale__c = true;
        inv2.pb__PurchaseListPrice__c = 12313;
        inv2.pb__IsAvailable__c = true;
        inv2.Project__c = 'abcdd';
        inv2.pb__ItemStatus__c = 'Available';
        inv2.pb__IsBlocked__c = false;
        inv2.SellerId__c = a.id;
        inv2.Area__c = 'Marina';
        inv2.Unit_No__c = '12test';
        inv2.ItemStage__c = 'Available';
        insert inv2;
      
      
       inv2.OwnerId = u.id;
       update inv2;
      
       Datetime todays= datetime.now();
      
         pb__Showing__c s = new pb__Showing__c();
         s.Start_Time__c=todays;
         s.End_Time__c=todays.addHours(2);
         s.Account__c=a.id;
         s.pb__Inventory__c=inv2.id;

         s.Provisional_Date_A__c = todays.addDays(2);
         s.Status__c = 'Pending';
         insert s;
      
      
      
   
    }
}

 

 

 

Kind Regards

 

Finney

  • February 14, 2013
  • Like
  • 0
public with sharing class AttachController {

//private ApexPages.StandardController controller { get; set; }
public List<Deal_License__c> dp{get;set;}

   public Deal__c D{get;set;}
    public AttachController(ApexPages.StandardController controller) {
     D = [Select Name,Id,Account__c,Account__r.Name,Rate__c,Total_Value__c,Account__r.BillingStreet,
                 Account__r.BillingCity,Account__r.Billingstate,Account__r.BillingPostalcode,Account__r.BillingCountry
                 from Deal__c where id=:ApexPages.currentPage().getParameters().get('id')];
    system.debug('TestDeal'+D);
    Account acc=[Select Id,BillingStreet,BillingCity,Billingstate,BillingPostalcode,BillingCountry from Account where id=:D.Account__c];
    system.debug('Account%%%%%%%%%%%%%%'+acc);
    dp=[select id,Name,Deal__c,Months__c,List_Price__c,Unit_Price__c,Quantity__c,Total_Value__c from Deal_License__c where Deal__c=:D.Id];
    System.debug('DEALPRDODUCT&&&&&&&&&&'+dp);
    }
    
    public void attach() {
        try{
            Attachment myAttach = new Attachment();
            myAttach.ParentId = ApexPages.currentPage().getParameters().get('id');
            System.debug('Id: ' + ApexPages.currentPage().getParameters().get('id'));
            List<Attachment> at=[Select id from Attachment where parentId=:myAttach.ParentId];
            Integer c=at.size()+1;
            myAttach.name =D.Account__r.Name +''+ 'License Version' + c +'.pdf';
            PageReference psPdf = new PageReference('/apex/Quotation?id=' + ApexPages.currentPage().getParameters().get('id'));
            myAttach.body = psPdf.getContentAsPdf();

            insert myAttach;
              
            
                       
            System.debug('After attach');
            System.debug(myAttach);

            
            /*
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Quotation has been attached.'));
            */
        }
        catch(Exception e) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL,'There was an error while attaching'));
            System.debug('Exception');
        }
    }
    
    public PageReference QA() {
     PageReference secondPage = new PageReference('/apex/EmailQuote?id=' + ApexPages.currentPage().getParameters().get('id'));
      Attachment myAttach = new Attachment();
            myAttach.ParentId = ApexPages.currentPage().getParameters().get('id');
            System.debug('Id: ' + ApexPages.currentPage().getParameters().get('id'));
            List<Attachment> at=[Select id from Attachment where parentId=:myAttach.ParentId];
            Integer c=at.size()+1;
            myAttach.name = D.Account__r.Name +''+ 'License Version' + c +'.pdf';
            PageReference psPdf = new PageReference('/apex/Quotation?id=' + ApexPages.currentPage().getParameters().get('id'));
            myAttach.body = psPdf.getContentAsPdf();

            insert myAttach;
              
            secondPage.setRedirect(true);   
            return secondPage; 
    }
    public PageReference back() {
        attach();
        PageReference pr = new PageReference('/' + ApexPages.currentPage().getParameters().get('id') +'#'+ ApexPages.currentPage().getParameters().get('id') + '_RelatedNoteList_target');
        pr.setRedirect(true);
        System.debug('Inside back');
        return pr;
    }
       public PageReference cancel() {
       PageReference pr = new PageReference('/' + ApexPages.currentPage().getParameters().get('id') +'#'+ ApexPages.currentPage().getParameters().get('id') + '_RelatedNoteList_target');
       pr.setRedirect(true);
       System.debug('Inside back');
       return pr;
       }
        /*test methods here*/
     public static testMethod void testAttachController()
      {    
        //Opportunity opp=[select id from Opportunity where Name=:'Prasad Punage-'];
        Account acc=new Account(Name='rose',BillingCity='bang',Billingstate='kat',BillingPostalcode='560000',BillingCountry='india' );
        insert acc;
        Deal__c opp=new Deal__c(Name='test12',Account__c='acc.id');
        insert opp;
       
        Deal_License__c dl=new Deal_License__c(Name='asd',Deal__c='opp.id');
        insert dl;        
        Attachment myAttach1 = new Attachment();
        myAttach1.ParentId =opp.id;
        myAttach1.name = 'Quotation.pdf';
        myAttach1.body = blob.valueof('test');
          
        insert myAttach1;
        system.debug('Attahment1'+ myAttach1);
        AttachController atc = new AttachController(new ApexPages.StandardController(myAttach1));
         
        atc.attach();
        atc.back();
        atc.cancel();
      }
      
      public String attachmentName{get; set;}
      public pagereference AttachQuote(){
        Pagereference pdf = page.Quotation;
        blob  b = pdf.getContent();
    
         attachment att = new attachment();
         att.parentId = ApexPages.currentPage().getParameters().get('id') ;
         att.body = b;
         att.name = 'Quotation.pdf';     
         insert att;
         
         return null;
      
      }
}

 Thanks in advance

I have two custom objects under the Opportunity object and I'd like to make a trigger that creates a third set of custom object records.

 

Custom object one is 'RepSplit__c': contains a Sales Rep (user lookup id) and Percentage Split (percentage)

Custom object two is 'OppPayment__c': contains a Date and amount of money received (currency) and amount of money initially expected (currency)

Third custom object titled 'RepRevShare__c' -- Opportunity, Percentage, Expected Amount, Actual Amount, Date, Amount of Money Received * Percentage (formula), 

 

I want to have RepRevShare records be the combination of the other two objects, so if I have RepSplit1,2,and 3...and OppPayments A,B... then I want to trigger creation of six records:

RepRevShare1A, 1B, 2A, 2B, 3A, and 3B

 

All this to have matrix reporting where my Reps are on the Y axis and Months are on the X axis, with money in the middle!

 

 

 

So here goes with my little programming knowledge...

 

My thinking was I need the following actions:

before insert,update,delete of a RepSplit or an OppPayment --   clear/delete all RepRevShare records under the related Opportunity

after insert,update,delete pf a RepSplit or an OppPayment -- create all new RepRevShare records

 

Is this possible?  I've been working my way through coding bits and pieces but my guess is there is a far easier way to code this.

 

 

  • February 13, 2013
  • Like
  • 0

Hi All 

 

I have a requirement to insert 7 records once.

 

I have 7 Record Types. If I create 1 Record with 1 Record Type my trigger to should insert other 6 records with 6 different record types.

I have a Lead Object and the lead has child object called "Home_Service_c"

Home service object has 7 record types.

 

Thanks in Advance