Sorry for being Inactive from a long :).
Actually these days I am looking for that what is not possible in salesforce and what can be the work around for that.
So be ready I am going to post some interesting things in coming days :).
Are you ready to get the first one, so let's start
I have an object named "Filed Comparision" with fields "Start Date" and "End Date".
Now picture starts from here :
My requirement is to get all the records from the "Field Comparison" having End Date greater then Start Date.
So my query should be something like :
but unfortunately, due to some salesforce restriction we can not do field comparison in where clause.This throws an exception "Compile Error: line 1, column 98: unexpected token: 'Start_Date__c'".
Then what should be done? do we need to fetch all the records and do the coding stuffs for getting the results?
Absolutely not.
We can create a formula field with criteria :
Guess, Formula field name is "Is Active". After introducing this field, records will be looks like :
I hope , now you got the idea what I am going to do to get the valid records only :D.
So, to get all the valid records SOQL query can be :
Ohh..........It's completed. forgive me for getting you bored :P.
Please comments for making it for meaningful and more helpful.
Actually these days I am looking for that what is not possible in salesforce and what can be the work around for that.
So be ready I am going to post some interesting things in coming days :).
Are you ready to get the first one, so let's start
I have an object named "Filed Comparision" with fields "Start Date" and "End Date".
Now picture starts from here :
My requirement is to get all the records from the "Field Comparison" having End Date greater then Start Date.
So my query should be something like :
List<Field_Comparison__c> listResults = [Select Name from Field_Comparison__c where End_date__c > Start_Date__c];
but unfortunately, due to some salesforce restriction we can not do field comparison in where clause.This throws an exception "Compile Error: line 1, column 98: unexpected token: 'Start_Date__c'".
Then what should be done? do we need to fetch all the records and do the coding stuffs for getting the results?
Absolutely not.
We can create a formula field with criteria :
IF(End_Date__c > Start_Date__c , 'true', 'false')
Guess, Formula field name is "Is Active". After introducing this field, records will be looks like :
I hope , now you got the idea what I am going to do to get the valid records only :D.
So, to get all the valid records SOQL query can be :
List<Field_Comparison__c> listResults = [Select Name from Field_Comparison__c where Is_Active__c = 'true'];
Ohh..........It's completed. forgive me for getting you bored :P.
Please comments for making it for meaningful and more helpful.
I'm still shocked SOQL doesn't support field-to-field comparisons. Thanks for the good hack.
ReplyDeleteyour trick helped me. Genius !
ReplyDeleteAlways happy to help :).
ReplyDeletewe have a scenario where we are going to compare two profiles nad give error message. Eg: If role1 and role2 is present in two different fields (like role and delegate role) then error message display. Please help on this asap.
DeleteThanks for this blog
ReplyDeleteThanks a lots sir, really helpful...
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis blog is really remarkable. Thanks for sharing this great stuff. Keep sharing more useful and conspicuous stuff like this. Thank you so much.
ReplyDeletecompare currency
This is really helpful. Thanks sir. You are rock...
ReplyDeleteNice one! it is amazing how there is always a workaround in Salesforce when some functions are not available straight away like in this case, using formula to cover the lack of comparision in SOQL. Thanks for the tip!
ReplyDeleteThanks for sharing such great information. It really helped me. I always search to read the quality content and finallyfound this in your post. keep it up!
ReplyDeletearchitect in agra
Uşak
ReplyDeleteAnkara
Adıyaman
Hatay
Şırnak
X44GX
yalova
ReplyDeleteyozgat
elazığ
van
sakarya
0E7T5
13FB5
ReplyDeletePursaklar Fayans Ustası
Isparta Lojistik
Çerkezköy Fayans Ustası
Giresun Şehir İçi Nakliyat
Manisa Şehirler Arası Nakliyat
Çerkezköy Evden Eve Nakliyat
Isparta Şehirler Arası Nakliyat
Kayseri Lojistik
Eskişehir Şehir İçi Nakliyat
E1C8E
ReplyDeleteBatman Şehir İçi Nakliyat
Ünye Fayans Ustası
Balıkesir Parça Eşya Taşıma
Tokat Parça Eşya Taşıma
Antalya Şehir İçi Nakliyat
Çerkezköy Oto Lastik
İzmir Şehirler Arası Nakliyat
Altındağ Parke Ustası
Çerkezköy Buzdolabı Tamircisi
12D6C
ReplyDeletecanli sohbet
muğla bedava sohbet siteleri
malatya canli sohbet bedava
samsun canlı görüntülü sohbet siteleri
karabük parasız sohbet
van mobil sohbet bedava
Ardahan Sesli Sohbet Siteler
canli sohbet bedava
karabük sohbet chat
17B7B
ReplyDeletedefillama
pancakeswap
dappradar
satoshivm
yearn finance
poocoin
pudgy penguins
dexview
quickswap