You need to sign in to do that
Don't have an account?
ArchieTechie6
SOQL Query using IN Operator returns error : Invalid bind expression type of ProcessInstance for Id field of SObject
Hello All,
I want to fetch items which are pending approvals. For this, I am querying from ProcessInstance.
Once I get the Ids from ProcessInstance, I want to query fields from my object by passing these IDs.
Below is my code:
I want to fetch items which are pending approvals. For this, I am querying from ProcessInstance.
Once I get the Ids from ProcessInstance, I want to query fields from my object by passing these IDs.
Below is my code:
public List<ProcessInstance> draftKBIds {get;set;}
public List<Knowledge__kav> pendingArticles {get;set;}
//Below query returns expected results from ProcessInstance
draftKBIds = [select Id from ProcessInstance where TargetObjectId IN(select Id from Knowledge__KAV where PublishStatus='Draft')];
//Knowledge__KAV is the name of my Knowledge Base Object.
pendingArticles = [Select id, Title
from Knowledge__KAV where id IN: draftKBIds ];
The above highlighted query returns error:
Invalid bind expression type of ProcessInstance for Id field of SObject Knowledge__kav
Please suggest where I am going wrong.
public List<Knowledge__kav> pendingArticles {get;set;}
//Below query returns expected results from ProcessInstance
draftKBIds = [select Id from ProcessInstance where TargetObjectId IN(select Id from Knowledge__KAV where PublishStatus='Draft')];
//Knowledge__KAV is the name of my Knowledge Base Object.
pendingArticles = [Select id, Title
from Knowledge__KAV where id IN: draftKBIds ];
The above highlighted query returns error:
Invalid bind expression type of ProcessInstance for Id field of SObject Knowledge__kav
Please suggest where I am going wrong.
pendingArticles = [Select id, Title from Knowledge__KAV where id IN=: draftKBIds ];
Thank you
PSM
Compile Error: line 39:60 no viable alternative at character '' at line 39 column 60
Please help! Thank you!
Thank you
PSM
Invalid bind expression type of ProcessInstance for Id field of SObject Knowledge__kav ==> This is error in the where condition below is why.
draftKBIds = [select Id from ProcessInstance where TargetObjectId IN(select Id from Knowledge__KAV where PublishStatus='Draft')];
The above query holds id's of ProcessInstance and not the Knowledge__KAV. That's the reason why in the second query its not recognisizng.
pendingArticles = [Select id, Title from Knowledge__KAV where id IN: draftKBIds ]; Here we will have to pass the Knowledge__KAV ID'S.
Thank you
PSM
public List<ProcessInstance> draftKBIds {get;set;}
public List<Knowledge__kav> pendingArticles {get;set;}
If I dont give public List<ProcessInstance> draftKBIds for draftKBIds, that particular SOQL query goes wrong.
Please suggest here ---