function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Markey1Markey1 

Sites - How to Set Record Type via Link

For my Site, I want the user to be able to click, for example, the Enrollment link which will take the user to the Enrollment Page... but, I also want to set the record type based off which link is clicked as well. How do I accomplish this?

 

<apex:component >
  <div id = "menu_container">
    <div id = "menu">
      <ul>
        <li class="menu_header">Some Name
          <ul>
            <li><a href="http://testing.somename.cs3.force.com/enroll">Enrollment</a></li>
            <li><a href="http://testing.somename.cs3.force.com/cert">Certification</a></li>
          </ul>
        </li>                            
      </ul>
    </div>
  </div>
</apex:component>

 

b-Forceb-Force

We need to send RecordTypeId by using QueryString parameter,

your NEW url will be like this

            <li><a href="http://testing.somename.cs3.force.com/enroll?RecordTypeID=SFID">Enrollment</a></li>
            <li><a href="http://testing.somename.cs3.force.com/cert?RecordTypeId=SFID">Certification</a></li>

 

Replace SFID with your actual recordType Id ,

access this parameter on your VF page

set like using  Custom_Object__c.RecordTypeId=SFID

 

 

this will set your RecordType for inserted record

 

Thanks,

Bala

 

Markey1Markey1

Hi Bala Wani,

 

Thanks for your reply. My link code is now:

 

<li><apex:outputlink value="{!URLFOR($Page.aeskisenroll) + '?RecordTypeID=012Q00000004So4'}">Enrollment</apex:outputlink></li>

 

The url is updating correctly

 

http://someurl.com/aeskisenroll?RecordTypeID=012Q00000004So4

 

 

However, when the record saves the Record Type is not updating correctly. How do I

"access this parameter on your VF page, set like using  Custom_Object__c.RecordTypeId=SFID...  this will set your RecordType for inserted record"?

 

If required I can display this on the Visualforce Page but I'm trying to get it to save without the end user ever seeing the Record Type field. Do you need me to post my VF page code as well?

 

Markey1Markey1

Or, should my link code be something more like:

 

            <li>
              <apex:outputlink value="{!URLFOR($Page.aeskisenroll)}">Enrollment
                <apex:param name="rt" value="Enrollment__c.RecordType.Id" />
              </apex:outputlink>
            </li>

 If so, how do I pass the parameter to the VF page so it saves the Record Type on save?

Markey1Markey1

Bala Wani,

 

I'm still stuck... I feel like I am close and any assistance is much appreciated.

 

My Link:

<li><a href="http://testing.somename.cs3.force.com/aeskisenroll?RecordTypeId=012Q00000004So4">Enrollment</a></li>

 

My VF:

<apex:param assignTo="{!RTT}" value="{!Enrollment__c.RecordTypeId}=012Q00000004So4"/>

 

Class Snippet:

    Public String RTT {get;set;}

    /*Controller*/
    public AESK_Enroll(ApexPages.StandardController con){
        ApexPages.StandardController controller;         
        controller = con;        
        skEnroll = (Enrollment__c)controller.getRecord();                         

    }           

    /*Validate, save, and return page*/
    public PageReference save() {    
        try {    
            insert skEnroll;
        } 
        catch (DMLException e) {
            ApexPages.addMessages(e);
            return null;
        }
        return page.aeskenrollconfirm; 
    }