• Matt Scholl 10
  • NEWBIE
  • 8 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
I am trying to reuse a piece of code I've used many times before. The code schedules a batch class from another Apex class. When I try to edit it in Developer Console or an IDE, I get the following error: "Method does not exist or incorrect signature: void scheduleBatch(testBatch, String, Decimal) from the type System". testBatch IS a batchable class. Why is the compiler pulling the NAME of the batchable class into the method?

Here is my code:
Apex class:
public class testClass {
    public static void testSchedule() {
        testBatch batchable = new testBatch();
        String jobName = 'testBatch';
        Decimal minutesFromNow = 0.0;

        try {
            String cronId = System.scheduleBatch(batchable, jobName, minutesFromNow);
            CronTrigger ct = [SELECT Id, NextFireTime FROM CronTrigger WHERE Id = :cronID];
            System.debug(jobName + ' jobId: ' + cronID);
            System.debug(jobName + ' next fire time: ' + ct.NextFireTime);
        } catch (Exception e) {
            System.debug('Error scheduling batch: '+e.getMessage());
        }
    }
}

Here is the batch class:
global class testBatch implements Database.Batchable<sObject> {
    private static String query;

    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope){
    }

    global void finish(Database.BatchableContext BC){
    }
}
Thanks in advance!
Hi Everyone,
I have an Apex class that records the datetime certain fields change. On one field, System.Datetime.now() returns a value that is 12 hours earlier than it should be.

Ex. If the user updates the field at 4:00 PM, the datestamp shows 4:00 AM. I have confirmed that he user's time zone and the org time zone are the same.

Here is my code. The middle line (Product_Link_Complete__c) is the one that returns the incorrect datetime. The lines work as expected.

            if (nq.Product_Complete__c != oq.Product_Complete__c) nq.Product_Completed_dt__c = System.Datetime.now();
            if (nq.Product_Link_Complete__c != oq.Product_Link_Complete__c) nq.Product_Link_Complete_dt__c = System.Datetime.now();
            if (nq.Product_Peer_Review_Complete__c != oq.Product_Peer_Review_Complete__c) nq.Product_Peer_Review_Complete_dt__c = System.Datetime.now();

Thoughts? TIA,
Matt
Hi All,
I have a lead trigger that automatically converts certain Leads. We recently added a Contact Duplicate Rule that causes a DmlException when one of Leads creates a duplicate Contact.
Here is my code:

List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
...
List<Database.LeadConvertResult> lcrList = Database.convertLead(leadConverts);

I have tried putting the Database.convertLead in a try/catch (DmlException de) block.
I have tried setting DMLOptions.DuplicateRuleHeader.allowSave = true.
I still can't seem to trap the error: FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATES_DETECTED, Use one of these records?: []
Two questions:
1. How can I trap the error?
2. How can I print the error message for each failed lead conversion in the list to the debug log? System.debug('Error: '+{what?})
Thanks in advance!
I have a custom javascript button that was working last week. Now it is not. Now I get a "missing ; before statement" error when the button is clicked. The code still passes the syntax check. Did something change with Winter 16 that broke the javascript?
I have tried adding a ; after the REQUIRESCRIPT line, but get the same result.​

User-added image

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}
if ('{!Opportunity.Agreements_Created__c}' == 0){
var r = confirm('Are you sure you want to request a contract?\n\nOnce a request is saved, a contract request will be submitted.');
if (r == true){
var URL = '/a2J/e?00N32000002Yv0Z={!Opportunity.Account} - Contract Request&CF00N32000002Yv0Y={!Opportunity.Account}&CF00N32000002Yv0Y_lkid={!Opportunity.AccountId}&CF00N32000002Yv0b={!Opportunity.Name}&CF00N32000002Yv0b_lkid={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}';
window.location.href = URL;
}
else{
setTimeout(function(){alert('Request cancelled.'); },1001);
}}
else{
setTimeout(function(){alert('A contract already exists for this Opportunity.'); },1001);
}
Hi All,
I have a lead trigger that automatically converts certain Leads. We recently added a Contact Duplicate Rule that causes a DmlException when one of Leads creates a duplicate Contact.
Here is my code:

List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
...
List<Database.LeadConvertResult> lcrList = Database.convertLead(leadConverts);

I have tried putting the Database.convertLead in a try/catch (DmlException de) block.
I have tried setting DMLOptions.DuplicateRuleHeader.allowSave = true.
I still can't seem to trap the error: FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATES_DETECTED, Use one of these records?: []
Two questions:
1. How can I trap the error?
2. How can I print the error message for each failed lead conversion in the list to the debug log? System.debug('Error: '+{what?})
Thanks in advance!
Challenge Not yet complete... here's what's wrong: 'Activate Temp Access Flow' lightning app page doesn't exist with the flow component called 'Accounts Temp Access'. Check the instructions.

Has anyone passed this challenge? I have passed all prior challenges. It seems pretty straightforward, I have my Lightning app page, activated it, added it to Sales...everything else is setup and has passed. 

User-added image