• Michael Merino 1
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 14
    Replies

In Salesforce Classic I have a visualforce page with the following code

                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Order Mode" for="orderMode" />
                    <apex:actionRegion >
                        <apex:inputField value="{!newCase.Order_Mode__c}" id="orderMode">
                            <apex:actionSupport event="onchange" action="{!changedOption}"
                                reRender="ordModeDetails" />
                        </apex:inputField>
                    </apex:actionRegion>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem />
                
                <apex:outputPanel id="ordModeDetails">
                    <apex:pageBlockSection id="cati"
                        rendered="{!newCase.Order_Mode__c=='Catering'}">
                        <apex:inputField value="{!newCase.Catering_Number_of_People_Served__c}" />
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="catin"
                        rendered="{!newCase.Order_Mode__c=='Catering'}">
                        <apex:inputField value="{!newCase.Catering_Occasion__c}" />
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="om"
                        rendered="{!newCase.Order_Mode__c=='Delivery'}">
                        <apex:inputField value="{!newCase.Delivery_Provider__c}" />
                    </apex:pageBlockSection>
                </apex:outputPanel>
                
What this does is 
if a person selects Catering from an Order_Mode dropdown, 2 new fields will appear on the page, Catering_Number_of_People_Served__c AND Catering_Occasion__c
if a person selects Delivery from an Order_Mode dropdown, 1 new field will appear on the page, Delivery_Provider__c

HOW DO I DO THIS KIND OF CONDITIONAL RENDERING IN A CUSTOM LIGHTNING COMPONENT?  for both based on a picklist (as above) and based on a checkbox (not shown)

classic image
I need to grab a few fields from a custom account for my lightning componnet doInit method.  Currently I do about 4 apex calls and each returns a single field.  This approach is working fine.  But I would like the apex method to return the whole record .  this is not working
/////////////////////////////////////
@AuraEnabled
public static String getRoyaltyAccount(Id raId) {
        List<Royalty_Account__c> x = [Select r.Proposed_Email__c, r.Name, r.Id, r.Number__c, r.active__c From Royalty_Acct__c r where Id=:raId];
        String response = JSON.serialize(x);
        system.debug('### response '+response);
        return response; 
}
/////////////////////////////////////
10:08:31:014 USER_DEBUG [287]|DEBUG|### response [{"attributes":{"type":"Royalty_Acct__c","Name":"Al Hansen","Id":"a0t0v000001M","Number__c":"12345538836389","Email__c":"aa@aardvark.org","Phone_Type__c":"landline",
/////////////////////////////////////
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride" access="global" 
                controller="RoyaltyServicesController_RR"> 
    <aura:attribute name="record" type="Object" 
    <aura:attribute name="simpleRecord" type="Object" />
    <aura:attribute name="recordError" type="String" 
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <div class="slds-clearfix">
        <div class="slds-float_right">
            <lightning:button label="Edit" variant="neutral" onclick="{!c.handleClick}"/>    
            <lightning:button label="Generate Cardless " aura:id="generateCardBtn" variant="neutral" onclick="{!c.generateCard1}" />
   
        </div>
    </div>
    
    <force:recordData aura:id="currentRecord"
                      recordId="{!v.recordId}"
                      targetRecord="{!v.simpleRecord}"
                      targetError="{!v.error}"
                      layoutType="FULL" 
                      recordUpdated="{!c.recordUpdated}" />

/////////////////////////////////////                      
doInit  : function(component, event, helper) {
        var action = component.get("c.getAcctRec");
        action.setParams({raId : component.get("v.recordId") });
        action.setCallback(this, function(a){
            var state = a.getState(); // get the response state
            if(state === 'SUCCESS') {
                var responseObj = JSON.parse(a.getReturnValue());
            component.set("v.simpleRecord",responseObj);
            /////////////NEXT LINE DOES NOT WORK /////////////////
        var pe = component.get("v.simpleRecord").fields.Proposed_Email__c.value; // uses RecordData
            }});
        $A.enqueueAction(action);
    } 
/////////////////////////////////////
here is what I see in Inspect on the responseObj
responseObj = "[{"attributes":{"type":"Royalty_Acct__c","Name":"Al ...

so the string is being returned into the controller I just need to know how to parse it to get the four fields
I have a Site that currently collects customer info on a complaint (e.g. name, restaurant locale) without requiring guests to login to Salesforce.  My business partners would like to see this form modernized and the trailhead course, Build a Community with Knowledge and Chat, seems like a very nice update.  I can incorporate Knowledge articles and collect custom support fields for a new case.

I found that this Contact Customer Support page uses a global action to collect data.  In the global action, new case layout it lists a number of fields you can add or remove from the page layout.  BUT this is a small subset of Case fields. 

How do I add/reference case fields not in this list of case fields.

newcase global action screenshot
list of case fields


 
 
I'm trying to make this as simple as possible.  I have a classic VFP with an "interesting" controller I inherited.  In my lightning sandbox, I created a Visualforce quick action
User-added image
I then added this quick action to the Case page layout Salesforce Mobile and Lightning Experience Actions.  

The good news is it works, allowing me to use the custom edit to modify the case and then save it

ANNONYANCE 1 - the button is on the right side with Chatter
ANNONYANCE 2 - editing this case only shows a small section of the case and you need to scroll to edit more
User-added image
ANNOYANCE 3 -the save works but the right side detail record does not show the change.  Clicking F5 also does not show the update on right side.  Clicking the Chrome Reload this page icon in upper left does actual do a true refresh where I can see the update on right panel.

any thoughts on how to get rid of annoyance 3, I know 1 & 2 are just current lightning standards and if I wanted to get around them I would need to do it either programmatically or with a lightning record page  but the goal is to initially make as few changes as necessary.
I have a visualforce page that successfully hides a pageblocksection using the reRender attribute until a checkbox, Food Illness, is clicked.  Then I can fill in the fields in the hidden section.  If I click SAVE this all works great. 

BUT if with the hidden section shown, I reset the hidden checkbox to unchecked and change both picklists to NULL, and THEN uncheck Food Illness and SAVE; an alert in the commandbutton states the hidden fields still contain data.  And if I edit again, the original saved values are not nulled out, WHICH IS WHAT I WANT.

<apex:page standardController="Case" tabStyle="Case" id="Page" lightningStylesheets="true">
    <apex:form id="form1">   
    <apex:PageBlock >   
            <apex:pageBlockButtons >
                <apex:commandButton value="Save"  onclick="return alert({!Case.Medical_Attention_Required__c})" action="{!save}" />
                <apex:commandButton action="{!cancel}" value="Cancel" />
            </apex:pageBlockButtons>    

            <apex:pageBlockSection showHeader="true" title="Escalated" columns="1" id="escalated">

                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Risk" style="font-weight:bold" />
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                        {!$ObjectType.Case.fields.Food_Illness__c.label}
                        <apex:actionRegion >
                            <apex:inputField value="{!Case.Food_Illness__c}">
                                <apex:actionSupport event="onchange"  reRender="foodIll" />
                            </apex:inputField>
                        </apex:actionRegion>
                </apex:pageBlockSectionItem>

               <!-- hidden section- ->
                <apex:outputPanel id="foodIll">
                    <apex:pageBlockSection columns="2" id="fi" rendered="{!Case.Food_Illness__c}" title="Food Illness">
                        <apex:inputField value="{!Case.Medical_Attention_Required__c}" />
                        <apex:outputText value="" />
                        <apex:inputField value="{!Case.Illness__c}" />
                        <apex:inputField value="{!Case.Food_Preparation__c}" />
                    </apex:pageBlockSection>
                </apex:outputPanel>               
                </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Screen Shot of VF page


 

In Salesforce Classic I have a visualforce page with the following code

                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Order Mode" for="orderMode" />
                    <apex:actionRegion >
                        <apex:inputField value="{!newCase.Order_Mode__c}" id="orderMode">
                            <apex:actionSupport event="onchange" action="{!changedOption}"
                                reRender="ordModeDetails" />
                        </apex:inputField>
                    </apex:actionRegion>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem />
                
                <apex:outputPanel id="ordModeDetails">
                    <apex:pageBlockSection id="cati"
                        rendered="{!newCase.Order_Mode__c=='Catering'}">
                        <apex:inputField value="{!newCase.Catering_Number_of_People_Served__c}" />
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="catin"
                        rendered="{!newCase.Order_Mode__c=='Catering'}">
                        <apex:inputField value="{!newCase.Catering_Occasion__c}" />
                    </apex:pageBlockSection>
                    <apex:pageBlockSection id="om"
                        rendered="{!newCase.Order_Mode__c=='Delivery'}">
                        <apex:inputField value="{!newCase.Delivery_Provider__c}" />
                    </apex:pageBlockSection>
                </apex:outputPanel>
                
What this does is 
if a person selects Catering from an Order_Mode dropdown, 2 new fields will appear on the page, Catering_Number_of_People_Served__c AND Catering_Occasion__c
if a person selects Delivery from an Order_Mode dropdown, 1 new field will appear on the page, Delivery_Provider__c

HOW DO I DO THIS KIND OF CONDITIONAL RENDERING IN A CUSTOM LIGHTNING COMPONENT?  for both based on a picklist (as above) and based on a checkbox (not shown)

classic image
I need to grab a few fields from a custom account for my lightning componnet doInit method.  Currently I do about 4 apex calls and each returns a single field.  This approach is working fine.  But I would like the apex method to return the whole record .  this is not working
/////////////////////////////////////
@AuraEnabled
public static String getRoyaltyAccount(Id raId) {
        List<Royalty_Account__c> x = [Select r.Proposed_Email__c, r.Name, r.Id, r.Number__c, r.active__c From Royalty_Acct__c r where Id=:raId];
        String response = JSON.serialize(x);
        system.debug('### response '+response);
        return response; 
}
/////////////////////////////////////
10:08:31:014 USER_DEBUG [287]|DEBUG|### response [{"attributes":{"type":"Royalty_Acct__c","Name":"Al Hansen","Id":"a0t0v000001M","Number__c":"12345538836389","Email__c":"aa@aardvark.org","Phone_Type__c":"landline",
/////////////////////////////////////
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride" access="global" 
                controller="RoyaltyServicesController_RR"> 
    <aura:attribute name="record" type="Object" 
    <aura:attribute name="simpleRecord" type="Object" />
    <aura:attribute name="recordError" type="String" 
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <div class="slds-clearfix">
        <div class="slds-float_right">
            <lightning:button label="Edit" variant="neutral" onclick="{!c.handleClick}"/>    
            <lightning:button label="Generate Cardless " aura:id="generateCardBtn" variant="neutral" onclick="{!c.generateCard1}" />
   
        </div>
    </div>
    
    <force:recordData aura:id="currentRecord"
                      recordId="{!v.recordId}"
                      targetRecord="{!v.simpleRecord}"
                      targetError="{!v.error}"
                      layoutType="FULL" 
                      recordUpdated="{!c.recordUpdated}" />

/////////////////////////////////////                      
doInit  : function(component, event, helper) {
        var action = component.get("c.getAcctRec");
        action.setParams({raId : component.get("v.recordId") });
        action.setCallback(this, function(a){
            var state = a.getState(); // get the response state
            if(state === 'SUCCESS') {
                var responseObj = JSON.parse(a.getReturnValue());
            component.set("v.simpleRecord",responseObj);
            /////////////NEXT LINE DOES NOT WORK /////////////////
        var pe = component.get("v.simpleRecord").fields.Proposed_Email__c.value; // uses RecordData
            }});
        $A.enqueueAction(action);
    } 
/////////////////////////////////////
here is what I see in Inspect on the responseObj
responseObj = "[{"attributes":{"type":"Royalty_Acct__c","Name":"Al ...

so the string is being returned into the controller I just need to know how to parse it to get the four fields
I have a trigger that has multiple checkbox and when i user clicks any of them i need the trigger to create a new record with a specific record type. My code below only allows the creation of  the records but only if all the checkboxes are checked. Once the record has one product it doesnt create another product. Any help would be gratly appreciated. 
 
trigger TriggerNewYushinProd on Opportunity (before update, before insert) {

List<Yushin_Product__c> oppList = new List<Yushin_Product__c>();
for(Opportunity a:[SELECT Id,Name,AccountId,Robot__c,EOAT__c,Conveyor__c,Safety_Guarding__c,Type from Opportunity where Id IN:Trigger.new AND Id NOT IN(SELECT Opportunity__c from Yushin_Product__c)]){
for(Integer i=6;i<=100;i++)
    
{
if (a.Robot__c == true){
    
    oppList.add(New Yushin_Product__c(Opportunity__c=a.Id,Account__c=a.AccountId, RecordTypeId='012180000004huP',Equipment_Type__c='Robot' ));
    }
    
    if (a.EOAT__c == true){
    
    oppList.add(New Yushin_Product__c(Opportunity__c=a.Id,Account__c=a.AccountId, RecordTypeId='012180000004huU',Equipment_Type__c='EOAT' ));
    }
    
    if (a.Conveyor__c == true){
    
    oppList.add(New Yushin_Product__c(Opportunity__c=a.Id,Account__c=a.AccountId, RecordTypeId='012180000004huZ',Equipment_Type__c='Conveyor' ));
    }
    
    if (a.Safety_Guarding__c == true){
    
    oppList.add(New Yushin_Product__c(Opportunity__c=a.Id,Account__c=a.AccountId, RecordTypeId='012180000004hue',Equipment_Type__c='Safety Guarding' ));
    }
    If(oppList.Size()>0){
        upsert oppList;
       
        }
}
}
}

 
  • August 27, 2018
  • Like
  • 0
I want to compare code changes in all classes in my dev and qa org.
I'm trying to make this as simple as possible.  I have a classic VFP with an "interesting" controller I inherited.  In my lightning sandbox, I created a Visualforce quick action
User-added image
I then added this quick action to the Case page layout Salesforce Mobile and Lightning Experience Actions.  

The good news is it works, allowing me to use the custom edit to modify the case and then save it

ANNONYANCE 1 - the button is on the right side with Chatter
ANNONYANCE 2 - editing this case only shows a small section of the case and you need to scroll to edit more
User-added image
ANNOYANCE 3 -the save works but the right side detail record does not show the change.  Clicking F5 also does not show the update on right side.  Clicking the Chrome Reload this page icon in upper left does actual do a true refresh where I can see the update on right panel.

any thoughts on how to get rid of annoyance 3, I know 1 & 2 are just current lightning standards and if I wanted to get around them I would need to do it either programmatically or with a lightning record page  but the goal is to initially make as few changes as necessary.
I have a visualforce page that successfully hides a pageblocksection using the reRender attribute until a checkbox, Food Illness, is clicked.  Then I can fill in the fields in the hidden section.  If I click SAVE this all works great. 

BUT if with the hidden section shown, I reset the hidden checkbox to unchecked and change both picklists to NULL, and THEN uncheck Food Illness and SAVE; an alert in the commandbutton states the hidden fields still contain data.  And if I edit again, the original saved values are not nulled out, WHICH IS WHAT I WANT.

<apex:page standardController="Case" tabStyle="Case" id="Page" lightningStylesheets="true">
    <apex:form id="form1">   
    <apex:PageBlock >   
            <apex:pageBlockButtons >
                <apex:commandButton value="Save"  onclick="return alert({!Case.Medical_Attention_Required__c})" action="{!save}" />
                <apex:commandButton action="{!cancel}" value="Cancel" />
            </apex:pageBlockButtons>    

            <apex:pageBlockSection showHeader="true" title="Escalated" columns="1" id="escalated">

                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Risk" style="font-weight:bold" />
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                        {!$ObjectType.Case.fields.Food_Illness__c.label}
                        <apex:actionRegion >
                            <apex:inputField value="{!Case.Food_Illness__c}">
                                <apex:actionSupport event="onchange"  reRender="foodIll" />
                            </apex:inputField>
                        </apex:actionRegion>
                </apex:pageBlockSectionItem>

               <!-- hidden section- ->
                <apex:outputPanel id="foodIll">
                    <apex:pageBlockSection columns="2" id="fi" rendered="{!Case.Food_Illness__c}" title="Food Illness">
                        <apex:inputField value="{!Case.Medical_Attention_Required__c}" />
                        <apex:outputText value="" />
                        <apex:inputField value="{!Case.Illness__c}" />
                        <apex:inputField value="{!Case.Food_Preparation__c}" />
                    </apex:pageBlockSection>
                </apex:outputPanel>               
                </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Screen Shot of VF page


 

I am wondering if there is a way we can specify more than one components in rerender attribute of any component.

 

I guess one way we can achieve is to put all components to be rerendered in once panel and then rerender that panel. However, our requirement is that we need to rerender two components which cannot be put in a single panel due to the layout requirement.

 

Is there any way/workaournd to achieve this?

 

Thank you,