function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
etechcareersetechcareers 

Insert after the fact????

Hi all:

   I am building a wizard on 2 custom object and basically the name in one obect is an autonumber. So i need this autonumber to appear in the second object which links to the first custom object.

for some reason it is not working from my VF page when I hit save

 

   public PageReference saveit() {
  
      System.Debug('rtpspm' + ApexPages.currentPage().getParameters().get('rtpspm'));
      System.debug('oppid' + ApexPages.currentPage().getParameters().get('oppId'));
      //Payment Detail
      pd.Donation__c = ApexPages.currentPage().getParameters().get('oppId');
      pd.recordtypeid = ApexPages.currentPage().getParameters().get('rtpspm');
      insert pd;
  
      List<Payment_Detail__c> pdName = new List<Payment_Detail__c>();
      pdName = [Select Name from Payment_Detail__c where Id=:pd.id Limit 1];
      System.Debug('pd.Name' + pdName[0].Name);
             
      //Allocation
      alloc.Donation__c = ApexPages.currentPage().getParameters().get('oppId');
      alloc.Payment_Detail__c = pdName[0].Name ;
      insert alloc;


       PageReference opptyPage = new PageReference('/' + ApexPages.currentPage().getParameters().get('oppId'));
       return opptyPage.setRedirect(true);
   

   }

 Where am I going wrong????

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

Is payment_detail__c a lookup? if so you should be using the Id of the related record, not its name.

All Answers

SuperfellSuperfell

Is payment_detail__c a lookup? if so you should be using the Id of the related record, not its name.

This was selected as the best answer
etechcareersetechcareers

Thank you so much... One more question

How in VF can I tell the user for what donation they are making the payment for:

I tried:

 

String donname {get;set;}
donname=opportunity.name;

In VF Page
<apex:outputText value="{!donname}"/>

But nothing comes up????

 

 

Jeremy.NottinghJeremy.Nottingh

Try it with an explicit get method:

 

 

public String getdonname() { return donname; }

 

 

etechcareersetechcareers

Hi Thank you so much... Awesome if I can give 2 aceepted solutions I would give one to you as well...

Thanks

Z