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
chriscwharrischriscwharris 

On the fly calculations

I have a scenario where I want to have a calculation performed on and object on the front end iusing values from multiple other objects. Let me explain the scenario and I would apprecaite any pointers.

Object 1 contains some "totals"
Object 2 contains some "static numbers"

Object 3 is the working form where I want the following process if possible:

- on load, get the totals from Object 1 and display them at the top of the form
- on load get the static numbers for use in the calculation but ideally do not have them visibile
- User enters additional values
- Calculation adds new values to total from object 1 and the static numbers from object 2
- If number do not exceed threshold allow the save and then update the total on object 1 to the new total from object 3

Now I had been building this app in declarative only but I'm now wondering if this part will need to be a VF page. I assume to get the values from object 1 and 2 to use on object 3 they all need to be "related" via a master-detail or lookup. Would you do the entire page as VF or would you do parts of it in VF and embed in page layout?

I assume to update object 1 then I could either use a master-detail and a rollup field? But can I reference the rollup field cross object? If not then I guess a trigger could be used to update the object 1 with the object 3 total on save?

Appreciate any thoughts. Thanks

 
Vishal_GuptaVishal_Gupta
Hi Chriscwharris,

Hope you are doing good.

We need to create a seprate VF page to implement above requirement. Embeded Vf page in layout does not work at time of creation or edit, its only work on detail page. so we need to create a seprate VF page, which we can open from a Tab or can override the New and Edit button of Object 3, so when user click on those button, it will open our custom VF page.

We need to keep relationship between object3 and (Object1 and Object 2), it will be either lookup or masterdetail depends on our buisness requirement.

Rollup fields are not editable and as we want to take input from end user and add that input in our Object 1 total and Object 2 static number then its better if keep these fields of Number type and our custom code will populate these fields.

Please let me know if I can help you more. 

Thanks,
Vishal
Email : vishal.er.gupta@gmail.com
Skype : vishal.gupta293
Vishal_GuptaVishal_Gupta
Hi Chriscwharris,

Have you finalize any solution?

Thanks,
Vishal
chriscwharrischriscwharris
Hi Vishal, I haven't had a chance to look at this yet, I'm hoping today!

Thanks