Linked Questions

0
votes
3answers
1k views

Using a variable in dynamic sql [duplicate]

I have a set of IDs I wanted excluded from a Task query. I need to use dynamic sql for this. I try: Set <ID> unwantedIds = ... // ids I don't want. String query = 'select Id, ThirdPartyId__c, ...
0
votes
1answer
507 views

How to pass set<id> dynamically to soql [duplicate]

I have a dynamic Soql in which I want to pass a set. I get an error: System.QueryException: expecting a colon, found '{' Anonymous window Set<Id> idSet = new Set<Id> (); idSet.add('...
8
votes
2answers
28k views

use string array in IN clause in dynamic soql

I have an array of strings i'd like to use in the IN clause of a dynamic soql query. if i wasn't building the string at runtime i could simply use (from the SF docs): String[] ss = new String[]{'a', ...
26
votes
2answers
5k views

Bind variable with dotted name not working in dynamic SOQL

As mentioned in this answer, it's possible to use bind variables in dynamic SOQL queries. This seems like a great way to avoid SOQL-injection, and to build a query string once but use it multiple ...
5
votes
3answers
8k views

Dynamic SOQL How to bind date?

soql = 'select A__c,EmplId__c, B__c,Date__c from Transaction__c Where Transaction__c.name!=null'; if (!branch.equals('')) system.debug('test br1'); soql += ' and A__c LIKE \''+String....
3
votes
5answers
7k views

Dynamic SOQL variable binding not working for multiple records

Am building a dynamic SOQL where I am using a list of strings that represent record ids, here's an example similar to my class: String q = ''; q += 'SELECT Id FROM' + object; q += ' WHERE Id IN :...
2
votes
2answers
1k views

code coverage for batch apex

I wrote a batch apex,test class on user.and when running the test class it is failed and below is the batch class and test class on which i'm working Batch Class global class CaptureLastLoginDate ...
2
votes
1answer
1k views

dynamic soql for single picklist

I have a dynamic soql as below. string remainingbetquery ='select id,name,uw_Brand__r.Name,Market_Cluster__c,Product_Category_Sub_Division__c from uw_bet__c where (id not in :betfollowed) and (id not ...
1
vote
2answers
2k views

Pulling and Searching Opportunity Contact Roles from a list of multiple opportunities

I have a custom object with two custom connectors - one to opps and one to contacts in order to create many to many relationships to both. To summarize I am trying to be on the main object (Demo) and ...
1
vote
2answers
183 views

How to use DateLiteral in visualforce

Can anyone tell me how to use the Date Literal in apex? My use case is I want to use Date literal as a custom picklsit. I want to create custom picklist as follows Please someone tell me how can I ...