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
venk1255venk1255 

Problem with updation of a field

Hi i want to update system.size field its not updateing can any one can help on this

 

it would be great appericated

 

trigger trgSystemSize on oe_order_lines__c (before insert, before update)
{

Set<Id> lstS = new Set<Id>();
for(oe_order_lines__c ool: trigger.new)
if(ool.Item_Number_Order_Line__c != null)
lstS.add(ool.Item_Number_Order_Line__c);


List<oe_order_lines__c> lstol= new List<oe_order_lines__c>();

if(!lstS.isEmpty())
{
for(oe_order_lines__c ool: Trigger.new)
{
Map<Id, Item__c> mI = new Map<Id, Item__c>([SELECT Name,Item_ID__c, Product_Type__c, Item_Category_3__c FROM Item__c WHERE Name IN: lstS]);

if((ool.Item_Number_Order_Line__c != null) && mI.containsKey(ool.Item_Number_Order_Line__c))
{

if( (mI.get(ool.Item_Number_Order_Line__c).Product_Type__c=='FG MODULE') &&
( (ool.INVENTORY_ITEM_ID__c == Integer.valueof(mI.get(ool.Item_Number_Order_Line__c).Item_ID__c) )
|| (ool.ITEM_NUMBER__c == String.valueof(Integer.valueof(mI.get(ool.Item_Number_Order_Line__c).Item_ID__c) ))) )

ool.System_Size__c = (ool.REQUESTED_QTY__c) * (Integer.valueof(mI.get(ool.Item_Number_Order_Line__c).Item_Category_3__c));
update ool;
}
else
{
ool.System_Size__c= null;
}

}
}
}

vishal@forcevishal@force

Hi,

 

yours is a before update ttigger, so the moment this code is executed - record will be updated. You do not need to do it from your code. 

 

So, in first place please remove this statement: 

 

update ool;