You need to sign in to do that
Don't have an account?
DTRain521
Redirect button from VF page
Hi, I have a need for a button from a VF page to rediert me to the landing page for record type selection for creating a new record on a custom object. Custom object has a master detail relationship with Opportunity. I have created the button but need help with the APEX coding in the class for the VF page. Any help would be greatful. Thanks Dwayne
create a apex CommandButton on page give a action function
on controller side
replace 01IQ0000000D12q by your custom object Id to get Object Id go to setup----> your custom object ----> you can get Id in url also Change your Salesforce instance accordingly
as you explained your custom object has Master-Detail with opportunity,
if you want this Opportunity should select autometically after record selection page
then need some more input from your side
like
1) VF page from where you are redirecting, Are you showing opportunity on this page [So we can get ID and Name of Opportunity]
2)What is recordId of your Master Detail field on custom object
3) What is object prefix of your custom object
if you want simple recordtype selection page then first solution is enough, else give these detail
Hope this will help you
Thanks,
Bala
So you need to go with Second option,
Could you please provide , other three factors, so we can create link that will populate current Opportunity in edit Layout of your custom object.
you can get this information easily by using apex Explorer or Eclipse
Thanks,
Bala
Basically we want to generate Correct pagereference URL which will hit RecordType selection Page ,
After selecting record type, It will return to Service_Notifications__c edit page.
to generate correct URL do following Exercise (****** Just to get correct URL parameter and Formats )
1) Add Service_Notifications__c related List on Opportunity page Layouts with (New button)
2) Click on New Service_Notifications__c button from related list ,
3) RecordType selection Page will appear ... this is the URL you need to generate,
which looks like
from this url you need to just replace current Opportunity record Id and Opportunity Name
In above example Id was 001Q000000FC97v and Name was Reseller Account
Hope this will help you,
Thanks,
Bala
your page reference URL is incorrect
It contains only retUrl Parameter (Even this parameter is not holding any value in your case )
your URL should be something like
https://cs3.salesforce.com/setup/ui/recordtypeselect.jsp?ent=01IQ0000000D12q&retURL=/001Q000000FC97v&save_new_url=/a1z/e%3FCF00NQ0000000iKS1%3DReseller%2BAccount%2B1%26CF00NQ0000000iKS1_lkid%3D001Q000000FC97v%26retURL%3D%252F001Q000000FC97v
save_new_url this parameter is missing from your code
if above things will not help you, let me check the code from your code, if you think so :) drop me mail
Also try the exercise that I have explained previously
Thanks,
Bala
Bala,
Thanks for your help on this. I am still having trouble and dont quite understand. Here is my code for the redirect, I think I may just be coding the url string wrong.
Jack,
you are constructing save_new_url in some incorrect way .
your save_new_url must like contains /Service_Notification_Object_Prefix/e
so this will open new edit page with Service_Notification_Object edit layout
Thanks,
Bala
Bala,
I dont understand what you mean. Where would I place the "/Service_Notification_Object_Prefix/e"
Is it possible to access your dev Org for me , I will do it for you (if you want so )
I have a sent a mail to you previously.
Thanks,
Bala
I have this in my sandbox and there is sensitive data that can not be shared. Sorry
Is there any thing that I can post here. I had posted the actual url at one point if that helps.
no problem .......
do this exercise
to generate correct URL do following Exercise (****** Just to get correct URL parameter and Formats )
1) Add Service_Notifications__c related List on Opportunity page Layouts with (New button)
2) Click on New Service_Notifications__c button from related list ,
3) RecordType selection Page will appear ... this is the URL you need to generate,
copy the resultant URL from browser address Bar and Post here,
If you have any issue for this exercise get back to me
Thanks ,
Bala
Also post your code of apex controlller
Thanks,
Bala
try with above code once
Let me know
Thanks ,
Bala
hey could you please send me Email id ,
so I can mail you updated controller code
I m trying to put source code here ..............but here Html formating adding some unwanted characters in code like '+......'
you can see.
Will send updated code as attachement
Thanks,
Bala
Visualforce Error
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Opportunity.Name
Class.PolicyDashboardController.ServiceNotifications: line 270, column 171 External entry point
<script type="text/javascript"></script>Visualforce Error
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Opportunity.Name
Class.PolicyDashboardController.ServiceNotifications: line 270, column 171 External entry point
add Name field where you have made query while retriving Opportunity record
like [Select Id, Name ,........ from Opportunity where .......]
Thanks,
Bala
Any updates ?
Yes I have this it would be policy.name
Does new Page Reference URL works for you ?
Thanks,
Bala
Bala,
Just noticed a response from you that I missed.
My email address is dtrain521@gmail.com
Thanks Dwayne
Any News?
updated script sent at your email id ,
Thanks,
Bala
I get the following error:
You may have reached this page after clicking on a direct link into the application. This direct link might be:
• A bookmark to a particular page, such as a report or view
• A link to a particular page in the Custom Links section of your Home Tab, or a Custom Link
• A link to a particular page in your email templates
If you reached this page through a bookmark, you are probably trying to access something that has moved. Please update your bookmark.
If you reached this page through any of the other direct links listed above, please notify your administrator to update the link.
If you reached this page through a link on our site, please report the broken link directly to our Support Team and we will fix it promptly. Please indicate the page you were on when you clicked the link as well as any other related information. We apologize for the inconvenience.
Thank you again for your patience and assistance. And thanks for using salesforce.com!
you need to encode the URL,
Mainly, If your policy.name contains some space (should get replaced by ENCODE character )
check is there any way so we can encode this fields and formed correct URL,
Also mail me URL in browser when you get this error message [in some Text file ] or ping me on gtalk
Thanks,
Bala