'Consumed From Location’ Field Sample Code
Sample code for the 'Consumed From Locationâ field is displayed below.
trigger WORD_Line_UpdateConsumedLocationTrigger on SVMXC__Service_Order_Line__c (before insert, before update)
{
List<SVMXC__Service_Group_Members__c> lstTechnician = new List<SVMXC__Service_Group_Members__c>();
lstTechnician = [Select SVMXC__Salesforce_User__c, SVMXC__Inventory_Location__c From SVMXC__Service_Group_Members__c where SVMXC__Inventory_Location__c != null and SVMXC__Salesforce_User__c=:UserInfo.getUserId() Limit 1];
if (lstTechnician != null && lstTechnician.size() == 1 && lstTechnician[0].SVMXC__Inventory_Location__c != null)
{
for(SVMXC__Service_Order_Line__c R : Trigger.new)
{
if(R.SVMXC__Consumed_From_Location__c == null )
R.SVMXC__Consumed_From_Location__c = lstTechnician[0].SVMXC__Inventory_Location__c;
}
}
}