+ Start a Discussion
Suresh MeghnathiSuresh Meghnathi 
How can we display thousands of records on the VF page without using the StandardSetController or Pagination?
Best Answer chosen by Suresh Meghnathi
Ajay K DubediAjay K Dubedi
Hi Suresh,

If your purpose is to display the records only, then you can set the readOnly='true' in apex:page tag. Using this, the SOQL limit will be relaxed from 50000 to 100000.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
Sajjan T SSajjan T S 
I am trying to write a batch apex to schedule and delete cases that were created before 18 months along with the related files. Can someone help me with formulating the query, please?
Best Answer chosen by Sajjan T S
Sajjan T SSajjan T S
The working batch class code below:

Global class OldCaseDeleter implements Database.Batchable<SObject> {
    Public List<SObject> allRecords;
   Global Database.QueryLocator start(Database.BatchableContext BC) {
       String query = 'SELECT Id FROM Case WHERE CreatedDate = today and Exempt_From_Deletion__c = false';
       System.debug('query -> ' + query);
       return Database.getQueryLocator(query);
   }
   Global void execute(Database.BatchableContext BC, List<SObject> records) {
       List<Case> caseList = (List<Case>)records;
       Set<Id> caseID = new Set<Id>();
       for(Case c: caseList) {
           caseId.add(c.Id);
       }
       List<ContentDocumentLink> files = [SELECT ContentDocumentId, LinkedEntityId
                                          From ContentDocumentLink
                                          WHERE LinkedEntityId IN :caseId];
       Set<Id> conId = new Set<Id>();
       for(ContentDocumentLink cd : files) {
           conId.add(cd.ContentDocumentId);
       }
       List<ContentDocument> files1 = [SELECT Id, Title
                               FROM ContentDocument
                               WHERE Id IN : conId];
           allRecords = new List<SObject>();
        allrecords.addAll((List<SObject>)files1);
        allrecords.addAll((List<Case>)caseList);
        Delete allrecords;
   }
   Global void finish(Database.BatchableContext BC) {
   }
}

 
Best Answer chosen by ashish jadhav 9
Amit Chaudhary 8Amit Chaudhary 8
What is a Record Type?

Allows you to define different sets of picklist values for both standard and custom picklists
Record Types help you implement your custom business processes

Why use Record Types?
To segment picklist values specific to business needs
Examples: segment by division, product line, or region
Easier administration – fewer fields to maintain

Business Process

What is a Business Process?
•Allows you to track separate sales, support, and lead lifecycles across different divisions, groups, or markets
Available Business Processes:

--> Sales Processes - Create different sales processes that include some or all of the picklist values available for the Opportunity Stage field
--> Support Processes - Create different support processes that include some or all of the picklist values available for the Case Status field
--> Lead Processes - Create different lead processes that include some or all of the picklist values available for the Lead Status field
--> Solution Processes - Create different solution processes that include some or all of the picklist values available for the Solution Status field


Please let us know if this will help you

Thanks
Amit Chaudary
SandyMedaSandyMeda 
We have apex classes through which we send emails based on user action in force.com sites. It was working great until Friday, But yesterday when one of our customer try to submit application, they were getting error, In debug it says “SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, INVALID_TYPE: sObject type 'SalesforceIqDataSource' is not supported.: []”. I am pretty sure we did not change anything related to apex class, email template, vf page etc.. Does anyone know the reason or best way to fix this?
Best Answer chosen by SandyMeda
Signagelive DevelopmentSignagelive Development
Following on from Andrew's comment about Salesforce whitelisting the SalesforceIqDataSource for the site guest user I put in a ticket with Salesforce Support explaining the situation.

They whitelisted the SalesforceIqDataSource object for the site guest user for our organisation and I can confirm this has resolved the issue for us.

Therefore, for anyone still encountering this issue I was advise that you do the same thing and raise a ticket with Salesforce support.

Thanks everyone for the support on this.
Ram SRam S 
Hi All,
If any one finds difficulties in passing this challenge plz make changes in the VF page:
<apex:outputText value="{!sampleMergeField1}"/> <apex:outputText value="{!HTMLENCODE(sampleMergeField2)}" escape="false"/> <apex:outputText > {!sampleMergeField3} </apex:outputText> <script> document.write('{!JSINHTMLENCODE(sampleMergeField4)}'); </script> {!sampleMergeField5} <script> var x = '{!JSENCODE(sampleMergeField6)}'; </script> <apex:outputLabel value="{!HTMLENCODE(sampleMergeField7)}" escape="false"/>

Thanks,
Ram
Best Answer chosen by Ram S
Ram SRam S
<apex:outputText value="{!sampleMergeField1}"/> <apex:outputText value="{!HTMLENCODE(sampleMergeField2)}" escape="false"/> <apex:outputText > {!sampleMergeField3} </apex:outputText> <script> document.write('{!JSINHTMLENCODE(sampleMergeField4)}'); </script> {!sampleMergeField5} <script> var x = '{!JSENCODE(sampleMergeField6)}'; </script> <apex:outputLabel value="{!HTMLENCODE(sampleMergeField7)}" escape="false"/>
Bosede Omolayo 16Bosede Omolayo 16 
 Conference Management App - Create a Lightning Component with Server-Side Apex Controller:

Step 5: Add Component to the Speaker Record Page
Click App Default and then Assign as App Default.
Select the Conference app, then click Next and then Save.
Question: Does anyone know why Conference Management App is not listed for selection?

User-added image
I am also getting this error when I verify the hands on challenge:Note all APEX codes saved without errors. and all other steps worked.
Step not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: List has no rows for assignment to SObject

Thanks in advance for your help.
Best Answer chosen by Bosede Omolayo 16
SandhyaSandhya (Salesforce Developers) 
Hi,

Make sure that you are using brand new trailhead playground for thid challenge as there may be some pre existing configuration that is preventing to check challenge.

Best Regards,
Sandhya
LinThawLinThaw 
Hi,

I got following error on step 3.

Challenge Not yet complete... here's what's wrong: 
Couldn’t find Agency records from the Account object.

Can anyone pass this step?
Thanks in advance.

Regards,
LinThaw
Best Answer chosen by LinThaw
LinThawLinThaw
Hi Jennifer and ankita,

Please refer below, I passed this step 3.

fig 1.
User-added image

fig 2.
User-added image


and create Top 5 Agencies lenses.

Regards,
LinThaw
EtienneCoutantEtienneCoutant 

Hi,

 

Can someone help, I keep getting the error:

System.DmlException: Insert failed. First exception on row 0 with id 00oS0000000AOgYIAW; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

 

But I am pretty sure that there is no Id specified in my insert call.

Here is my code:

 

 

public PageReference save() { List<OpportunityLineItemSchedule> revenueSchedulesToUpdate = new List<OpportunityLineItemSchedule>(); List<OpportunityLineItemSchedule> revenueSchedulesToInsert = new List<OpportunityLineItemSchedule>(); for(revenueSchedulesDate revenueSchedulesDate:revenueSchedulesDates){ for(OpportunityLineItemSchedule revenueSchedule:revenueSchedulesDate.getRevenueSchedules()){ if(revenueSchedule.get('Id') == null) revenueSchedulesToInsert.add(revenueSchedule); else revenueSchedulesToUpdate.add(revenueSchedule); } if(revenueSchedulesToUpdate.size() > 0) update revenueSchedulesToUpdate; if(revenueSchedulesToInsert.size() > 0) insert revenueSchedulesToInsert; } return Page.revenueScheduleView2; }

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
wesnoltewesnolte

Hey

 

You're getting this error becuase you're adding items to list; inserting the list; adding more items to the list; and then trying to insert all the items you've already inserted and the new ones.

 

You shouldn't be performing DML inside a loop, although isn't directly causing your issue. Try this instead:

 

    public PageReference save() {
        List<OpportunityLineItemSchedule> revenueSchedulesToUpdate = new List<OpportunityLineItemSchedule>();
        List<OpportunityLineItemSchedule> revenueSchedulesToInsert = new List<OpportunityLineItemSchedule>();
       
        for(revenueSchedulesDate revenueSchedulesDate:revenueSchedulesDates){
            for(OpportunityLineItemSchedule revenueSchedule:revenueSchedulesDate.getRevenueSchedules()){
                if(revenueSchedule.get('Id') == null)
                    revenueSchedulesToInsert.add(revenueSchedule);
                else
                    revenueSchedulesToUpdate.add(revenueSchedule);
            }
        }
       
        update revenueSchedulesToUpdate;
        insert revenueSchedulesToInsert;       
       
        return Page.revenueScheduleView2;
    }

 

This will help with governor limits(although this still depends on the amoutn of data you work with), and will avoid your other issue.

 

Wes

 

 

Camila CamargoCamila Camargo 
Hi, everyone.

I'm a Salesforce beginner and I need help with this code. I want to this "Don't show this again checkbox" makes the modal to stop showing up instead of the handler doInit. I thought that I could only change the function position on the component, but it doesn't work. Can any of you help me step by step to make this works, please? I appreciate your time and patience. Here is my code:

Component
<aura:component implements="flexipage:availableForAllPageTypes"
                access="global">
    
<!--<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>-->
<aura:attribute name="isModalOpen" type="boolean" default="false"/> 
    
	<div class="demo-only">
        <!--Use aura:if tag to display/hide popup based on isModalOpen value-->  
        <aura:if isTrue="{!v.isModalOpen}">
  <section role="dialog" tabindex="-1" class="slds-modal slds-fade-in-open slds-modal_small" aria-labelledby="welcome-mat-95-label" aria-describedby="welcome-mat-95-content" aria-modal="true">
    <div class="slds-modal__container">
      <header class="slds-modal__header slds-modal__header_empty">
        <lightning:buttonIcon iconName="utility:close"
                                              onclick="{! c.closeModel }"
                                              alternativeText="close"
                                              variant="bare-inverse"
                                              class="slds-modal__close"/>
      </header>
      <div class="slds-modal__content" id="welcome-mat-95-content" style="overflow: hidden">
        <div class="slds-welcome-mat slds-welcome-mat_splash">
          <div class="slds-welcome-mat__content slds-grid">
            <div class="slds-welcome-mat__info slds-size_1-of-1">
              <div class="slds-welcome-mat__info-content">
                <h2 class="slds-welcome-mat__info-title" id="welcome-mat-95-label">The Lightning Experience is here!</h2>
                <div class="slds-welcome-mat__info-description slds-text-longform">
                  <p>Welcome to Lightning Experience, the modern, beautiful user experience from Salesforce. With a sales-and service-centric mindset, we focused on reinventing the desktop environment to better support your business processes.</p>
                </div>
                <div class="slds-welcome-mat__info-actions">
                  <button class="slds-button slds-button_brand">Learn More</button>
                 <div class="slds-m-top_large">
                    <div class="slds-form-element">
                      <div class="slds-form-element__control">
                        <div class="slds-checkbox">
                          <input type="checkbox" name="init" id="checkbox-8" onchange="{!c.doInit}" value="{!this}" />
                          <label class="slds-checkbox__label" for="checkbox-8">
                            <span class="slds-checkbox_faux"></span>
                            <span class="slds-form-element__label">Don&#x27;t show this again</span>
                          </label>
                        </div>
                      </div>
                    </div>
                  </div> 
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
            
  <div class="slds-backdrop slds-backdrop_open"></div>
     </aura:if>
</div>
</aura:component>

Controller
({
   doInit: function(component, event, helper) { 
 var temperorySession = sessionStorage.getItem('tempSession');
  if(temperorySession == '1')
        {  
      console.log('===== in If');
            component.set("v.isModalOpen", false);
  }
        else
        {
      console.log('===== in else');
      component.set("v.isModalOpen", true);
  }
   sessionStorage.setItem('tempSession', '1');
 },
  
   closeModel: function(component, event, helper) {
      // Set isModalOpen attribute to false  
      component.set("v.isModalOpen", false);
   },
})

Style
 
.THIS.pop-up {
    display: block;
    opacity: 1;
    visibility: visible;
    background-color: transparent;
}

.THIS .slds-modal__inner {
    background: yellow;
    padding: 20px;
    text-align:left;
}

.THIS .slds-modal__pinner {
    background: #fff;
    padding: 20px;
}

Best Regards,

Camila Camargo
Full Stack Developer
Best Answer chosen by Camila Camargo
Khan AnasKhan Anas (Salesforce Developers) 
Hi Camila,

Greetings to you!

You need to use init handler also so that when component refreshes it should get tempSession. But you need to set its value on button or checkbox click (according to your requirement). I have made a few changes to the code. If you click on a button without selecting checkbox it will display modal again on refresh but if you click on a button after selecting a checkbox the modal will not show again for that session.

Kindly modify the code as per your requirement.

Component:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    
    <aura:attribute name="isModalOpen" type="boolean" default="true"/>
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
    <div class="slds-m-around_xx-large" >
        
        <!--Use aura:if tag to display/hide popup based on isModalOpen value-->  
        <aura:if isTrue="{!v.isModalOpen}">
            
            <!-- Modal/Popup Box starts here-->
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <!-- Modal/Popup Box Header Starts here-->
                    <header class="slds-modal__header" style="border-bottom: none; padding: 0">
                        <lightning:buttonIcon iconName="utility:close"
                                              onclick="{! c.closeModel }"
                                              alternativeText="close"
                                              variant="bare-inverse"
                                              class="slds-modal__close"/>
                    </header>
                    <!--Modal/Popup Box Body Starts here-->
                    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1" style="overflow: hidden">
                        <img src="/resource/1556211422000/polybday26" alt="Aniversario Polyorganic" />
                    </div>
                    
                    <!--Modal/Popup Box Footer Starts here-->
                    <footer class="slds-modal__footer">
                        <div class="slds-m-top_large">
                            <div class="slds-form-element">
                                <div class="slds-form-element__control">
                                    <div>
                                        <ui:inputCheckbox aura:id="checkbox-8" 
                                                          change="{!c.doInit}" 
                                                          label="Don&#x27;t show this again   "/>
                                        
                                    </div>
                                </div>
                            </div>
                        </div>
                        

                        <lightning:button variant="brand"
                                          label="OK"
                                          title="OK"
                                          onclick="{!c.submitDetails}"/>
                    </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
            
        </aura:if>
    </div>
</aura:component>

Controller:
({
    doInit: function(component, event, helper) {
        var temperorySession = localStorage.getItem('tempSession');
        if(temperorySession == '1')
        {  
            console.log('===== in If');
            component.set("v.isModalOpen", false);
        }
        else
        {
            console.log('===== in else');
            component.set("v.isModalOpen", true);
        }
        //localStorage.setItem('tempSession', '0');
    },
    
    openModel: function(component, event, helper) {
        // Set isModalOpen attribute to true
        component.set("v.isModalOpen", true);
        
        
    },
    
    closeModel: function(component, event, helper) {
        // Set isModalOpen attribute to false  
        component.set("v.isModalOpen", false);
    },
    
    submitDetails: function(component, event, helper) {
        // Set isModalOpen attribute to false
        //Add your code to call apex method or do some processing
        var checkCmp = component.find("checkbox-8");
        var resultCmp = checkCmp.get("v.value");
        console.log('resultCmp-> ' + resultCmp);
        if(resultCmp==true){
            localStorage.setItem('tempSession', '1');
        }
        component.set("v.isModalOpen", false);
    },
})

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas​​​​​​​
uptime_andrewuptime_andrew 

I have an APEX Trigger that runs when a Task is created/updated, so it can update the related Case. 

 

Somehow, the trigger is causing the Case Assignment Rules to re-fire, but I don't know what.  Any thoughts?

 

 

 

trigger caseLastActivityDate on Task (after insert, after update) { Map<String, Task> tMap = new Map<String, Task>(); for (Task t : System.Trigger.new) { String whatId = t.WhatId; System.debug('whatId is ' + whatId); if(whatId <> null && whatId.startsWith('500') == true) { Case c = [select Id from Case where Id = :whatId]; if(c.Id <> null) { c.Last_Activity_Date__c = t.LastModifiedDate; update c; } } } }

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
uptime_andrewuptime_andrew

The solution I had for this was two-fold:

 

First, we added a new field, "Case Taken", which is just a boolean.   Once the case is taken by a user (who is not the default assignee), Case Taken is set to true.

 

Second, we updated the assignment rules with an new entry/step where if Case Taken equals True and the owner is not the default assigner, use the "Do Not Reassign Owner" flag.