1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public with sharing class New_Opportunity_On_Account
{
private string AccountId;
public New_Opportunity_On_Account ()
{
AccountId = ApexPages.currentPage().getParameters().get('id');
}
public Pagereference init()
{
PageReference p = new PageReference(Constants.RECORD_TYPE_URL);
p.getParameters().put('ent','Opportunity');
p.getParameters().put(constants.RET_URL,'/'+AccountId);
string save_Url = Constants.OPPORTUNITY_EDIT_URL + '?nooverride=1&';
save_Url += constants.ACCOUNT_ID_FIELD_ID + '=' + AccountId + '&' +
constants.RET_URL + '=' + '/'+AccountId;
p.getParameters().put(Constants.SAVE_NEW_URL,save_Url);
return p;
}
/************************************TEST************************************/
public static testMethod void test()
{
Account acc = New Account();
acc.Name= ... quelques données renseignées
insert acc;
PageReference p = Page.New_Opportunity_On_Account;
p.getParameters().put('id',acc.id);
Test.setCurrentPageReference(p);
New_Opportunity_On_Account vf = new New_Opportunity_On_Account();
vf.init();
}
} |
Partager