• Nick Gachowicz
  • NEWBIE
  • 5 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi all, I'm a new developer and would appreciate any help with this question.

I am trying to pre-populate a lightning:select field based on a variable in the URL.

I am able to dynamically generate the list of options for the field, but I can't seem to get it to populate with the variable from the URL.

I am using a wrapper class to get both the list of options and my chosen option in the same call - class adapated from here: http://sfdcmonkey.com/2017/07/06/use-wrapper-class-lightning-component/

Here is my code:

Lightning Component:
<aura:component implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:appHostable,force:hasRecordId" controller="SADC_Contact_Us" access="global">
    
  
    <aura:attribute name="variableURL"                type="String" default="Nothing"/>
    <aura:attribute name="srvList"                type="Object"/> 
      
    <aura:handler name="init"    value="{!this}"                 action="{!c.onInit}" /> 
  
    <fieldset class="slds-box slds-m-top_small ">
        <legend class="slds-text-heading_medium">Provide us with some extra details</legend>
        

         <div class="slds-form-element__row">
            <div class="slds-form-element slds-size__2-of-2 slds-medium-size__1-of-2">
                <lightning:select aura:id="formField" name="formField" label="Service Area" required="true" value="{!v.variableURL}">
                    <option value="">- Not Specified -</option>
                    <aura:iteration items="{!v.srvList.lstServices}" var="ans">
                        <option value="{!ans.Name}" text="{!ans.Name}" selected="{!ans.Name == v.srvList.selectServ.Name}"></option>
                    </aura:iteration>
                </lightning:select>                             
            </div>
        </div> 
        
        
    </fieldset>
   
</aura:component>


Controller:
({
    onInit : function(component, event, helper) {
       
       var action = component.get("c.initMethod");
       var variableURL = component.get("v.variableURL");

       action.setParams({
           variableURL : variableURL
       });
        
       action.setCallback(this, function(a) {
            
         var state = a.getState();
         console.log("state: ",state);
            
         if (state === 'SUCCESS'){
                
             //set response value in wrapperList attribute on component.
             var response = a.getReturnValue();
             console.log("response: ",response);
                
                
             component.set("v.srvList",response);
            
            }
            
       });
      $A.enqueueAction(action);
        
    }
    
})


Apex Class:
public class SADC_Contact_Us {
    
       @AuraEnabled
           public static wrapperClass initMethod(String variableURL){
             //create a wrapper class object and set the wrapper class @AuraEnabled properties and return it to the lightning component.
               wrapperClass returnwrapperClass = new  wrapperClass ();        
               returnwrapperClass.lstServices = [SELECT Name from Website_Service__c WHERE Service_Level__c =1 LIMIT 25];
                returnwrapperClass.selectServ = [SELECT Name from Website_Service__c WHERE Service_Level__c =1 AND Name=:variableURL LIMIT 1];
              return returnwrapperClass;    
    }
    
       //wrapper or Inner class with @AuraEnabled {get;set;} properties*    
        public class wrapperClass{
                @AuraEnabled public List<Website_Service__c> lstServices{get;set;}
                @AuraEnabled public List<Website_Service__c> selectServ {get;set;}
        }    
}



So the aura:iteration on items="{!v.srvList.lstServices}" works fine, but this part does not load anything:

selected="{!ans.Name == v.srvList.selectServ.Name}

Can anyone advise how to get this selected part working?
Hi all,

Since our sandboxes have upgraded to Summer 19, we have noticed the text size has changed throughout our internal community (Customer Services template). The text size has decreased throughout the community by a few points.

Please compare these screenshots to see the difference:

Spring 19:
spring 19

Summer 19:
summer 19

Any ideas how to globally increase the text size back to how it was before? Perhaps using css? 

Salesforce Support weren't any help so wondered if you guys had any ideas.

I also tried this css but it didn't change anything that I could see: https://success.salesforce.com/answers?id=9063A000000lPq0QAE
Hi all,

Since our sandboxes have upgraded to Summer 19, we have noticed the text size has changed throughout our internal community (Customer Services template). The text size has decreased throughout the community by a few points.

Please compare these screenshots to see the difference:

Spring 19:
spring 19

Summer 19:
summer 19

Any ideas how to globally increase the text size back to how it was before? Perhaps using css? 

Salesforce Support weren't any help so wondered if you guys had any ideas.

I also tried this css but it didn't change anything that I could see: https://success.salesforce.com/answers?id=9063A000000lPq0QAE
Hi all, I'm a new developer and would appreciate any help with this question.

I am trying to pre-populate a lightning:select field based on a variable in the URL.

I am able to dynamically generate the list of options for the field, but I can't seem to get it to populate with the variable from the URL.

I am using a wrapper class to get both the list of options and my chosen option in the same call - class adapated from here: http://sfdcmonkey.com/2017/07/06/use-wrapper-class-lightning-component/

Here is my code:

Lightning Component:
<aura:component implements="flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes,force:appHostable,force:hasRecordId" controller="SADC_Contact_Us" access="global">
    
  
    <aura:attribute name="variableURL"                type="String" default="Nothing"/>
    <aura:attribute name="srvList"                type="Object"/> 
      
    <aura:handler name="init"    value="{!this}"                 action="{!c.onInit}" /> 
  
    <fieldset class="slds-box slds-m-top_small ">
        <legend class="slds-text-heading_medium">Provide us with some extra details</legend>
        

         <div class="slds-form-element__row">
            <div class="slds-form-element slds-size__2-of-2 slds-medium-size__1-of-2">
                <lightning:select aura:id="formField" name="formField" label="Service Area" required="true" value="{!v.variableURL}">
                    <option value="">- Not Specified -</option>
                    <aura:iteration items="{!v.srvList.lstServices}" var="ans">
                        <option value="{!ans.Name}" text="{!ans.Name}" selected="{!ans.Name == v.srvList.selectServ.Name}"></option>
                    </aura:iteration>
                </lightning:select>                             
            </div>
        </div> 
        
        
    </fieldset>
   
</aura:component>


Controller:
({
    onInit : function(component, event, helper) {
       
       var action = component.get("c.initMethod");
       var variableURL = component.get("v.variableURL");

       action.setParams({
           variableURL : variableURL
       });
        
       action.setCallback(this, function(a) {
            
         var state = a.getState();
         console.log("state: ",state);
            
         if (state === 'SUCCESS'){
                
             //set response value in wrapperList attribute on component.
             var response = a.getReturnValue();
             console.log("response: ",response);
                
                
             component.set("v.srvList",response);
            
            }
            
       });
      $A.enqueueAction(action);
        
    }
    
})


Apex Class:
public class SADC_Contact_Us {
    
       @AuraEnabled
           public static wrapperClass initMethod(String variableURL){
             //create a wrapper class object and set the wrapper class @AuraEnabled properties and return it to the lightning component.
               wrapperClass returnwrapperClass = new  wrapperClass ();        
               returnwrapperClass.lstServices = [SELECT Name from Website_Service__c WHERE Service_Level__c =1 LIMIT 25];
                returnwrapperClass.selectServ = [SELECT Name from Website_Service__c WHERE Service_Level__c =1 AND Name=:variableURL LIMIT 1];
              return returnwrapperClass;    
    }
    
       //wrapper or Inner class with @AuraEnabled {get;set;} properties*    
        public class wrapperClass{
                @AuraEnabled public List<Website_Service__c> lstServices{get;set;}
                @AuraEnabled public List<Website_Service__c> selectServ {get;set;}
        }    
}



So the aura:iteration on items="{!v.srvList.lstServices}" works fine, but this part does not load anything:

selected="{!ans.Name == v.srvList.selectServ.Name}

Can anyone advise how to get this selected part working?
Hi all,

Since our sandboxes have upgraded to Summer 19, we have noticed the text size has changed throughout our internal community (Customer Services template). The text size has decreased throughout the community by a few points.

Please compare these screenshots to see the difference:

Spring 19:
spring 19

Summer 19:
summer 19

Any ideas how to globally increase the text size back to how it was before? Perhaps using css? 

Salesforce Support weren't any help so wondered if you guys had any ideas.

I also tried this css but it didn't change anything that I could see: https://success.salesforce.com/answers?id=9063A000000lPq0QAE