• DScottR
  • 0 Points
  • Member since 2009

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 1

I have a similar scenario and haved tried adapting the code below to my situtaion but am not familiar enough with triggers to make it work.


Here is my situation:


Lead = Parent Object

Hot List = Child Object (from a managed install)


My main goal is to reference the field "Hot__c", a true/false, from the child object "Hot List" [Hot__List__c.Hot] via an advanced formula.  However this will not work when trying to go down to a child from a parent in the advanced formula builder.


So, I figured out I need a trigger to update a custom field "RC_Hot__c" on the parent object "Lead" [Lead.RC_Hot__c].


1.  Where should the trigger fire on the Lead or the Child object Hot__List__c?  I want the field Lead.RC_Hot__c to update when the value for  Hot__List__c.Hot__c changes.


2.  If the trigger must live on the custom object "Hot__List__c" and that object is from a managed install will this even work?


Here is the code that I tried to adapt and it does not work.  try not to laugh I have never done this before ;-)


trigger UpdateRCHot on Lead (after insert, after update) {

    // Create a set of Lead IDs to use as a query parameter
    Set<String> LeadIDs = new Set<String>();
    for(Hot__List__c h : Trigger.new) {
        LeadIDs.add(h.Hot_Lead_id__c); // Use whatever your custom look-up field is to Lead from Hot__List__c

    // Create a list of locations to update
    List<Lead> LeadsToUpdate = new List<h.Hot_Lead_id__c>();

    // Select and iterate through any Hot__List__c associated with set of Lead records being inserted or updated
    for(Lead l : [Select Hot_Lead_id__c, Hot__c FROM Hot__List__c WHERE Hot__c = true]) {
    l.RC_Hot__c = false;

    update LeadsToUpdate;


Hey all,


I'm trying to uncheck the active check box for a number of locations object records.


The setup of my objects is as follow:


Locations --> Hardware (Both are custom objects which have parent child relationship)


I have a related list of Hardware for every Location record.

And, location records have an Active check box status which identifies if that location is currently active or not.


The logic behind the Active check box:

It is assumed to be unchecked if there are no Hardware records in the respective Locations related list.

And, it is assumed to be checked if there is one or more Hardware records in the respective Locations related list.


I believe this is viable through the Triggers.


Any help or comment is appreciated.


Thank you,