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
Malik ButlerMalik Butler 

Multiplying field values in vf page

I'm trying to create a vf page that will allow me to calculate two fields. Basically I need the quantity multiplied by the typical time to install(custom field), to get the Total Estimated Install time(custom field). I'm stumped as to if I can do it with apex code or if I should try to use html or css.
Best Answer chosen by Malik Butler
Ajay K DubediAjay K Dubedi
Hi Malik,
Of course, you can do this in Apex. You just need to query and store your  'quantity' and  'typical time to install' in the proper lists(or list if both are fields of the same object).  After this you'll be needing a for-each loop on list/lists, multiply them and store it in  a variable.
for(Object inst : list1){ //considering single object
    integer save = inst.Quantity * inst.typical time to install
    integerList.add(save);
}
return integerList
Now take this list to vf page and display it using simple pageblock and pageblocktable tags.
 
I hope you find the solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi

All Answers

Ajay K DubediAjay K Dubedi
Hi Malik,
Of course, you can do this in Apex. You just need to query and store your  'quantity' and  'typical time to install' in the proper lists(or list if both are fields of the same object).  After this you'll be needing a for-each loop on list/lists, multiply them and store it in  a variable.
for(Object inst : list1){ //considering single object
    integer save = inst.Quantity * inst.typical time to install
    integerList.add(save);
}
return integerList
Now take this list to vf page and display it using simple pageblock and pageblocktable tags.
 
I hope you find the solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
This was selected as the best answer
Malik ButlerMalik Butler
Hi Ajay,
Thanks for the response. That makes total sense! I was able to set this up and got what I needed completed. Thanks so much for your help!