1

I have a visualforce page with custom buttons. Twas asked to add to the Custom Setting a field called ATLAS_ENDPOINT. I need to use this value to popup a new window with the link inside.

VISUALFORCE

<apex:page standardController="Case" sidebar="false" extensions="LEORDERSAPIExtension">
    <apex:form >
  <script>
    function finalRedirect()
    {
        window.location = "https://c.cs11.visual.force.com/apex/OrderSubmitted?&id={!Case.Id}";
    }
  </script>

        <apex:pageBlock title="Please Confirm Order Details">
        <apex:pageBlockSection title="Order Details" columns="2">

<apex:OutputText Label="Account ID" value="{!Case.Account.Id}"/>
<apex:OutputText Label="Account Number" value="{!Case.Account_Number_c__c}"/>
<apex:OutputText Label="Alternate phone"  value="{!Case.Alternate_Phone__c}" />
<apex:OutputText Label="primary street" value="{!Case.Account.BillingStreet}"/>
<apex:OutputText Label="primary city" value="{!Case.Account.billingcity}"/>
<apex:OutputText Label="primary state" value="{!Case.Account.BillingState}"/>
<apex:OutputText Label="primary zip" value="{!Case.Account.BillingPostalCode}"/>
<apex:OutputText Label="created by" value="{!Case.Createdby.Name}"/>
<apex:OutputText Label="created by user Id" value="{!Case.Createdby}"/>
<apex:OutputText Label="digital contract length (months)" value="{!Case.Opportunity__r.Digital_Contract_Length_Text__c}"/>
<apex:OutputText Label="primary country" value="{!Case.Account.BillingCountry}"/>
<apex:OutputText Label="email" value="{!Case.Contact.Email}"/>
<apex:OutputText Label="fax" value="{!Case.Account.Fax}"/>
<apex:OutputText Label="Contact First Name" value="{!Case.Contact.FirstName}"/>
<apex:OutputText Label="Contact Last Name" value="{!Case.Contact.LastName}"/>
<apex:OutputText Label="Oppty Owner Manager Email" value="{!Case.Opportunity__r.Owner.Manager.Email}"/>
<apex:OutputText Label="Case Market" value="{!Case.Case_Market__c}"/>
<apex:OutputText Label="Account Name" value="{!Case.Account.Name}"/>
<apex:OutputText Label="Opportunity Owner First Name" value="{!Case.Opportunity__r.Owner.FirstName}"/>
<apex:OutputText Label="Opportunity Owner Last Name" value="{!Case.Opportunity__r.Owner.LastName}"/>
<apex:OutputText Label="Contact Phone" value="{!Case.Contact.Phone}"/>
<apex:OutputText Label="Account Phone" value="{!Case.Account.Phone}"/>
<apex:OutputText Label="Total digital monthly fees" value="{!Case.Opportunity__r.Total_Digital_monthly_Fees__c}"/>
<apex:OutputText Label="total setup fees" value="{!Case.Opportunity__r.Total_Setup_Fees__c}"/>
<apex:OutputText Label="website" value="{!Case.Account.Website}"/>
 </apex:pageBlockSection>
        <apex:pageBlockButtons >
                <apex:commandButton action="{!sendOrder}" value="Send Order" oncomplete="finalRedirect();"  />
                <apex:commandButton action="{!Cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

APEX CLASS

public class LEORDERSAPIExtension {   
     private Id caseRecordId;    public LEORDERSAPIExtension(ApexPages.StandardController controller) {        caseRecordId = controller.getRecord().Id; 

   }        public void sendOrder() {            
              BPMIntegrationService.postCaseRecordToBPM(caseRecordId);            
 }            
  }

CUSTOM SETTING

Label BPM Integration Object Name BPM_Integration 
API Name BPM_Integration__c Setting Type Hierarchy 
Visibility Public Description  
Namespace Prefix  Created Date 8/8/2014 10:06 AM 
Last Modified Date 8/8/2014 10:08 AM Record Size 1,870 
  • 2
    see Keith C's answer; note to others who might be reading this: if the custom setting is a list Custom Setting, then the controller will need to make it available with a public getter property – cropredy Nov 24 '14 at 20:50
2

You can reference the value of a hierarchy custom setting field directly in Visualforce via the $Setup global:

{!$Setup.BPM_Integration__c.ATLAS_ENDPOINT__c}

The text that is in the setting will be merged into your page so you can reference it e.g. in some JavaScript.

| improve this answer | |
0

Using Keith C's information I added the following: window.open('{!$Setup.BPM_Integration__c.ATLAS_ENDPOINT__c}') I put that under the window.location line. The final visualforce page included:

<apex:page standardController="Case" sidebar="false" extensions="LEORDERSAPIExtension">
    <apex:form >
  <script>
    function finalRedirect()
    {
        window.location = "https://c.cs11.visual.force.com/apex/OrderSubmitted?&id={!Case.Id}";
        window.open('{!$Setup.BPM_Integration__c.ATLAS_ENDPOINT__c}')

    }
  </script>

        <apex:pageBlock title="Please Confirm Order Details">
        <apex:pageBlockSection title="Order Details" columns="2">

<apex:OutputText Label="Account ID" value="{!Case.Account.Id}"/>
<apex:OutputText Label="Account Number" value="{!Case.Account_Number_c__c}"/>
<apex:OutputText Label="Alternate phone"  value="{!Case.Alternate_Phone__c}" />
<apex:OutputText Label="primary street" value="{!Case.Account.BillingStreet}"/>
<apex:OutputText Label="primary city" value="{!Case.Account.billingcity}"/>
<apex:OutputText Label="primary state" value="{!Case.Account.BillingState}"/>
<apex:OutputText Label="primary zip" value="{!Case.Account.BillingPostalCode}"/>
<apex:OutputText Label="created by" value="{!Case.Createdby.Name}"/>
<apex:OutputText Label="created by user Id" value="{!Case.Createdby}"/>
<apex:OutputText Label="digital contract length (months)" value="{!Case.Opportunity__r.Digital_Contract_Length_Text__c}"/>
<apex:OutputText Label="primary country" value="{!Case.Account.BillingCountry}"/>
<apex:OutputText Label="email" value="{!Case.Contact.Email}"/>
<apex:OutputText Label="fax" value="{!Case.Account.Fax}"/>
<apex:OutputText Label="Contact First Name" value="{!Case.Contact.FirstName}"/>
<apex:OutputText Label="Contact Last Name" value="{!Case.Contact.LastName}"/>
<apex:OutputText Label="Oppty Owner Manager Email" value="{!Case.Opportunity__r.Owner.Manager.Email}"/>
<apex:OutputText Label="Case Market" value="{!Case.Case_Market__c}"/>
<apex:OutputText Label="Account Name" value="{!Case.Account.Name}"/>
<apex:OutputText Label="Opportunity Owner First Name" value="{!Case.Opportunity__r.Owner.FirstName}"/>
<apex:OutputText Label="Opportunity Owner Last Name" value="{!Case.Opportunity__r.Owner.LastName}"/>
<apex:OutputText Label="Contact Phone" value="{!Case.Contact.Phone}"/>
<apex:OutputText Label="Account Phone" value="{!Case.Account.Phone}"/>
<apex:OutputText Label="Total digital monthly fees" value="{!Case.Opportunity__r.Total_Digital_monthly_Fees__c}"/>
<apex:OutputText Label="total setup fees" value="{!Case.Opportunity__r.Total_Setup_Fees__c}"/>
<apex:OutputText Label="website" value="{!Case.Account.Website}"/>
 </apex:pageBlockSection>
        <apex:pageBlockButtons >
                <apex:commandButton action="{!sendOrder}" value="Send Order" oncomplete="finalRedirect();"  />
                <apex:commandButton action="{!Cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.