You need to sign in to do that
Don't have an account?
Sangeetha T
*CRITICAL* -- using variable in where condition "LIKE"
Hi All
I have a batch class as follows
I need to add a condition to the query like Inte__key__c like 'FYPlusOne%'
Intekey field value will be in the format of 2017|39238shdshdhkjsoskok. I have to fetch the records of the previous fiscal year so the inteley should contain 2017(Currentfiscalyear - 1)
Please help me how to achieve this in where condition. I have a declared a variable on top
Thanks
Sangeetha T
I have a batch class as follows
Integer FiscalYear = getCurrentFY(); Integer FYPlusOne = FiscalYear - 1; global database.querylocator start(Database.BatchableContext BC){ Integer lmt = Limits.getLimitQueryRows(); String query = 'Select Org_SFID__r.Fiscal_Year_SFID__c,fAccount_Brand_ID__c,Id,CFY_Dealer_Account_SFID__r.Brand_Group_Name__c,Integration_Key__c,'; query += 'Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c'; query += ' FROM Account_Org_Relationship__c'; query += ' WHERE Sales_Focus_Descr__c =\'Assigned\' and is_Active__c = True and fFiscal_Year__c = False and fAccount_Brand_Name__c =: National';
I need to add a condition to the query like Inte__key__c like 'FYPlusOne%'
Intekey field value will be in the format of 2017|39238shdshdhkjsoskok. I have to fetch the records of the previous fiscal year so the inteley should contain 2017(Currentfiscalyear - 1)
Please help me how to achieve this in where condition. I have a declared a variable on top
Thanks
Sangeetha T
Do the below:
Integer FiscalYear = getCurrentFY();
Integer FYPlusOne = FiscalYear - 1;
string yearCheck = FYPlusOne + '%' ;
global database.querylocator start(Database.BatchableContext BC){
Integer lmt = Limits.getLimitQueryRows();
String query = 'Select Org_SFID__r.Fiscal_Year_SFID__c,fAccount_Brand_ID__c,Id,CFY_Dealer_Account_SFID__r.Brand_Group_Name__c,Integration_Key__c,';
query += 'Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c';
query += ' FROM Account_Org_Relationship__c';
query += ' WHERE Sales_Focus_Descr__c =\'Assigned\' and is_Active__c = True and fFiscal_Year__c = False and fAccount_Brand_Name__c =: National and Inte__key__c like yearCheck ';
All Answers
Do the below:
Integer FiscalYear = getCurrentFY();
Integer FYPlusOne = FiscalYear - 1;
string yearCheck = FYPlusOne + '%' ;
global database.querylocator start(Database.BatchableContext BC){
Integer lmt = Limits.getLimitQueryRows();
String query = 'Select Org_SFID__r.Fiscal_Year_SFID__c,fAccount_Brand_ID__c,Id,CFY_Dealer_Account_SFID__r.Brand_Group_Name__c,Integration_Key__c,';
query += 'Org_SFID__c,Org_SFID__r.Fiscal_Year_SFID__r.Year__c,Sales_Focus_Descr__c';
query += ' FROM Account_Org_Relationship__c';
query += ' WHERE Sales_Focus_Descr__c =\'Assigned\' and is_Active__c = True and fFiscal_Year__c = False and fAccount_Brand_Name__c =: National and Inte__key__c like yearCheck ';
Thanks so much it worked
Can you please have a look at these --->>> https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005MaRQAU