• Alfredo Ornelas 4
  • NEWBIE
  • 70 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 9
    Replies
Hi,
I'm new with Apex, can you help me and modify this piece of code to share Opportunity with products instead of Contact record via S2S?
 
Here is basic code snippet to share a contact record via S2S programmatically.

PartnerNetworkRecordConnection newConnection =
                    new PartnerNetworkRecordConnection(
                        ConnectionId = networkId,
                        LocalRecordId = newContact.Id,
                        SendClosedTasks = false,
                        SendOpenTasks = false,
                        SendEmails = false,
                        ParentRecordId = newContact.AccountId);
insert newConnection;

 
Hi,
I'm new with Apex, can you share a code that I can add to my web to lead code to update "LeadSource" field with "Web2Lead" picklist value when creating a Lead from my web form?
I don't know about coding, can you tell me if it's possible to write a trigger to create new CONTACTS from My Unresolved Items? Instead of doing it manually? If so, can you share code? Thanks!

User-added image
Hi,

I'm new with VFP and I want to know if I can create the following  car diagram, and after selecting the checkbox options save the diagram.
Can you share code for class and VFP? thanks

User-added image
Hi,
Can you share a code and controller on how to delete tasks created by Marketo user? I want to clean up tasks on a weekly basis due to data storage limitations. Thanks
I enabled my visualforce page under Setup -> Develop -> Sites -> Click Site label -> Edit -> Move from Available VFP to Enabled VFP and an error is appearing: Page not found
What I'm missing? Thanks
Hi,
I have a PDF fiel (Whitepaper) and I want to create a Visualforce page so when a user click a button, they can see/download the PDF file.
Can you help me with the codes (VFP 7 controller)? thanks
I'm new on Apex, can some tell me if I can create a web form so my customer can download a video once they register? If so, can you share code for VP, class, controller? or something in the AppExchange to do so?
I created a VF page for a web form with sites. If the prospect goes to our website and enter all the required information on the form and click submit the "Authorization Required" Error appear on screen.
When I preview my VF page, enter all the required information and click submit, my Thank You page appears working properly. What I'm missing?

My Class and VF page below:
 
<apex:page standardController="Lead" extensions="myWeb2LeadExtension" title="Contact Us" showHeader="false" standardStylesheets="false">
  <apex:define name="body">
    <apex:pageBlock title="" mode="edit">
    
        <link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'></link>
    
<style type="text/css">

    body { 
        width: 100%; 
        height: auto; 
        margin: 0px; 
        padding: 0px;
        background-color: #ebebeb; 
        }
    
    #HEheader {
        margin: auto;
        width: 100%;
        height: 43px;
        background-color: #000;
        }
        
    #centered {
        margin: auto;
        width: 1024px;
        height: auto;
        background-color: #ffffff;
        overflow-y: auto;
        }

    #HEhead {
        margin: auto;
        width: 999px;
        height: 31px;
        padding-top: 12px;
        padding-left: 25px;
        }

    #EPheader {
        margin: auto;
        width: 999px;
        height: 70px;
        padding-top: 12px;
        padding-left: 25px;
        }
    #pageTitle {
        padding-left: 25px;
        width: 875px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:30px;
        font-weight:bold;
        color: #00728f;
        }
     #pageDesc {
        margin: 10px 0px 0px 0px;
        padding-left: 25px;
        width: 860px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:24px;
        font-weight:Normal;
        color: #333;
        }
    #pageBody{
        float: left;
        margin: 0px 25px 50px 25px;
        width: 390px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:18px;
        font-weight:Normal;
        color: #000;
        }
    #picture {
        float: left;
        margin: 15px 10px 0px 10px;
        }
    #FormCon  {
        float: left;
        margin: 0px 0px 0px 25px;
        width: 275px;
        }
    #EPformHead {
        height: 60px;
        }
    #EPform {
        padding: 15px;
        width: 315px;
        background-color: #e4e4e4;
        font-family:Verdana, Geneva, sans-serif;
        font-size:12px;
        text-align:left;
        }

</style>

    
   

      <script type="text/javascript">
      window.onload=function() {
          var queryDict = {}
          var cid = '';
          location.search.substr(1).split("&").forEach(function(item) {queryDict[item.split("=")[0]] = item.split("=")[1]})
          if(typeof queryDict['cid'] != 'undefined') {
            cid = queryDict['cid'];
          }
          
          var pageTitle = '';
          var pageDesc = '';
          var pageBody = '';
          var imgSrc = '';
          var videoSrc = ''; 
          switch(cid) {
          

       case 'DigitalBestPractices':
             pageTitle = 'Best Practices in Digital Marketing for the Oil and Gas Industry';
             pageDesc = '';
             pageBody = '<p>The oil and gas industry’s marketing landscape is evolving faster than ever before.<br\><br\>Marketers have access to new digital channels that weren’t available just 10 years ago.<br\><br\>To help you stay in front of the latest digital marketing trends, Hart Energy, in partnership with Unleaded Communications, Savage Brands and Foster Marketing, collected expert insights and live campaign data for this white paper.<br></br></p><p><strong><em>This white paper will discuss best practices in the following areas:</em></strong><ul><li>Native advertising.</li><li>Video and video production.</li><li>Social media.</li><li>Banner advertising and methods to increase engagement.</li></p><p style="margin-left:-1cm"><strong></strong></p>';
             imgSrc ="{!$Resource.DigitalBestPractices}";
       break;
       
             
 default:
              cid = ''; // Protect against injection
              pageBody = '<p style="color:red; font-weight:bold;">Missing or incorrect whitepaper.</p>';
              document.getElementById('contact-form').style.display = 'none';
videoSrc = '';
              break;
          }

          
          document.getElementById('pageTitle').innerHTML = pageTitle;
          document.getElementById('pageDesc').innerHTML = pageDesc;
          document.getElementById('pageBody').innerHTML = pageBody;
          document.getElementById('theImage').setAttribute('src', imgSrc);
          
          
          if(cid != '') {
            document.getElementsByTagName('form')[0].action += '?cid=' + cid;
          }
      }
      </script>

        

      <div id="centered">
          <div id="EPheader">
            <a href="http://www.hartfuel.com" target="_parent"><img src="http://digital.hartenergy.com/img/logo.png"/></a>
          </div>
          <hr />
          <div id="pageTitle"></div>
          <div id="pageDesc"></div>
          <div id="pageBody"><p></p></div>

          <div id="picture"><p align="center"><img id='theImage' src=""/></p></div>
        
        <div id="FormCon">
                <div id="EPformHead"><img src="http://www.hartenergy.com/images/email/register.jpg"/></div>
                <div id="EPform">
                 <apex:form >
                          <apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em; color:red;"/>
                          <apex:pageBlockSection title="Contact Us" collapsible="false" columns="1">
                  
                  
                  <apex:inputField required="true" value="{!Lead.FirstName}"/>
                  <apex:inputField required="true" value="{!Lead.LastName}"/>
                  <apex:inputField required="true" value="{!Lead.Email}"/>
                  <apex:inputField required="true" value="{!Lead.Company}" label="Company"/>
                  <apex:inputField required="true" value="{!Lead.Title}"/>
                  <apex:inputField required="true" value="{!Lead.Street}"/>
                  <apex:inputField required="true" value="{!Lead.City}"/>
                  <apex:inputField required="true" value="{!Lead.State_ProvinceDropdown__c}"/>
                  <apex:inputField required="true" value="{!Lead.PostalCode}"/>
                  <apex:inputField required="false" value="{!Lead.CountryDropDown__c}"/>
                  <apex:inputField required="false" value="{!Lead.Phone}"/>
                  <p>In addition to communications that may result from this inquiry, would you also like to receive news and
                   event email notifications from the sponsors that are specific to your interests? <apex:inputField value="{!Lead.WhitePaperAdditionalContact__c}"/></p>
                  <apex:commandButton value="Submit" action="{!saveLead}"/>
              </apex:pageBlockSection>
            </apex:form>
                
                
                </div>
        </div>
      </div>
    </apex:pageBlock>
  </apex:define>
</apex:page>
 
public class myWeb2LeadExtension {

 

    private final Lead weblead;



    public myWeb2LeadExtension(ApexPages.StandardController stdController) {

       weblead = (Lead)stdController.getRecord();

    }

     

     public PageReference saveLead() {

       try {
       weblead.whitepaperID__c = Apexpages.currentPage().getParameters().get('cid');

       insert(weblead);

       }

       catch(System.DMLException e) {

           ApexPages.addMessages(e);

           return null;

       }

     PageReference p = Page.ThankYouPageWhitePaper;
     p.getParameters().put('cid', Apexpages.currentPage().getParameters().get('cid'));
  

       p.setRedirect(true);

       return p;
       
    }
    
}

 
When trying to deplo a class this message appears?
User-added image
I don't have that option in my Org? What I need to do to enable Lightning Experience?
Hi,
I'm new with Apex, can you share a code that I can add to my web to lead code to update "LeadSource" field with "Web2Lead" picklist value when creating a Lead from my web form?
Hi,
Can you share a code and controller on how to delete tasks created by Marketo user? I want to clean up tasks on a weekly basis due to data storage limitations. Thanks
I enabled my visualforce page under Setup -> Develop -> Sites -> Click Site label -> Edit -> Move from Available VFP to Enabled VFP and an error is appearing: Page not found
What I'm missing? Thanks
Hi,
I have a PDF fiel (Whitepaper) and I want to create a Visualforce page so when a user click a button, they can see/download the PDF file.
Can you help me with the codes (VFP 7 controller)? thanks
I created a VF page for a web form with sites. If the prospect goes to our website and enter all the required information on the form and click submit the "Authorization Required" Error appear on screen.
When I preview my VF page, enter all the required information and click submit, my Thank You page appears working properly. What I'm missing?

My Class and VF page below:
 
<apex:page standardController="Lead" extensions="myWeb2LeadExtension" title="Contact Us" showHeader="false" standardStylesheets="false">
  <apex:define name="body">
    <apex:pageBlock title="" mode="edit">
    
        <link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300' rel='stylesheet' type='text/css'></link>
    
<style type="text/css">

    body { 
        width: 100%; 
        height: auto; 
        margin: 0px; 
        padding: 0px;
        background-color: #ebebeb; 
        }
    
    #HEheader {
        margin: auto;
        width: 100%;
        height: 43px;
        background-color: #000;
        }
        
    #centered {
        margin: auto;
        width: 1024px;
        height: auto;
        background-color: #ffffff;
        overflow-y: auto;
        }

    #HEhead {
        margin: auto;
        width: 999px;
        height: 31px;
        padding-top: 12px;
        padding-left: 25px;
        }

    #EPheader {
        margin: auto;
        width: 999px;
        height: 70px;
        padding-top: 12px;
        padding-left: 25px;
        }
    #pageTitle {
        padding-left: 25px;
        width: 875px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:30px;
        font-weight:bold;
        color: #00728f;
        }
     #pageDesc {
        margin: 10px 0px 0px 0px;
        padding-left: 25px;
        width: 860px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:24px;
        font-weight:Normal;
        color: #333;
        }
    #pageBody{
        float: left;
        margin: 0px 25px 50px 25px;
        width: 390px;
        font-family:'Open Sans Condensed', sans-serif;
        font-size:18px;
        font-weight:Normal;
        color: #000;
        }
    #picture {
        float: left;
        margin: 15px 10px 0px 10px;
        }
    #FormCon  {
        float: left;
        margin: 0px 0px 0px 25px;
        width: 275px;
        }
    #EPformHead {
        height: 60px;
        }
    #EPform {
        padding: 15px;
        width: 315px;
        background-color: #e4e4e4;
        font-family:Verdana, Geneva, sans-serif;
        font-size:12px;
        text-align:left;
        }

</style>

    
   

      <script type="text/javascript">
      window.onload=function() {
          var queryDict = {}
          var cid = '';
          location.search.substr(1).split("&").forEach(function(item) {queryDict[item.split("=")[0]] = item.split("=")[1]})
          if(typeof queryDict['cid'] != 'undefined') {
            cid = queryDict['cid'];
          }
          
          var pageTitle = '';
          var pageDesc = '';
          var pageBody = '';
          var imgSrc = '';
          var videoSrc = ''; 
          switch(cid) {
          

       case 'DigitalBestPractices':
             pageTitle = 'Best Practices in Digital Marketing for the Oil and Gas Industry';
             pageDesc = '';
             pageBody = '<p>The oil and gas industry’s marketing landscape is evolving faster than ever before.<br\><br\>Marketers have access to new digital channels that weren’t available just 10 years ago.<br\><br\>To help you stay in front of the latest digital marketing trends, Hart Energy, in partnership with Unleaded Communications, Savage Brands and Foster Marketing, collected expert insights and live campaign data for this white paper.<br></br></p><p><strong><em>This white paper will discuss best practices in the following areas:</em></strong><ul><li>Native advertising.</li><li>Video and video production.</li><li>Social media.</li><li>Banner advertising and methods to increase engagement.</li></p><p style="margin-left:-1cm"><strong></strong></p>';
             imgSrc ="{!$Resource.DigitalBestPractices}";
       break;
       
             
 default:
              cid = ''; // Protect against injection
              pageBody = '<p style="color:red; font-weight:bold;">Missing or incorrect whitepaper.</p>';
              document.getElementById('contact-form').style.display = 'none';
videoSrc = '';
              break;
          }

          
          document.getElementById('pageTitle').innerHTML = pageTitle;
          document.getElementById('pageDesc').innerHTML = pageDesc;
          document.getElementById('pageBody').innerHTML = pageBody;
          document.getElementById('theImage').setAttribute('src', imgSrc);
          
          
          if(cid != '') {
            document.getElementsByTagName('form')[0].action += '?cid=' + cid;
          }
      }
      </script>

        

      <div id="centered">
          <div id="EPheader">
            <a href="http://www.hartfuel.com" target="_parent"><img src="http://digital.hartenergy.com/img/logo.png"/></a>
          </div>
          <hr />
          <div id="pageTitle"></div>
          <div id="pageDesc"></div>
          <div id="pageBody"><p></p></div>

          <div id="picture"><p align="center"><img id='theImage' src=""/></p></div>
        
        <div id="FormCon">
                <div id="EPformHead"><img src="http://www.hartenergy.com/images/email/register.jpg"/></div>
                <div id="EPform">
                 <apex:form >
                          <apex:messages id="error" styleClass="errorMsg" layout="table" style="margin-top:1em; color:red;"/>
                          <apex:pageBlockSection title="Contact Us" collapsible="false" columns="1">
                  
                  
                  <apex:inputField required="true" value="{!Lead.FirstName}"/>
                  <apex:inputField required="true" value="{!Lead.LastName}"/>
                  <apex:inputField required="true" value="{!Lead.Email}"/>
                  <apex:inputField required="true" value="{!Lead.Company}" label="Company"/>
                  <apex:inputField required="true" value="{!Lead.Title}"/>
                  <apex:inputField required="true" value="{!Lead.Street}"/>
                  <apex:inputField required="true" value="{!Lead.City}"/>
                  <apex:inputField required="true" value="{!Lead.State_ProvinceDropdown__c}"/>
                  <apex:inputField required="true" value="{!Lead.PostalCode}"/>
                  <apex:inputField required="false" value="{!Lead.CountryDropDown__c}"/>
                  <apex:inputField required="false" value="{!Lead.Phone}"/>
                  <p>In addition to communications that may result from this inquiry, would you also like to receive news and
                   event email notifications from the sponsors that are specific to your interests? <apex:inputField value="{!Lead.WhitePaperAdditionalContact__c}"/></p>
                  <apex:commandButton value="Submit" action="{!saveLead}"/>
              </apex:pageBlockSection>
            </apex:form>
                
                
                </div>
        </div>
      </div>
    </apex:pageBlock>
  </apex:define>
</apex:page>
 
public class myWeb2LeadExtension {

 

    private final Lead weblead;



    public myWeb2LeadExtension(ApexPages.StandardController stdController) {

       weblead = (Lead)stdController.getRecord();

    }

     

     public PageReference saveLead() {

       try {
       weblead.whitepaperID__c = Apexpages.currentPage().getParameters().get('cid');

       insert(weblead);

       }

       catch(System.DMLException e) {

           ApexPages.addMessages(e);

           return null;

       }

     PageReference p = Page.ThankYouPageWhitePaper;
     p.getParameters().put('cid', Apexpages.currentPage().getParameters().get('cid'));
  

       p.setRedirect(true);

       return p;
       
    }
    
}

 
When trying to deplo a class this message appears?
User-added image
I don't have that option in my Org? What I need to do to enable Lightning Experience?