You need to sign in to do that
Don't have an account?
Akansha Gupta
.getParameters().put() not working
I have the following method which opens a new record page from a VF page. "Account" is a lookup field in the record page which has to be populated from the TR1__Account__c field in the Closing Report object. How do I achieve this? Here is the method I wrote.
public PageReference create() {
id = ApexPages.currentPage().getParameters().get('id');
cr = [Select TR1__Account__c from TR1__Closing_Report__c where Id =: id];
accountId = cr.TR1__Account__c;
PageReference pageRef = new PageReference('https://foiberia--devv11.cs88.my.salesforce.com/a2w/e?retURL=%2Fa2w%2Fo');
pageRef.getParameters().put('Account',String.valueOf(accountId));
return pageRef.setRedirect(true);
}
public PageReference create() {
id = ApexPages.currentPage().getParameters().get('id');
cr = [Select TR1__Account__c from TR1__Closing_Report__c where Id =: id];
accountId = cr.TR1__Account__c;
PageReference pageRef = new PageReference('https://foiberia--devv11.cs88.my.salesforce.com/a2w/e?retURL=%2Fa2w%2Fo');
pageRef.getParameters().put('Account',String.valueOf(accountId));
return pageRef.setRedirect(true);
}
Inspect your lookup field and 3,4 line above the element, search for this code -
And then collect the name value from the input tag which contains "lkid" in the name value. In my case, since I am using Standard Object, the name value is "con4_lkid". But in your case it might not be con4, but some 15 digit id with "_" and "lkid" (XXXXXXXXXXXXXXX_lkid) . So you have to take that value and prefix "CF" with it.
Once you get that, in the URL, after the retURL, type this where con4_lkid will contain an Accounts Id and the con4 parameter will contain the same Account's Name.
For your case, here is an example how your URL will look like after the retURL value - Here is a link for reference - http://forcewizard.com/blog/url-hack-prepopulate-lookup-fields-parent-data
All Answers
Are you unable to see the URL Parameter called "Account" ?
Inspect your lookup field and 3,4 line above the element, search for this code -
And then collect the name value from the input tag which contains "lkid" in the name value. In my case, since I am using Standard Object, the name value is "con4_lkid". But in your case it might not be con4, but some 15 digit id with "_" and "lkid" (XXXXXXXXXXXXXXX_lkid) . So you have to take that value and prefix "CF" with it.
Once you get that, in the URL, after the retURL, type this where con4_lkid will contain an Accounts Id and the con4 parameter will contain the same Account's Name.
For your case, here is an example how your URL will look like after the retURL value - Here is a link for reference - http://forcewizard.com/blog/url-hack-prepopulate-lookup-fields-parent-data