<apex:page action="onload()" extensions="TransactionExtension" id="pg" standardcontroller="Transaction__c"></apex:page>
ExtController
global with sharing class TransactionExtension
{
Transaction__c ta = new Transaction__c();
private String prefix = Schema.getGlobalDescribe().get('Transaction__c').getDescribe().getKeyPrefix();
public Rateboard__c rb {get;set;}
public TransactionExtension(ApexPages.StandardController controller)
{
ta = (Transaction__c)controller.getRecord();
ta.Settlement_Date__c = Date.today();
if(ta.Rateboard__c != null)
rb = [SELECT Id, Name FROM Rateboard__c WHERE Id = :ta.Rateboard__c];
}
public PageReference onLoad()
{
//Default new URL values
PageReference pg = new PageReference('/' + prefix +'/e?');
pg.getParameters().put('CF00N6100000BpDsy', rb.Name); //rateboard text
pg.getParameters().put('CF00N6100000BpDsy_lkid', rb.Id); //rateboard id
pg.getParameters().put('retURL','/' + rb.Id); //return url
pg.getParameters().put('nooverride','1');// Important to avoid recursion
// Copy from values from Rateboard__c
pg.getParameters().put('00N6100000Bol8p', rb.Basis__c);
System.debug(Logginglevel.DEBUG, '@@@TransactionExtension.onLoad.pg: ' + pg);
return pg;
}
}