You need to sign in to do that
Don't have an account?

Invalid bind expression type of SOBJECT
The SELECT line fails....?
what am i doing wrong?
the error says: Invalid bind expression type of SOBJECT:Account for column of type String op regel 13 kolom 75
trigger getRelatiecode on Opportunity (after insert) {
System.debug('Making future call to sfservice');
for (Opportunity opp : Trigger.New) {
//Call future method to update account
//with data from external server.
//This is a async calls, it returns right away, after
//enqueuing the request.
string UID=UserInfo.getUserId();
string UPW=UserInfo.getFirstName();
string MK = [SELECT MarktSelect_Sleutel__c FROM Account WHERE Name = :opp.Account];
integer MKR = integer.valueof(MK.MarktSelect_Sleutel__c);
//SFservice.sFservice(opp.id, UID, UPW, MKR);
}
}
The bind expression, opp.Account, in your code, refers to the Account SObject. Not the Account Name.
I refactored some of the code to show you how you need to query all the related Accounts, can store them in a Map for easy access, and then iterate across the Opportunities. I hope this helps.
trigger getRelatiecode on Opportunity (after insert) { System.debug('Making future call to sfservice'); List<id> accountIds = new List<Id>{}; String UID=UserInfo.getUserId(); String UPW=UserInfo.getFirstName(); for (Opportunity opp : Trigger.New) { if(opp.AccountId!=null) accountIds.add(opp.Account); } Map<Id,Account> accountMap = new Map<Id,Account>([select id,MarktSelect_Sleutel__c, name from account where Id IN :accountIds]); for(Opportunity opp: Trigger.new){ //Call future method to update account //with data from external server. //This is a async calls, it returns right away, after //enqueuing the request. //string MK = [SELECT MarktSelect_Sleutel__c FROM Account WHERE Name = :smileysurprised:pp.Account]; Account MK = accountMap.get(opp.AccountId); integer MKR = integer.valueof(MK.MarktSelect_Sleutel__c); //SFservice.sFservice(opp.id, UID, UPW, MKR); } }
All Answers
The bind expression, opp.Account, in your code, refers to the Account SObject. Not the Account Name.
I refactored some of the code to show you how you need to query all the related Accounts, can store them in a Map for easy access, and then iterate across the Opportunities. I hope this helps.
trigger getRelatiecode on Opportunity (after insert) { System.debug('Making future call to sfservice'); List<id> accountIds = new List<Id>{}; String UID=UserInfo.getUserId(); String UPW=UserInfo.getFirstName(); for (Opportunity opp : Trigger.New) { if(opp.AccountId!=null) accountIds.add(opp.Account); } Map<Id,Account> accountMap = new Map<Id,Account>([select id,MarktSelect_Sleutel__c, name from account where Id IN :accountIds]); for(Opportunity opp: Trigger.new){ //Call future method to update account //with data from external server. //This is a async calls, it returns right away, after //enqueuing the request. //string MK = [SELECT MarktSelect_Sleutel__c FROM Account WHERE Name = :smileysurprised:pp.Account]; Account MK = accountMap.get(opp.AccountId); integer MKR = integer.valueof(MK.MarktSelect_Sleutel__c); //SFservice.sFservice(opp.id, UID, UPW, MKR); } }
Hi
Any one have idea how to get this count value ?
integer abc1=integer.valueOf(Database.query('select COUNT() from case'));
system.Debug('test arun'+abc1);
er.arunthakur@gmail.com