You need to sign in to do that
Don't have an account?
GYAN ANDRUS
Decimal total_amt = 0.0;
Base_live_funded_amount__c obj1 = Base_live_funded_amount__c.getInstance('Base_Live_Amount_funded_so_far__c');
for (Account obj : [select id,Total_Amount_Funded__c, ( Select Id,name,peer__Amount_Funded__c from peer__Loan_Application__r where status__c =' Funded' AND peer__Amount_Funded__c!=NULL) from Account Where Type='Borrower'])
{
for(peer__Loan_Application__c temp : obj.peer__Loan_Application__r)
{
total_amt = total_amt + temp.peer__Amount_Funded__c;
if( total_amt != null && total_amt >0)
{
total_amt +=obj1.Base_Live_Amount_funded_so_far__c+total_amt;
total_amt = obj1.Base_Live_Amount_funded_so_far__c ;
system.debug('TTTTTTTTTTTTTTTTTTTTTTT -----------:'+total_amt);
}
}
}
Please help for this code,Total value is not calculating
Decimal total_amt = 0.0;
Base_live_funded_amount__c obj1 = Base_live_funded_amount__c.getInstance('Base_Live_Amount_funded_so_far__c');
for (Account obj : [select id,Total_Amount_Funded__c, ( Select Id,name,peer__Amount_Funded__c from peer__Loan_Application__r where status__c =' Funded' AND peer__Amount_Funded__c!=NULL) from Account Where Type='Borrower'])
{
for(peer__Loan_Application__c temp : obj.peer__Loan_Application__r)
{
total_amt = total_amt + temp.peer__Amount_Funded__c;
if( total_amt != null && total_amt >0)
{
total_amt +=obj1.Base_Live_Amount_funded_so_far__c+total_amt;
total_amt = obj1.Base_Live_Amount_funded_so_far__c ;
system.debug('TTTTTTTTTTTTTTTTTTTTTTT -----------:'+total_amt);
}
}
}
Please give a try to my code also, It would work for sure and don't forget to mark it as best answer.
All Answers
Can you let me know what exactly you want to do, you just want to do the sum of all peer__Amount_Funded__c realted to accounts right ?
I mean Account is parent and peer__Loan_Application__c is child and peer__Amount_Funded__c is on child and you just wamt to some all teh amount related to one account and you want to show on parent right ?
Please confirm so I can help you out ..
Thanks
I need to add all the values of peer_amount_funded__c and save it to total_amt variable.After adding all the values i want to add Base_value__c in total_amt variable.
And i have created the custom field in custom Setting Base_value__c.no need of parent child value only in
peer__Loan_Application__c
Please help me
Map<Id, Decimal> mapAccIdToDecimal = new Map<Id, Decimal>();
In below code you have not stored the sum in map so every time it will be reset ...so you need to create a mapo and then you can store the sum in that map for each account. also we can optimise the code as per your need. I just share the code using map where you can store teh values against each account and then you can get the value for each our from map and use as you want if you want to populate them in account field that also you can do.
Please refer the given code and let me know if that helps you.
Thanks,
Sandeep
In below code just replace the field name of account on peer__Loan_Application__c. then it will do the job for you.
In above code I am directly querying on peer__Loan_Application__c where status is Funded and its parent type is borrower.
Then I am framing a map where I am storing sum of all peer__Amount_Funded__c as per the account . Please use and let me knwo if that helps you.
Thanks
Sandeep
Thanks
Map<Id, Decimal> mapAccIdToDecimal = new Map<Id, Decimal>();
Decimal total_amt = 0.0;
Base_live_funded_amount__c obj1 = Base_live_funded_amount__c.getInstance('Base_Live_Amount_funded_so_far__c');
for (Account obj : [select id,Total_Amount_Funded__c, ( Select Id,name,peer__Amount_Funded__c from peer__Loan_Application__r where status__c =' Funded' AND peer__Amount_Funded__c!=NULL) from Account Where Type='Borrower'])
{
for(peer__Loan_Application__c temp : obj.peer__Loan_Application__r)
{
total_amt = total_amt + temp.peer__Amount_Funded__c;
if( total_amt != null && total_amt >0)
{
total_amt +=obj1.Base_Live_Amount_funded_so_far__c+total_amt;
total_amt = obj1.Base_Live_Amount_funded_so_far__c ;
system.debug('TTTTTTTTTTTTTTTTTTTTTTT -----------:'+total_amt);
}
mapAccIdToDecimal.put(obj.Id, total_amt);
system.debug('Final value ---------:'+mapAccIdToDecimal);
}
}
Please use and let me know if that does the job for you.
currently the code whichyou shared is putting values everytime and it will bve overiiden and last child value will be there so it is not proper..
you can keep that outide for loop if you want to use same code.
you just want to add base amount in peer__Amount_Funded__c ?
like if you have 5peer__Loan_Application__c where status is funded now tell me what you want ?
peer__Loan_Application__c obj1 ----peer__Amount_Funded__c is 100
peer__Loan_Application__c obj2 ----peer__Amount_Funded__c is 500
peer__Loan_Application__c obj3 ----peer__Amount_Funded__c is 400
peer__Loan_Application__c obj4 ----peer__Amount_Funded__c is 300
peer__Loan_Application__c obj5 ----peer__Amount_Funded__c is 200
and base amount from custom setting is 100..now tell me what you want so I can help you out.
Thanks
Base_live_funded_amount__c value= 500
total_amt = 2000
then this much code will work for this case. Please check and let me kbow if that helps.
Thanks
remove that blank check as its decimal you can do if that value is 0 or not like that
Use below code:
Let me know now if that logic works for you.
Thanks
Please give a try to my code also, It would work for sure and don't forget to mark it as best answer.