Skip to main content

SOQL - Examples



ProcessInstance





Get list of Processess for Object

SELECT Id,Status,SubmittedById,TargetObjectId FROM ProcessInstance where Status = 'Pending' and TargetObjectId = 'a1m14000002gvWG'

SELECT Id, CompletedDate, ElapsedTimeInDays, ElapsedTimeInHours, ElapsedTimeInMinutes, LastActorId, ProcessDefinitionId, Status, TargetObjectId FROM ProcessInstance WHERE id =:result.instanceId]

ProcessInstanceWorkItem

select Id from ProcessInstanceWorkitem where ProcessInstanceId = '04gW0000000X2Y1IAK'








SELECT Description, Id FROM ProcessDefinition

Scheduled Jobs


SELECT Id, Status, ApexClass.Name, CreatedBy.Name, CreatedDate,CompletedDate FROM AsyncApexJob  where ApexClass.Name = 'ScheduleSalesTargets' Order by CompletedDate

CronTrigger and CronJobDetail objects

SELECT Id, CronJobDetail.Name, NextFireTime, PreviousFireTime, State, StartTime, EndTime, CronExpression, TimeZoneSidKey, OwnerId, LastModifiedById, CreatedById, CreatedDate, TimesTriggered FROM CronTrigger order by CreatedDate desc

SELECT TimesTriggered, NextFireTime FROM CronTrigger WHERE Id = :jobID
SELECT TimesTriggered, NextFireTime FROM CronTrigger WHERE Id = :sc.getTriggerId()
SELECT Id, CronJobDetail.Id, CronJobDetail.Name, CronJobDetail.JobType FROM CronTrigger ORDER BY CreatedDate DESC LIMIT 1

To obtain the total count of all Apex scheduled jobs, excluding all other scheduled job types, perform the following query. Note the value '7' is specified for the job type, which corresponds to the scheduled Apex job type.


SELECT COUNT() FROM CronTrigger WHERE CronJobDetail.JobType = '7'

Comments

Popular posts from this blog

Product Evaluation - MuleSoft Anypoint Platform one day workshop

People, Business Executives, Enterprise Architects, Solution/System/Application Architects, Tech Leads, Developers,  who are looking for and want to know more about MuleSoft Integration offering which is compared to other key providers like Software AG WebMethods, Oracle SOA Suite, WSO2, Informatica, etc. Recently I attended a one day Workshop on MuleSoft Anypoint platform . The overall goal of this workshop was to evaluate MuleSoft integration technology offering for a mid-size integration environment which is currently supported through Software AG WebMethods and Oracle SOA Suite. So, if you are in process of evaluating MuleSoft Anypoint Platform for your integration needs, this write up will give you a good high level executive summary overview. MuleSoft Product Offering falls under following category of market offering: iPaaS (Integration Platform as a Service) Hybrid Integration On-Premise Integration Platform Internet of Things (#IOT) Integration ...

Salesforce - Scheduling a Schedule Job

Following are the different ways to schedule a Schedule Job through a script. Run the given code in Execute Anonymous window and then you could see in Setting -> 'Scheduled Job' that your Job is waiting to be executed. Run a Schedule Job NOW Method - 1 ScheduleSalesTargets c = new ScheduleSalesTargets(); c.execute(null); Method - 2  (This one I prefer, whenever I need to run a job) Check the current Time. If it is, let's say 10:39 AM, in your clock, then set the minute to 41. This will schedule the job for 10:41 AM just two minutes from now. But, if you set minute value to 38, then it will schedule to next hour 11:38 AM ScheduleSales c = new ScheduleSales(); String sch = '0 0 * * * ?'; System.schedule('Sales Job Name - 1',  '0 41 * * * ?', c); You could repeat following, so that job keeps running every 5 minutes while you debug and change the Apex code behind the scene. ScheduleSales c = new ScheduleSales(); String sch = ...

Salesforce Code and Configuration Deployment

Following are a varied list of ways through which Code or Configuration could be deployed in Salesforce Server. It is assumed that deployment focus would be on Production instance, but it is true with Developer Edition and Sandbox instances as well. Technical Prerequisites for a Salesforce Deployment There are some tools and software that must be installed and properly configured on the Release Manager’s machine in order to enable the Deployment Process described in this guide. Some other tools are not required but we recommend using them. Here is a quick description of these tools. Tool Required / Optional Purpose Comment Eclipse Optional Eclipse is a developer tool that supports several languages. The currently recommended version of Eclipse to download is Eclipse Kepler 4.3 (the “Eclipse for Java developers” version is recommended) and can be downloaded from http://www.eclipse.org/downloads/pac...