You need to sign in to do that
Don't have an account?
anil Kumar
Custom Label value not working in SOQL Query
Hi All,
I am trying to use custom label value in SOQL Query. Query is not accepting custom label value. it is expecting number.
Integer num_days = Integer.valueOf(System.Label.Num_of_Days);
Select id, name FROM contact WHERE LastModifiedDate >= LAST_N_DAYS :num_days
Thanks,
Anil Kumar
I am trying to use custom label value in SOQL Query. Query is not accepting custom label value. it is expecting number.
Integer num_days = Integer.valueOf(System.Label.Num_of_Days);
Select id, name FROM contact WHERE LastModifiedDate >= LAST_N_DAYS :num_days
Thanks,
Anil Kumar
You'll need dynamic SOQL to make it work.
See similar post in the context of date field: https://salesforce.stackexchange.com/questions/195205/how-to-use-custom-label-inside-soql-query-for-date-value. You need to customize for number as per your requirement
Related: https://developer.salesforce.com/forums/?id=906F0000000BWNnIAO
If this information helps, please mark the answer as best. Thank you
All Answers
You'll need dynamic SOQL to make it work.
See similar post in the context of date field: https://salesforce.stackexchange.com/questions/195205/how-to-use-custom-label-inside-soql-query-for-date-value. You need to customize for number as per your requirement
Related: https://developer.salesforce.com/forums/?id=906F0000000BWNnIAO
If this information helps, please mark the answer as best. Thank you
Thank you for the responce,,,dynamic SOQL worked for me.
Integer num_days = Integer.valueOf(System.Label.Num_of_Days);
string Query='Select id, name FROM contact WHERE LastModifiedDate >= LAST_N_DAYS :'+num_days;
system.debug('Query...'+Query);
Thanks,
Anil Kumar