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
hegde_hegdekhegde_hegdek 

Automatically Calculating Field value

Hello, I have a custom field called total,which is calculated automatically by multiplying 2 custom fields unit and price,this should happen as soon as the unit and price fields are entered,I used a trigger i always get a readonly error,I cannot use formula as i cannot reference the othere fields

regards

hegdek

Ispita_NavatarIspita_Navatar

I could not understand fully the limitation faced by you that is about not being able to reference the "other" fields . Could you please elaborate your scenario.

As of the error you are getting please check the :-

1. Is the field read-only or formula?

2. How have you structured your trigger , are you trying to fire your trigger on after update event, if yes try with before update?

Please do check the above and let me know.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

DEV_NAVATARDEV_NAVATAR

You can’t assign value in formula fields through API calls.


Either you can go for formula field datatype. But formula field with value will display only in detail page after save.
If you go for Trigger, whether it is on after or before insert, the value will display only after click on save button not in edit page.


If you want to display the value in field Total as soon as the unit and price fields are entered you have to create a Visual force page for this. Keep this field as read only so that no user other than System Admin can edit this field.