You need to sign in to do that
Don't have an account?
Markey1
Set Record Type ID via Page ID
Hello,
How do I set the Record Type ID (value) based off which Visualforce Page a user is currently viewing?
This is a Sites project. When a user is on the "enrollment" page and submits their form, I want the custom controller extension (or ?) to reference the Page ID to set the Record Type to "Enrollment" (i.e. Record Type Name = Enrollment, Record Type ID = 012Q00000004So4).
My Code (could be completely off, mashed a few things together from other forums):
public rtt() { if(System.currentPageReference().getParameters().get('id')= "enrollment") { RecordType.ID = "012Q00000004So4"; } }
My Error:
Error: Compile Error: line 84:60 no viable alternative at character '"' at line 84 column 60
Hi,
Check the below code, i think you should use logical operator in the if loop.
Hi rmeh,
Thanks for your response. I tried:
Unfortunately, I get an error:
Column 83 is where the "if" statement starts.... any ideas? Need me to post any other code?
Hi Markey1,
Please do the following changes and try it:
This will work!!!
The RecordType.ID line is also incorrect. Visualforce always uses a "single quote" (apostrophe) instead of the usual "double quotes" found in most other programming languages.
Thanks sfdcfox,
Getting there...now I'm getting an error "Error: Compile Error: Invalid constructor name: rtt at line 82 column 8". Also, not sure if it matters, but this is a "Sites" project.
Full Controller Code:
Hi,
Please do the following changes in your code.
Check if it works for you!!
Hi rmeh,
I really appreciate your help and feel like I'm getting closer. I still get the error "Error: Compile Error: Invalid constructor name: rtt..". Should I be using "Public Void rtt()"?
Yes, please try using the below and i know this should not be the issue, but try and put the method after your constructor call.
public void rtt()
{
}