-1
@isTest
static void test_getBankDetailsFinnone(){
           
    Bank_Detail__c bankDetails = [Select Id from Bank_Detail__c limit 1];
    Set<ID> bd = new Set<ID>();
    bd.add(bankDetails);
    CF_UW_DataProvider.getBankDetailsFinnone(bd);
           
}

I wish to store Id from object Bank_Detail__c in set bd and then call a method getBankDetailsFinnone which takes argument as a set of type id. I am getting errors with it. Can someone please help me?

1
  • What errors are you getting? Will be helpful if you mention that too.
    – Night Guy
    May 24 '21 at 6:16
1

Simply, Change this line

bd.add(bankDetails);

to

bd.add(bankDetails.Id);
1

You can do this in one statement

CF_UW_DataProvider.getBankDetailsFinnone(new Map<Id,Bank_Detail__c> (
     [SELECT Id FROM Bank_Detail__c]).keySet());
0

Try below:

Bank_Detail__c bankDetails = [Select Id from Bank_Detail__c limit 1];
    
Set<ID> bd = new Set<ID>();
bd.add(bankDetails.Id);
CF_UW_DataProvider.getBankDetailsFinnone(bd);
0

The error in your code is because you are trying to reference an object of "Bank_Detail__c" to a set of type Id. In the code block please make the following changes in your code:

Bank_Detail__c bankDetails = [Select Id from Bank_Detail__c limit 1];
Set<ID> bd = new Set<ID>();
bd.add(bankDetails.Id);
CF_UW_DataProvider.getBankDetailsFinnone(bd);

Hope this explanation will resolve your query.

Thanks

Akshay

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.