• Chris Simmons 3
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
Hi,

I'm trying to incorporate an If-Then statement into my visualforce section. For instance, if Field X = true, display these values, otherwise display nothing. 

What's the syntax for including an If-Then statement in my visualforce?
We're using DocuSign for Salesforce. I'm trying to combine the syntax of the Send with DocuSign button & then a field update button so that when the combined button is clicked, the field update fires on the Opportunity & the user is redirected to the DocuSign interface. What should the syntax look like to combine the two actions?

Send with DocuSign Syntax

{!REQUIRESCRIPT("/apex/dsfs__DocuSign_JavaScript")}
DocuSign_CreateEnvelope();

User-added image

Field Update Button Syntax

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var opportunityObj = new sforce.SObject("Opportunity"); 

opportunityObj.Id = '{!Opportunity.Id}'; 

opportunityObj.DocuSign_Template__c = 'Order Form'; 

var result = sforce.connection.update([opportunityObj]); 

if (result[0].success=='false') { 

alert(result[0].errors.message); 

} else { 

location.reload(true); 

}

User-added image

 
My end goal is to add a Visualforce Page to the Home Page that will (a) have three Report Components, (b) redirect the user to the Report in a new window when they click on one of the Report Components (as opposed to the default functionality where the Report will open within the frame), & (c) have 3 columns for the 3 Report Components.

I don't have any development experience, but was able to cobble together the snippet below...

<!-- Begin Default Content REMOVE THIS -->
  <apex:page >
       <apex:pageBlock >
           <apex:pageBlockSection columns="3">
           
<!-- My Leads/Contacts that are SQLs Report -->  
           <!-- Ensure that when the user clicks on the chart, it redirects to a new window as opposed to default functionality to open up within the Visualforce frame -->        
                <script type="text/javascript">
                      function Test(){
                      var url = 'https://ap1.salesforce.com/00OQ0000000PxZd';
                      window.parent.location.replace(url);
                 }
                 </script>
                 <apex:outputLink onclick="Test();">
                 <analytics:reportChart reportId="00OQ0000000PxZd"></analytics:reportChart>
                 </apex:outputLink>
                 
<!-- My Activities Due Today Report --> 
           <!-- Ensure that when the user clicks on the chart, it redirects to a new window as opposed to default functionality to open up within the Visualforce frame -->
                <script type="text/javascript">
                      function Test(){
                      var url = 'https://ap1.salesforce.com/00OQ0000000Q2KU';
                      window.parent.location.replace(url);
                 }
                 </script>
                 <apex:outputLink onclick="Test();">
                 <analytics:reportChart reportId="00OQ0000000Q2KU"></analytics:reportChart>
                 </apex:outputLink>  
                 
<!-- My Open Opps for this Fiscal Quarter Report -->  
            <!-- Ensure that when the user clicks on the chart, it redirects to a new window as opposed to default functionality to open up within the Visualforce frame -->
                <script type="text/javascript">
                      function Test(){
                      var url = 'https://ap1.salesforce.com/00OQ0000000Q2KZ';
                      window.parent.location.replace(url);
                 }
                 </script>
                 <apex:outputLink onclick="Test();">
                 <analytics:reportChart reportId="00OQ0000000Q2KZ"></analytics:reportChart>
                 </apex:outputLink>
                 
          </apex:pageBlockSection>
       </apex:pageBlock>
  </apex:page>
  <!-- End Default Content REMOVE THIS -->

The snippet displays the Report Component in three columns (good), but the columns are staggered (bad). When I click on the Report Components, it tries to redirect me to a new window (good), but the new window is just a salesforce login page (not sure if that's good or bad).

I was hoping y'all could take a look at the code & offer suggestions on how I can get the Report Components in a straight line & let me know if the existing code will open the Report Components in a new window.

User-added image