function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
StreepieStreepie 

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);
  }

}

Best Answer chosen by Admin (Salesforce Developers) 
aalbertaalbert

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

aalbertaalbert

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); } }

 

 

 

This was selected as the best answer
hector.asp2hector.asp2

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