You need to sign in to do that
Don't have an account?
Pawan Kumar 32
Update Child ServiceMax object's field based on update to Parent ServiceMax object's field
Hi All,
I want a custom field "OD_Last_Qualified_Date_Update_At__c" on Child Object SVMXC__Installed_Product__c(ServiceMax object) to be updated to value "System.now" when Parent Object SVMXC__site__c's(ServiceMax object) custom field "SVMXC__street__c" is updated to "any value".
In the below code my trigger is not getting fire.
Any assistance with code or alternate solutions are much appreciated!
I want a custom field "OD_Last_Qualified_Date_Update_At__c" on Child Object SVMXC__Installed_Product__c(ServiceMax object) to be updated to value "System.now" when Parent Object SVMXC__site__c's(ServiceMax object) custom field "SVMXC__street__c" is updated to "any value".
In the below code my trigger is not getting fire.
trigger OD_Integration_Trigger on SVMXC__site__c (after update){ set<id> locationIds = new set<id>(); if (trigger.isupdate) { locationIds.addAll(trigger.newMap.keySet()); //productsToProcess.add(p); system.debug('@@@@@@@@@@@@@@'+ locationIds); // update productsToProcess; list<SVMXC__Installed_Product__c> productsToprocess= new list<SVMXC__Installed_Product__c>(); for (SVMXC__Installed_Product__c p : [select id, Name, OD_Last_Qualified_Update_At__c,OD_Sync_Status__c from SVMXC__Installed_Product__c where id in :locationIds and Product_Line__c='OnDemand']){ p.OD_Last_Qualified_Update_At__c = system.now(); p.OD_Sync_Status__c = 'Pending'; productsToprocess.add(p); } system.debug('##########'+ productsToprocess); update productsToprocess; } }
Any assistance with code or alternate solutions are much appreciated!
In your code, there are various flaws, the reason your trigger is not firing because in your query's where clause you are comapring Id of two different objects. Also, if you correct that thing, your trigger will always fire, if you do any change in the Site. You can use the below code: Let me know if this helps you and mark it as best answer.
Thanks,
Neetu
All Answers
In your code, there are various flaws, the reason your trigger is not firing because in your query's where clause you are comapring Id of two different objects. Also, if you correct that thing, your trigger will always fire, if you do any change in the Site. You can use the below code: Let me know if this helps you and mark it as best answer.
Thanks,
Neetu
Now I have optimized the code as well. :)