You need to sign in to do that
Don't have an account?
SFDC Coder 8
Access SOQL query from Custom Settings
Hi All,
I am new to Salesfroce.
I have written a batch apex to delete data from custom object.
Now, my requirement is to get that data from custom settings.
How to create that custom setting and what changes I have to do my below batch apex
Please help me
Thanks in Advance!!
I am new to Salesfroce.
I have written a batch apex to delete data from custom object.
Now, my requirement is to get that data from custom settings.
How to create that custom setting and what changes I have to do my below batch apex
global class batchDelete implements Database.Batchable<sobject> { global Database.QueryLocator start(Database.BatchableContext BC){ return Database.getQueryLocator([SELECT Id,CreatedDate FROM Obj1__c WHERE createdDate = yesterday]); } global void execute(Database.BatchableContext BC,List<Obj1__c> rec){ //some code delete rec; } global void finish(Database.BatchableContext BC){ } }
Please help me
Thanks in Advance!!
You csn simply restore your daata from Recyclebin.
Thanks
Thank you for your reply
Please explain little bit, How to do?
click on Home -> Recycle bin -> Select your data which you want to restore -> Undelete
Thanks
I do not want this.
You can see SOQL query in my code. (Where CreatedDate=Yesterday)
There in where condition instead of Yesterday, I want to get that data from Custom settings .
What change I need to there
whatever you have deleted ether using SOQL query that goes to Recycle Bin. You can get that in Recycle Bin.
I am assuming that your requirement is to make createdDate field criteria as configurable in the SOQL query like (Yesterday, Today, Last_week etc) . For this create a custom setting and a custom field to store the value. Once Custom setting is created.
Click on Manage button available in the custom setting detail screen, there you can create records, Here Name is unique field and the custom field which you created is to store the value.
In the code you have to get the value w.r.t Name by using the custom setting methods. Follow this link (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_custom_settings.htm%23apex_System_ListCustomSetting_instance_methods).
for eg : Assume your custom setting api name is : Foundation_Countries__c and the custom field api name is Criteria__c .
and you have created a custom setting record with Name field populated with "DateCriteria"
To get that particular record values follow below syntax: Hop this will help.
Thanks
Satya.