You need to sign in to do that
Don't have an account?

Need to update formula field
Hi guys,plesae help me out with this scenario:
Here the list view named of Object Sla_sanpshot__c who is a child of sla__c object.
In list view there is fields like A__c AND B__c from Sla_snapshot__c so if i will update this fields then i want to change the value in my formula which is like (A/B)*100...SO writing trigger to update but it is throwning me an error:
if(trigger.isbefore)
{
if(Trigger.isUpdate || Trigger.isInsert)
{
for(SLA_Snapshot__c s: Trigger.new)
{
s.Formula__c = s.Formula__c != null ? string.valueof(s.Formula__c) : '';
string.valueof(s.Formula__c).replace('A',s.A__c);
}
}
}

Here the list view named of Object Sla_sanpshot__c who is a child of sla__c object.
In list view there is fields like A__c AND B__c from Sla_snapshot__c so if i will update this fields then i want to change the value in my formula which is like (A/B)*100...SO writing trigger to update but it is throwning me an error:
if(trigger.isbefore)
{
if(Trigger.isUpdate || Trigger.isInsert)
{
for(SLA_Snapshot__c s: Trigger.new)
{
s.Formula__c = s.Formula__c != null ? string.valueof(s.Formula__c) : '';
string.valueof(s.Formula__c).replace('A',s.A__c);
}
}
}

Hi Shivangi, you cannot update formula fields..i.e., if the field type of the field that you are trying to update is formula, then you cannot update it any way like apex trigger or process builder or workflow rule.