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
KirstyFranceKirstyFrance 

User-Level Security interfering with trigger

Hello,

 

I am getting frustrated because I have two very similar triggers, one of which works correctly while the other does not.

 

They both update fields based on the value of another field. One is a currency field another is a number field. Both these fields are read-only fields (unless you are an administrator).

 

The trigger that updates the currency field works correctly regardless of the user. However the trigger on the number field sets the default value of "0", unless it is an administrator updating the object.

 

Any help would be appreciated. 

Trigger that works trigger SetListPrice on Price_Plan__c (before insert,before update) { for (Price_Plan__c a : Trigger.new) { if (a.Item_Code__c== '1068') {a.List_Price__c = 10 ;} else if(a.Item_Code__c== '1069'|| a.Item_Code__c=='1069'|| a.Item_Code__c=='1081') {a.List_Price__c = 15 ;} else if (a.Item_Code__c== '1019' || a.Item_Code__c=='1074'|| a.Item_Code__c=='1083') {a.List_Price__c = 50 ;} else {a.List_Price__c = 0 ;} } } Trigger that does not work trigger SetCoverNumbers on Price_Plan__c (before insert, before update) { for (Price_Plan__c a : Trigger.new) { if (a.Item_Code__c== '1009'||a.Item_Code__c== '1021' ||a.Item_Code__c== '1043'||a.Item_Code__c== '1066'||a.Item_Code__c== '1082'||a.Item_Code__c== '1063') {a.Covers_Included__c= 50 ;} else if (a.Item_Code__c== '1083'||a.Item_Code__c== '1085') {a.Covers_Included__c= 250 ;} else if (a.Item_Code__c== '1083'||a.Item_Code__c== '1085') {a.Covers_Included__c= 750 ;} else {a.Covers_Included__c= 0 ;} } }