apex-code

apex scheduler- what if scenarios?

烈酒焚心 提交于 2019-12-12 05:29:55
问题 I'm looking into using apex scheduler to run a batch job. We can run it whenever we want, say 3 am when traffic is low, but I'm trying to anticipate some 'Oh-Crap' Scenarios. Can you guys help answer these questions for me? Setup: When the user modifies a territory 100k's of records can get updated. Questions: What are some scenarios that can realistically cause my jobs to not terminate? I thought of a scenario of- when a user is editing a contact which happens to be in one of the batches is

Salesforce Apex: test that callout hasn't been made

二次信任 提交于 2019-12-12 05:13:12
问题 I want to write a unit test that checks that callout hasn't been made from the trigger. I know how to test if the callout is made correctly - by implementing HttpCalloutMock: global class MyHttpCalloutMock implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req) { //test HTTPRequest here } } But if no HTTP request is made, then the respond() method won't be called. So this approach doesn't test if the request was made at all. I need something like this: HTTPRequest

Apex Class Controller Random Contact Records

删除回忆录丶 提交于 2019-12-12 02:53:21
问题 I am looking on selecting a small group of random contacts from a specific view. The records are in that view if their campaign status is set to sent. I have created an apex class that I think would work, however I am trying make this class a controller and build a visual force page. I am knew to salesforce and apex. After doing some research i think i will have to use getters and setters to call the information. My apex class is public class MyController { Integer count = [SELECT COUNT()

automate creating communities user

时间秒杀一切 提交于 2019-12-11 17:55:55
问题 Would it be possible to automate the process of creating a communities user in Salesforce? I was thinking of a trigger on the contact that would then create the user record with the communities license. Would this be possible at all? Thanks. 回答1: Yes it should be something like this Contact con = [select id,email,firstName,lastname,accountId from Contact where Id =:contactId]; Database.DMLOptions dmo = new Database.DMLOptions(); dmo.EmailHeader.triggerUserEmail = false; dmo.EmailHeader

EXCEEDED_ID_LIMIT: emptyRecycleBin id limit reached: 200

只谈情不闲聊 提交于 2019-12-11 17:14:53
问题 I'm just wondering if anyone else has seen this and if so, can you confirm that this is correct? The documentation claims, as you might expect, that 10,000 is the record limit for the system call: Database.emptyRecycleBin(records); not 200. Yet it's throwing an error at 200. The only thing I can think of is that this call occurs from within a batch Apex process. 回答1: This is the only reference that I could find to there being a limit of 200 on emptyrecyclebin(), I dare say that you are

Cannot get values of <apex:selectRadio> when inside <apex:repeat>

丶灬走出姿态 提交于 2019-12-11 14:19:45
问题 When I setup a visualforce page with a <apex:selectRadio> that is inside a repeat, I cant seem to get the selected value back into the controller. If I move it out of the repeat, it works fine. Any ideas? Controller: public with sharing class COPE_TestsExt { public id tid {get;set;} public boolean showTestSelect {get;set;} public list<COPE_Tests__c> tests {get;set;} public list<COPE_questions__c> questions {get;set;} public list<List<SelectOption>> options {get;set;} public COPE_results__c

Regexp to match members declaration of Java source files

£可爱£侵袭症+ 提交于 2019-12-11 09:48:36
问题 In a Javalike language where parsers and other advanced methods do not exist I want to parse and evaluate source files. It's the language Apex from the proprietary cloud platform Salesforce.com. I know its based on Antrl/Java but there is no way to parse it from inside the platform as I want to parse Apex code with Apex code and the only means is Regexp. When reading in a source file I want (by using a regexp) to match and extract all parts that are interesting to draw an UML class diagram:

How to sort list items for Date field value (Apex, Salesforce)

前提是你 提交于 2019-12-11 06:45:16
问题 With Salesforce's Apex, is there any way to sort list items, for Date field value. Please refer the TODO section of the following code, thanks. /** * Select list of jobOccurrences belongs to particular list of jobs */ private List<Job_Occurrence__c> getJobsByJobCode(List<Job__c> jobList) { // Select relevant Job Occurrence objects List<Job_Occurrence__c> jobOccuList = new List<Job_Occurrence__c>(); for (Job__c job : jobList) { Job_Occurrence__c jobOccurrence = [SELECT Id, Job__c, Schedule

Removing None Option in PickList visualforce apex

不想你离开。 提交于 2019-12-11 03:54:32
问题 i have created an object with name PS_Detail__c .in this custom object i created a custom field .in this picklist i defined two values Dollar ,Unit . when i go to P/S Detail Tab for creating a new PS_Detail__c object then i get None also as a value in picklist field .i want only Dollar and Unit as Picklist values .some one please help how to remove this None from Picklist !! 回答1: As you have discovered, you cannot make this picklist required at the object level. However, making this field

How invoke APEX method from custom button

青春壹個敷衍的年華 提交于 2019-12-11 03:29:23
问题 I have add custom button for salesforce's Sales application's 'Opportunities' tab. Once press that button I want to navigate some new tab (I have done it by adding proper URL) and execute following Apex method. How can execute this method. Thanks. public class JobService { private JobDao job_dao = new JobDao(); public void insertJob() { Job__c newJob = new Job__c(); job_dao.insertJob(newJob); } } 回答1: I have accomplished this task as following way, Add following java script codes to, custom