You need to sign in to do that
Don't have an account?
rajubalaji
how to write a soql query for the parameter variable
Hi all,
please find the below code for reference my case was i dont want to get the user from user table.i need to get the users from the parameter variable called as alluser.anyone please tell me the soql query for how to write a query for parameter variable class.
Public Static List<String> GetUserListForTaskAssignmentNew(List<String> allUser){
List<String> UserId = new List<String>();
List<User> assignUserList=new List<User>();
String User = null;
List<AggregateResult> TaskCount = [SELECT ownerId, count(Type) from Task where createdDate<=Today and GroupId In (select id from alluser where id=:ownerId) group By ownerID];
{
if(allUser.size() > 0)
{
}
}
return UserId;
}
}
Thank You in advance.
please find the below code for reference my case was i dont want to get the user from user table.i need to get the users from the parameter variable called as alluser.anyone please tell me the soql query for how to write a query for parameter variable class.
Public Static List<String> GetUserListForTaskAssignmentNew(List<String> allUser){
List<String> UserId = new List<String>();
List<User> assignUserList=new List<User>();
String User = null;
List<AggregateResult> TaskCount = [SELECT ownerId, count(Type) from Task where createdDate<=Today and GroupId In (select id from alluser where id=:ownerId) group By ownerID];
{
if(allUser.size() > 0)
{
}
}
return UserId;
}
}
Thank You in advance.
Now i got to know what is your requirement.
please look at my sample code below
public class EventsDelete {
@InvocableMethod
public static void deleteEvents(List<Id> opportunityIds) {
List<Event> events = [SELECT id from Event where whatId IN:opportunityIds ];
delete events;
}
}
here I am doing almost similar thing
All Answers
hi balaji,
i assume that you want your soql in this way
String myTestString = 'TestName';
List<sObject> sobjList = Database.query('SELECT Id FROM MyCustomObject__c WHERE Name = :myTestString');
Now i got to know what is your requirement.
please look at my sample code below
public class EventsDelete {
@InvocableMethod
public static void deleteEvents(List<Id> opportunityIds) {
List<Event> events = [SELECT id from Event where whatId IN:opportunityIds ];
delete events;
}
}
here I am doing almost similar thing
By Using one query.
select ownerId, Count(type) from task where CreatedDate<=Today and ownerId In(Select Id from user where allUser='+OwnerId+') group By ownerId
But i am getting below please chck and reply me for futher process.
[object Object]: ownerId In(Select Id from user where allUser='+OwnerId+') group By ownerId ^ ERROR at Row:1:Column:105 No such column 'allUser' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
alluser is a parameter which is a input type and it's data is coming. so you can not use like that as it is not a field in user object. rather you can have ownerId IN: allUser.
By your guideline i have follow the same thing but i am getting below error.
Unknown error parsing query
select ownerId, Count(type) from task where CreatedDate<=Today and OwnerId In(Select Id from user where OwnerId In:'+allUser+') Group By owner Id
hi balaji,
you dont have to use + sign and niether the ' ' . you simply have to write
select ownerId, Count(type) from task where CreatedDate<=Today and OwnerId In(Select Id from user where OwnerId IN:allUser) Group By owner Id. This query will not work in query editor as allUser cant be determined in that.
thanks