• xmikedev
  • NEWBIE
  • 0 Points
  • Member since 2007

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I have been starting to work with triggers and this one works... as long as you are not bulk inserting. My issue is that we have a custom child object to Cases calles SVC WO and grandchild object called FS Labor. When the labor object is inserted or updated, it needs to update both the SVC WO and the Case depending on logic. The logic is working fine. I know that the problem is that I am trying to do updates within the for loops. If I try to get them out, I no longer have access to the variables described in the loop.

trigger StatUpd on FS_Labor__c (after insert, after update) { List<Id> CasesToUpdate = new List<Id>{}; List<Id> WOsToUpdate = new List<Id>{}; // Find cases and WOs to update for(FS_Labor__c fsl : Trigger.new){ CasesToUpdate.add(fsl.CaseId__c); WOsToUpdate.add(fsl.Service_WO__c); // Update the WOs Field_Service_WO__c[] wos = [select id, Arrival_Time_on_Site__c, Date_and_Time_Back_Online__c from Field_Service_WO__c where id in:WOsToUpdate]; for(Field_Service_WO__c wo: wos){ IF(wo.Arrival_Time_on_Site__c == null || (Trigger.isupdate && wo.Arrival_Time_on_Site__c == Trigger.oldMap.get(fsl.id).Start_Time__c)) wo.Arrival_Time_on_Site__c = fsl.Start_Time__c; IF(fsl.Final_Status__c == 'Functional') wo.Date_and_Time_Back_Online__c = fsl.Stop_Time__c; update wo; // Update the cases Case[] cases = [select id, Service_Status__c from Case where id in :CasesToUpdate]; for(Case c: cases){ If(wo.Date_and_Time_Back_Online__c == null || fsl.Stop_Time__c >= wo.Date_and_Time_Back_Online__c) c.Service_Status__c = fsl.Final_Status__c; update c; } } } }

 

  • April 11, 2009
  • Like
  • 0

I have created a workflow rule on an Account Object, which updates the Account Record type from Unsigned Group to Signed Group, when the Account status changes from Unsigned to Signed and if the Insurance type custom field is Group. However, the rule doesnt seem to be working?

Also, The Account status is workflow field update on its own. So when the Opportunity Stage changes to Closed Won, the Account status changes to Signed from Unsigned, and this is working fine. 

 

Is it because the first workflow relies on the second workflow rule to update its value?

  • January 26, 2009
  • Like
  • 0