You need to sign in to do that
Don't have an account?
SFDC16
How to use where clause for string variable in soql?
Hello,
I am not able to fetch the dashboard name based on the string variable.
Below highlighted code is not working.
List<User> userList=[Select id,BMCServiceDesk__Account_ID__c, BMCServiceDesk__Account__c from user where id=:userInfo.getUserId()];
System.debug('userList-------->'+userList); // return value
List<String> userAccount=new List<String>();
for(User u:userList)
{
userAccount.add(u.BMCServiceDesk__Account__c);
}
System.debug('User Account------->'+userAccount);
String sData = String.valueof(userAccount);
System.debug('String----->'+sData);//return Values
List<Dashboard> dash=[Select id,title From Dashboard where title=:sData];
if(dash.size()>0)
System.debug('Dashboard Name------>'+dash);//return null List<Dashboard> sobjList = Database.query('Select id,title From Dashboard where title IN:userAccount');
if(sobjList.size()>0)
System.debug('Dashboard---------------->'+sobjList); //return null
I am not able to fetch the dashboard name based on the string variable.
Below highlighted code is not working.
List<User> userList=[Select id,BMCServiceDesk__Account_ID__c, BMCServiceDesk__Account__c from user where id=:userInfo.getUserId()];
System.debug('userList-------->'+userList); // return value
List<String> userAccount=new List<String>();
for(User u:userList)
{
userAccount.add(u.BMCServiceDesk__Account__c);
}
System.debug('User Account------->'+userAccount);
String sData = String.valueof(userAccount);
System.debug('String----->'+sData);//return Values
List<Dashboard> dash=[Select id,title From Dashboard where title=:sData];
if(dash.size()>0)
System.debug('Dashboard Name------>'+dash);//return null List<Dashboard> sobjList = Database.query('Select id,title From Dashboard where title IN:userAccount');
if(sobjList.size()>0)
System.debug('Dashboard---------------->'+sobjList); //return null
Raj Vakati
Change it as below
SFDC16
still, it's not working.
log
22:19:40:030 USER_DEBUG [15]|DEBUG|----------->()
22:19:40:024 USER_DEBUG [13]|DEBUG|Dashboard Name------>()
Raj Vakati
Can you check two thinks ..
- What is the value in BMCServiceDesk__Account__c
- What this SOQL returning Select id,title From Dashboard
SFDC16
1. What is the value in BMCServiceDesk__Account__c------------>Account
Name (String)
2. What this SOQL returning Select id,title From Dashboard ----------->
Dashboard title(String)
Example :
Account Name: SWD Pvt Ltd.
Dashboard title: SWD Pvt Ltd.