• Wmin
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
I get an error during deployment validation: 

A driving SObject type has already been set, all other entity types in the FROM clause must be relationships to the initial object.

The query that defines the scope for a batch job works fine in the Sandbox:

"Select id, Expiry_date_of_your_license_to_trade__c, Has_Live_Contract__c, Licence_Reminders_Sent__c, Proprietor_First_Name__c, Proprietor_Email_Address__c, Operator_Main_Contact_Email__c, Main_Contract_Email_Lookup__c, Main_Contact_Lookup__c from Bid_Information__c where Has_Live_Contract__c = True and (Licence_Reminders_Sent__c < 1 or Licence_Reminders_Sent__c = NULL) and Main_Contract_Email_Lookup__c != \'\' and (Expiry_date_of_your_license_to_trade__c <='+ String.valueOf(expdate) +' and Expiry_date_of_your_license_to_trade__c != NULL)"

Any help would be appreciated.
  • March 30, 2020
  • Like
  • 0
I am processing hundreds of thousands of call records that must be assigned to their respective telephone lines based on the phone number. I wanted to retrieve a list of Phone Line records and then create multiple batch jobs to find all related telephone call records. 

public void GetLines(){

        List<Lines__c> lines = [Select id, phone_number__c from lines__c ORDER BY Line_Status__c ASC];
        
        for(Lines__c l: lines){
                   ExecuteBatchUpdate(l.id, l.phone_number__c );         
        }  
    }

public void ExecuteBatchUpdate(Id lineid, String phone){
..
If(Test.isRunningTest()){
            Id batchInstanceId = Database.executeBatch(new BatchUpdateCallRecordsAssingLine(q, Lineid), 20); 
            System.abortJob(batchInstanceId);
        }else{
                Database.executeBatch(new BatchUpdateCallRecordsAssingLine(q, Lineid));
        }
..
}

Unfortunately, I get System.LimitException: Too many DML statements: 151

Is it possible to call Database.executeBatch from a loop?  If not, what is the right way do deal with this scenario?

Your advice would be much appreciated.

Many thanks in advance.
 
  • October 31, 2019
  • Like
  • 0
Our Community Portal form has around 130 fields; some of those are required, some have validation. 

It takes at least thirty minutes to fill in the form, and unless all validation is passed and the required fields are completed, the form can't be saved. Because of the length, it can be challenging to track missed fields or bad input and can lead to form abandonment or loss of information due to browser crash other factors.

Unfortunately, the form has to be so long for compliance reasons; all information is stored in a single custom object. 

Is there a way to break down this form into multiple pages yet keeping everything in a single object, or give users an opportunity to save without instant validation until the form is ready for submission?

What is the best way to deal with this problem?
  • April 05, 2019
  • Like
  • 0
Not too familiar with maps and aggregateResult in SF, so I'm not sure if this is a formatting issue or something else, but I keep getting that error in my trigger when this is called.
Map<Id,aggregateResult> maxDates = new Map<id,AggregateResult>([Select whoid id, Max(Sales_Activity_Date__c) myMax, Min(Sales_Activity_Date__c) myMin from Task 
         where whoid = :who and status = 'Completed' and whoid!=NULL GROUP BY whoid]);

Is it a formatting issue, or something else?

Thanks.

Hi Everyone,

 

I'm new to working with Apex code and I have looked around for the answer to this but everyone seems to have a slightly different situation. I have the fields for a custom object displayed on a site that I want public users to be able to use to create new records. However, when I submit a new record it takes me to a logon page because it is attempting to take me to the new record. Instead I want it to take users to a page that says they successfully created a record. I have created a controller extension to override the save action but something is wrong with it as it does not even work on the VF page, I get the error "System.NullPointerException: Attempt to de-reference a null object" "Class.MyPageController.save: line 8, column 8 External entry point" , where line 8 is the "Insert request" line. I have been working from information on the two sites below. Any help would be greatly appreciated.

 

http://blog.jeffdouglas.com/2008/11/14/redirecting-users-to-different-visualforce-pages/

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_pagereference.htm

 

Site Code

<apex:page sidebar="false" showHeader="false" standardController="Request__c" extensions="MyPageController">   
<apex:form >
    <apex:pageBlock >
    <apex:pageMessages />
    <apex:pageBlockSection >
    <apex:detail />
        <apex:inputField value="{! Request__c.First_Name__c}" />
        <apex:inputField value="{! Request__c.Last_Name__c}"/>
        <apex:inputField value="{! Request__c.Email_Address__c}"/>
        <apex:inputField value="{! Request__c.Cost_Center__c}"/>
        <apex:inputField value="{! Request__c.Department__c}"/>
        <apex:inputField value="{! Request__c.Director_s_Email__c}"/>
        <apex:inputField value="{! Request__c.Director_s_First_Name__c}"/>
        <apex:inputField value="{! Request__c.Director_s_Last_Name__c}"/>
        <apex:inputField value="{! Request__c.Mailstop__c}"/>
        <apex:inputField value="{! Request__c.Phone_Number__c}"/>

    </apex:pageBlockSection>
    </apex:PageBlock>       
        <apex:commandButton action="{! save}" value="Save"/>
       
    </apex:form>
</apex:page>

 

Controller Extension

public class MyPageController {
Request__c request;
private ApexPages.StandardController controller;
public MyPageController(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference save() {
insert request;
PageReference requestPage = Page.Congratulations;
requestPage.setRedirect(true);
return requestPage;

}

  • April 12, 2011
  • Like
  • 0