+ Start a Discussion
Hiteshkumar Chaudhari 2Hiteshkumar Chaudhari 2 

fetch 15 digit record id to update perticular record

i like to update a perticular account number's balence in my bank application for that purpose i need to fetch 15 digit record id and i am unable to fetch it.. kindly help ..

Query
 Integer id  = [SELECT b1.Id FROM BankApplication__c WHERE b1.Account_Number__c =: accnum  ];

Error : 
Error: Compile Error: Didn't understand relationship 'b1' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 12 column 25
   
Best Answer chosen by Hiteshkumar Chaudhari 2
sandeep reddy 37sandeep reddy 37
first of all ids are not integers combain with character and numbers chouse as 
string id=[select id from bankapplication__c where account_number__c=:accnum];
this what you need to do
why beacuase you getting error 
IN soql you only search  with object field name only 




but you are trying to modify account balance so you do one thing 

bankapplication__c b=[select id,account_balance__c from bankapplication__c where account_number__c=:accnum];
b.account_balance__c=5000;
update b;
 

All Answers

sandeep reddy 37sandeep reddy 37
first of all ids are not integers combain with character and numbers chouse as 
string id=[select id from bankapplication__c where account_number__c=:accnum];
this what you need to do
why beacuase you getting error 
IN soql you only search  with object field name only 




but you are trying to modify account balance so you do one thing 

bankapplication__c b=[select id,account_balance__c from bankapplication__c where account_number__c=:accnum];
b.account_balance__c=5000;
update b;
 
This was selected as the best answer
Hiteshkumar Chaudhari 2Hiteshkumar Chaudhari 2
right sandeep.

thnx for the quick reply but after updating query when i try to update balence of my customer it gives error 

 "b1.Amount__c  = b1.Amount__c + Decimal.valueof(damount); "

 the above statement wont work for me
can you suggest something ...
Hiteshkumar Chaudhari 2Hiteshkumar Chaudhari 2
damount is the text field in the visualforce page 

 <h1>Account Holder Name</h1><apex:inputText id="dname" value="{!dname}"    />
Hiteshkumar Chaudhari 2Hiteshkumar Chaudhari 2
After clicking deposit button it gives error :

System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: BankApplication__c.Amount__c
Error is in expression '{!deposit}' in component <apex:commandButton> in page createaccount: Class.BankAppDemo.deposit: line 23, column 1
Class.BankAppDemo.deposit: line 23, column 1