• Michael Welburn
  • NEWBIE
  • 125 Points
  • Member since 2014
  • Salesforce Engineer
  • Twitch


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 19
    Replies
Working through the Trailhead Visualforce Beginner section and working in the Using Standard List Controller section.  Following through the lesson, I am trying to get the pagination section to work but cannot seem to.  I have tried like 5 times now.  Any ideas on what I am doing wrong?

<apex:page standardController="Contact" recordSetVar="contacts">
    <apex:form>
        <apex:pageBlock title="Contacts List" id="contacts_list">
        
            Filter: 
            <apex:selectList value="{! filterId }" size="1">
                <apex:selectOptions value="{! listViewOptions }"/>
                <apex:actionSupport event="onchange" reRender="contacts_list"/>
            </apex:selectList>
        
            <!-- Contacts List -->
            <apex:pageBlockTable value="{! contacts }" var="ct">
                <!-- Pagination -->
                <table style="width: 100%"><tr>
                <td>
                <!-- Page X of Y -->
                    Page: <apex:outputText
                          value=" {!PageNumber} of {! CEILING(ResultSize / PageSize) }"/>
                </td>            

                <td align="center">
                   <!-- Previous page -->
                <!-- active -->
                    <apex:commandLink action="{! Previous }" value="« Previous"
                         rendered="{! HasPrevious }"/>
                <!-- inactive (no earlier pages) -->
                    <apex:outputText style="color: #ccc;" value="« Previous"
                         rendered="{! NOT(HasPrevious) }"/>

                    &nbsp;&nbsp;  

                <!-- Next page -->
                <!-- active -->
                    <apex:commandLink action="{! Next }" value="Next »"
                         rendered="{! HasNext }"/>
                <!-- inactive (no more pages) -->
                    <apex:outputText style="color: #ccc;" value="Next »"
                           rendered="{! NOT(HasNext) }"/>
                <!-- Next page -->
                </td>
    
                <td align="right">
                <!-- Records per page -->
                    Records per page:
                    <apex:selectList value="{! PageSize }" size="1">
                        <apex:selectOption itemValue="5" itemLabel="5"/>
                        <apex:selectOption itemValue="20" itemLabel="20"/>
                        <apex:actionSupport event="onchange" reRender="contacts_list"/>
                    </apex:selectList>
                </td>
                

                </tr></table>

                <apex:column value="{! ct.FirstName }"/>
                <apex:column value="{! ct.LastName }"/>
                <apex:column value="{! ct.Email }"/>
                   <apex:column value="{! ct.Account.Name }"/>
            </apex:pageBlockTable>
        
        </apex:pageBlock>
    </apex:form>
</apex:page>
Not experienced in apex code so would appreciate some help.
Within a controller I am trying to retrieve the first 3 characters of a field to either store or just query on direct.

I have the following two fields defined:

    public String orderHeaderReason {get; set;}
    public String orderHeaderReasonFirst3 {get; set;}

and then want to use them as follows:
              // Save the reason specified on the OrderHeader - this works OK
              orderHeaderReason = orderHeader.Reason_for_Order_FOC__c;

              // Save the first 3 characters of the same field   - this fails
              orderHeaderReasonFirst3 = orderHeader.Reason_for_Order_FOC__c.substring(0,2);

              //This also fails
              orderHeaderReasonFirst3= orderHeaderReason.substring(0,2);

I am assuming that I have not correctly defined the fields orderHeaderReason and  orderHeaderReasonFirst3 but cannot see what I should be doing - I need to instantiate them in some way?

Thanks
So I have a trigger that I want to run everytime a record is updated and created. However, when I use after insert and before update I get a record is locked error when creating the record.

How can I run this trigger on both record edit and creation (it only works before update)?   Better yet, is it possible to update any record "after update" or "after insert"?
 
trigger CalcBenefit on EA_App__c (before update, after insert) {
//works for update only.  insert throws error because I'm trying to change value
for (EA_App__C ea : Trigger.new){

    EA_App__C oldEA = Trigger.oldMap.get(ea.Id);

    if (ea.X3_Month_Income__c > CalculateBenefit.getMax(integer.valueOf(ea.Family_Size__c))){
        ea.App_Status__c = 'DENIED';            
        ea.Benefit_Amount__c = 0;                 

    }else if (ea.X3_Month_Income__c <= CalculateBenefit.getMin(integer.valueOf(ea.Family_Size__c)) && ea.App_Status__c != 'PAID'){
        //how to compare to old? 
        //&& (ea.X3_Month_Income__c != oldEA.X3_Month_Income__c || ea.Family_Size__c != oldEA.Family_Size__c)
        ea.Benefit_Amount__c = 0;                 
        ea.App_Status__c = 'SENT FOR APPROVAL';                

    }else{
        ea.App_Status__c = 'PAID';
        ea.Benefit_Amount__c = CalculateBenefit.calc(ea.X3_Month_Income__c, integer.valueOf(ea.Family_Size__c), ea.Fuel_Cost__c, '2015');
    }

}

 
I noticed that while I can leverage the UserPreferences fields to dictate Chatter related Email settings for standard Salesforce users, the same fields do not seem to affect Community (Customer, in this case) users. If I update the field via the Developer Console, the UI the Community User sees is not updated, and if I update via the UI the backend data is not affected. Is there another record where this information is captured?

The use case here is that I want to turn some of these email settings off when a community user is provisioned.

I cross posted this from the StackExchange forums, but there might be more information there as well: http://salesforce.stackexchange.com/questions/51885/community-user-email-settings-api
Hi,

       How to create the lightning component with google map instead of leaflet map. I saw the leaflet example in this link
'https://developer.salesforce.com/blogs/developer-relations/2015/04/creating-salesforce-lightning-map-component.html'  .   But I want to show the google map in lightning component. Please guide me how to get this.

Advance Thanks
Siva
 
Working through the Trailhead Visualforce Beginner section and working in the Using Standard List Controller section.  Following through the lesson, I am trying to get the pagination section to work but cannot seem to.  I have tried like 5 times now.  Any ideas on what I am doing wrong?

<apex:page standardController="Contact" recordSetVar="contacts">
    <apex:form>
        <apex:pageBlock title="Contacts List" id="contacts_list">
        
            Filter: 
            <apex:selectList value="{! filterId }" size="1">
                <apex:selectOptions value="{! listViewOptions }"/>
                <apex:actionSupport event="onchange" reRender="contacts_list"/>
            </apex:selectList>
        
            <!-- Contacts List -->
            <apex:pageBlockTable value="{! contacts }" var="ct">
                <!-- Pagination -->
                <table style="width: 100%"><tr>
                <td>
                <!-- Page X of Y -->
                    Page: <apex:outputText
                          value=" {!PageNumber} of {! CEILING(ResultSize / PageSize) }"/>
                </td>            

                <td align="center">
                   <!-- Previous page -->
                <!-- active -->
                    <apex:commandLink action="{! Previous }" value="« Previous"
                         rendered="{! HasPrevious }"/>
                <!-- inactive (no earlier pages) -->
                    <apex:outputText style="color: #ccc;" value="« Previous"
                         rendered="{! NOT(HasPrevious) }"/>

                    &nbsp;&nbsp;  

                <!-- Next page -->
                <!-- active -->
                    <apex:commandLink action="{! Next }" value="Next »"
                         rendered="{! HasNext }"/>
                <!-- inactive (no more pages) -->
                    <apex:outputText style="color: #ccc;" value="Next »"
                           rendered="{! NOT(HasNext) }"/>
                <!-- Next page -->
                </td>
    
                <td align="right">
                <!-- Records per page -->
                    Records per page:
                    <apex:selectList value="{! PageSize }" size="1">
                        <apex:selectOption itemValue="5" itemLabel="5"/>
                        <apex:selectOption itemValue="20" itemLabel="20"/>
                        <apex:actionSupport event="onchange" reRender="contacts_list"/>
                    </apex:selectList>
                </td>
                

                </tr></table>

                <apex:column value="{! ct.FirstName }"/>
                <apex:column value="{! ct.LastName }"/>
                <apex:column value="{! ct.Email }"/>
                   <apex:column value="{! ct.Account.Name }"/>
            </apex:pageBlockTable>
        
        </apex:pageBlock>
    </apex:form>
</apex:page>
Not experienced in apex code so would appreciate some help.
Within a controller I am trying to retrieve the first 3 characters of a field to either store or just query on direct.

I have the following two fields defined:

    public String orderHeaderReason {get; set;}
    public String orderHeaderReasonFirst3 {get; set;}

and then want to use them as follows:
              // Save the reason specified on the OrderHeader - this works OK
              orderHeaderReason = orderHeader.Reason_for_Order_FOC__c;

              // Save the first 3 characters of the same field   - this fails
              orderHeaderReasonFirst3 = orderHeader.Reason_for_Order_FOC__c.substring(0,2);

              //This also fails
              orderHeaderReasonFirst3= orderHeaderReason.substring(0,2);

I am assuming that I have not correctly defined the fields orderHeaderReason and  orderHeaderReasonFirst3 but cannot see what I should be doing - I need to instantiate them in some way?

Thanks
Hi Guys,
  I want to implement a customer community. I don't know how to start this and which license i have to take. Please help me out this.


Thanks & Regards,
Mahesh.
HI,

Please any one help me with code to implement the sorting functionality for dynamic colums in a table.

<apex:pageblock id="recds" >
                                    <apex:pageblockTable value="{!selectedObjreport}" var="r" id="theaddrs" rendered="{!IF(selectedObjreport.size!=0 , true , false)}">
                      <apex:repeat value="{!selectedObjFields}" var="FieldLable" id="repeat" >  
                       <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="{!r[FieldLable]}" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="{!r[FieldLable]}" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!r[FieldLable]}" rendered="{!IF(FieldLable != '--None--' , true, false)}"/>
            </apex:column>                                         
       </apex:repeat>
  </apex:pageblockTable>                      
</apex:pageblock>

Regards,
Anand
  • February 12, 2016
  • Like
  • 0
Hi 
I have a requirement  that  I need to share the IMAGES from slaesforce to social media like facebook or linkedin  by onclick the share button 
Is any one have been worked on social media sharing.

Please post a  sample code or url.It'svery urgent

Thanks
 
  • February 11, 2016
  • Like
  • 0
Hello,

I am trying to simply call a web service that one of my clients has.  This appears to be rocket science using Salesforce.  All paths have led to failure for this venture thus far.   I have seen all All Star in this community call the WSDL2Apex a crap shoot.  Has anyone in this community successfully called a 3rd party web service?  If so, please tell me how you accomplished this.  I prefer NOT to use the WSDL2Apex as the code that it generates is completely obfuscated and has complexity WITHOUT necessity. 

I understand that I must create a Remote Site setting for the webservice URL and also have the Salesforce IPs whitelisted on the webservice site.

How do I simply create some XML(SOAP envelope), send it over to the web service and get a response!!??????

Any help is deeply appreciated.

Thank you!!
I am trying to backup the entire org with eclipse.My eclipse gets struck.
what would be best way to entire org and also i need to back up them on weekly basis to my local directory.
Please help me with this.

Thanks in advance.
Hi all,

I am trying to login into Salesforce Customer Community using Facebook as Auth Provider. 

Issue faced: I am able to sign in to Salesforce community using facebook authentication, however I am not able to fetch the facebook user details such as firstname,lastname,email dynamically using the Registration Handler Class by  using data.firstname,data.lastname,data.email . Currently i am using static values for the fields like firstname,lastname,email 

Expected : Getting dynamic values from facebook in the code below where static values are provided.

Code for Registration Handler that i am using as below.

global class FacebookHandler implements Auth.RegistrationHandler{ 
    global User createUser(Id portalId, Auth.UserData data){
    system.debug('hahahahaha' +portalId);
      User result;
      try {
        //default account to collect Community Members
        Account a = [ SELECT Id
                      FROM Account
                      WHERE name='MyAllergy'
                      LIMIT 1
                  ];
      
       //default profile
      Profile p = [ SELECT Id
                     FROM Profile
                    WHERE name='Custom Customer Community Plus Login User'
                     LIMIT 1
                   ];
       //contact
       Contact c   = new Contact(
        accountId = a.Id,
         email     = 'prateek.sharma@salesforce.com',
         firstName = data.firstName,
         lastName = data.lastname

     //    lastName  = 'testr'
       );     
       insert c;
      //get the alias as username
      String alias = this.getAlias(data.username);
       //user
       User u = new User(
         username          = alias + '@community.com',                                    
         email             = 'prateek.sharma@salesforce.com',
        lastName          = 'testtr',
         firstName         = data.firstName,
        alias             = alias,
         languagelocalekey = 'en_US',
         localesidkey      = 'en_GB',
         emailEncodingKey  = 'UTF-8',
         timeZoneSidKey    = 'GMT',
        profileId         = p.Id,
         contactId         = c.Id
       );
       //binding
       result = u;
     }
     catch(Exception pEx) {
      //re-throwing exception to allow tracing the error from URL
      throw new HandlerException(
         pEx.getStackTraceString()
       );
     }
    return result;           
   }
   //custom exception
   global class HandlerException extends Exception{}
   global void updateUser(Id userId, Id portalId, Auth.UserData data){
        User u = new User(
       id        = userId,
      email     = 'prateek.sharma@salesforce.com',
       lastName  = 'tata',
     firstName = data.firstName,
     alias     = this.getAlias(data.username)
    );
    
     update u;
   }
   global String getAlias(String pUsername) {
     //generate random string (8)
     Blob blobKey           = crypto.generateAesKey(128);
     String key             = EncodingUtil.convertToHex(blobKey);
     String random_username = key.substring(0,8);
     //if not defined, create a random one
     String alias = pUsername != null ?
                     pUsername :
                     random_username;
     //check alias.length() > 8 and chop it
     alias = alias.length() > 8 ?
               alias.substring(0,8) :
               alias;
     return alias;
   }
}

Any help would be appreciated,

Thanks
So I have a trigger that I want to run everytime a record is updated and created. However, when I use after insert and before update I get a record is locked error when creating the record.

How can I run this trigger on both record edit and creation (it only works before update)?   Better yet, is it possible to update any record "after update" or "after insert"?
 
trigger CalcBenefit on EA_App__c (before update, after insert) {
//works for update only.  insert throws error because I'm trying to change value
for (EA_App__C ea : Trigger.new){

    EA_App__C oldEA = Trigger.oldMap.get(ea.Id);

    if (ea.X3_Month_Income__c > CalculateBenefit.getMax(integer.valueOf(ea.Family_Size__c))){
        ea.App_Status__c = 'DENIED';            
        ea.Benefit_Amount__c = 0;                 

    }else if (ea.X3_Month_Income__c <= CalculateBenefit.getMin(integer.valueOf(ea.Family_Size__c)) && ea.App_Status__c != 'PAID'){
        //how to compare to old? 
        //&& (ea.X3_Month_Income__c != oldEA.X3_Month_Income__c || ea.Family_Size__c != oldEA.Family_Size__c)
        ea.Benefit_Amount__c = 0;                 
        ea.App_Status__c = 'SENT FOR APPROVAL';                

    }else{
        ea.App_Status__c = 'PAID';
        ea.Benefit_Amount__c = CalculateBenefit.calc(ea.X3_Month_Income__c, integer.valueOf(ea.Family_Size__c), ea.Fuel_Cost__c, '2015');
    }

}

 
I'm would like to use a formula field which filters my end result based on the user who is curently logged in, in the creation of a roll up summary field on account object. Basically, I'm trying to get a count of all my opportunities for a given account but only when a field called "A&K Reporting Company" reads a certain country name based on user login specs. Each of our Sales Reps are responsible for different countries. So if the rep who is responsible for Argentina wants to know every time a certain account makes it's first confirmed opportunity to Argentina (Field A& K Reporting Company = Argentina) I've created a formula boolean type field which compares a field at the user level where the name of the country of the rep is inserted with this given country if it appears inside the given opportunity field record called A&K Reporting Company. If Argentina (in my example) shows up in both cases then my formula fields returns a True for the Argentina rep. However, if the rep is one from Canada then for the formula field to return true when this rep is logged in, the opportunity field data must read Canada. The name of this boolean formula field is my Localcountry and this is the field that I want to include in the roll up summary field of accounts to tag the count of the account's first opportunity but specifically to the country belonging to the specific rep logged in. Since formula fields are not accepted in RollUp Sumaries, I was wodering if someone can help me do this with code? I'm not familiar with coding so I don't know how easy or hard this would be. These reps don't own accounts or opportunities based on this field so unfortunately I can't tag ownership based on the name that is really indicated for the owner of the opportunity or account.