Enabling Ranked Appointment Booking on External Websites
You can embed the Ranked Appointment Booking page on an external website. This enables your customers to book appointment slots for themselves. This is achieved by creating a Visualforce page for Appointment Booking, and then embedding that URL in any website.
Perform the following steps to embed the Ranked Appointment Booking page on an external website:
1. Create a class for Appointment Booking. The following is a sample code snippet of the class:
public class WoOptimaxController {
public SVMXC__Service_Order__c wos{get; set;}
public SVMXC__Service_Order__c setwos(SVMXC__Service_Order__c workOrder){
this.wos=workOrder;
return wos;
}
public WoOptimaxController() {
wos=new SVMXC__Service_Order__c();
}
public pagereference Save(){
SVMXC__Service_Order__c wo = new SVMXC__Service_Order__c();
wo.SVMXC__Contact__c=wos.SVMXC__Contact__c;
wo.SVMXC__Component__c=wos.SVMXC__Component__c;
wo.SVMXC__Zip__c=wos.SVMXC__Zip__c;
wo.SVMXC__SM_Appointment_Type__c='a2a17000000UmYF';
wo.SVMXC__Primary_Territory__c = 'a2B170000007d5p';
wo.SVMXC__Order_Type__c = wos.SVMXC__Order_Type__c;
wo.SVMXC__Purpose_of_Visit__c= wos.SVMXC__Purpose_of_Visit__c;
insert wo;
Pagereference pg = new Pagereference('/apex/SVMXC__WSCH_Provider_ECO_Appointment?id=' + wo.id);
pg.setredirect(true);
return pg;
}
}
The following fields are mandatory for this class: - Appointment Type - Territory - Valid Address
2. Create a VisualForce page. The following is a sample code snippet for the page:
<apex:page sidebar="false" controller="WoOptimaxController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel >Zip</apex:outputLabel>
<apex:inputField id="zip" value="{!wos.SVMXC__Zip__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Country</apex:outputLabel>
<apex:inputField id="Country" value="{!wos.SVMXC__Country__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Order Type</apex:outputLabel>
<apex:inputField id="OrderType" value="{!wos.SVMXC__Order_Type__c}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel >Purpose Of Visit</apex:outputLabel>
<apex:inputField id="purposeOfVisit" value="{!wos.SVMXC__Purpose_of_Visit__c}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton id="Save" action="{!Save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
You can add the fields as per your requirement. In this sample code snippet, Zip, Country, Order Type, and Purpose of Visit are added as fields.
3. Perform the following steps in Salesforce Setup:
a. Navigate to Site > Edit.
b. Set Active Home Page to appointment_wizard.
c. Click Save.
4. Go to Public Access Settings > Edit Enabled Apex Class Access. Add the WoOptimaxController class.
5. Edit Enabled Visualforce Page Access and add SVMXC.WSCH_Provider_ECO_Appointment and appointment_wizard. The Visualforce page is set up, as shown in the following screen.
* 
Ensure that the object and field level permissions are set for the Appointment Window object for the Site user.
Using the External Website Page for Appointment Booking
To invoke the Ranked Appointment Booking page through the external website:
1. Select values for the fields in the externally embedded page.
2. Click Save. A work order is created. You are redirected to the Ranked Appointment Booking page, where you can select an appointment slot for the work order.
* 
You can embed the Visualforce page URL in any website.
Was this helpful?