• Aron Schor 24
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 8
    Replies
Hi, I am using two Triggers and it seems the record that is initially being updated does not stay in sync with the other records.
Example, for Pitch (custom) record 123, let's say I add a $2 Opportunity and then Property tied to Property Group A.
What happens is Total Amount is $102 for all related records EXCEPT 123 which shows $100.
It seems the amount is set for that record prior to it being tied to the Property Group.
After, if I update record 123 by making any change, then it becomes $102.  I want it to become $102 with these triggers.
I should say I am no expert and have been getting assistence from the forums (thanks Prateek P!) and ChatGPT.
Thanks.

trigger PropertyCalc1 on Pitch__c (before insert, before update) {

  // Get the records that are being triggered on.
  List<Pitch__c> records = Trigger.new;

  // Get the property group amount for each record.
  for (Pitch__c record : records) {
    List<AggregateResult> propertyGroupAmounts = [
      SELECT SUM(Opportunity__r.Amount)
      FROM Pitch__c
      WHERE Property_Group__c = :record.Property_Group__c
      GROUP BY propertyhighspot__r.Property_Group_Text__c
    ];

    // Set the property group amount for each record.
    if (propertyGroupAmounts != null && propertyGroupAmounts.size() > 0) {
      record.Property_Group_Amount__c = (Decimal)propertyGroupAmounts[0].get('expr0');
    } else {
      // Set the property group amount to 0 if there is no amount.
      record.Property_Group_Amount__c = 0;
    }
  }
}

trigger PropertyCalc2 on Pitch__c (after update) {

  // Get the records that are being triggered on.
  List<Pitch__c> records = Trigger.new;

  // Check if the trigger is currently running.
  if (RecursiveTriggerHandler.isFirstTime) {
    // Set isFirstTime to false to prevent recursion.
    RecursiveTriggerHandler.isFirstTime = false;

    // Update all records with the same value for Property_Group__c.
    List<Pitch__c> matchingRecordsToUpdate = new List<Pitch__c>();
    for (Pitch__c record : records) {
      if (record.Property_Group__c != null) {
        // Get all records with the same value for Property_Group__c.
        List<Pitch__c> matchingRecords = [
          SELECT Id, Property_Group_Amount__c
          FROM Pitch__c
          WHERE Property_Group__c = :record.Property_Group__c
          AND Id != :record.Id
        ];

        // Update the property group amount for all matching records.
        for (Pitch__c matchingRecord : matchingRecords) {
          matchingRecord.Property_Group_Amount__c = record.Property_Group_Amount__c;
          matchingRecordsToUpdate.add(matchingRecord);
        }
      }
    }

    // Update all matching records outside of the trigger context.
    if (!matchingRecordsToUpdate.isEmpty()) {
      update matchingRecordsToUpdate;
    }
  }
}

                     
Hi, I have a trigger that updates a field on a custom object, Pitch.  I got it to partially work with help from ChatGPT and my own tweaks.

1. What it does is update a field that shows the total of all Opportunity Amounts related to a specific Opportunity Property Group.
2. Next it should find all other Pitch records that have the same Opportunity Property Group do the same update so all related records should be in sync.

ie Select SUM(Opportunity__r.Amount) From Pitch__c where Property_Group__c = :record.Property_Group__c

It does not do step 2 but I can't figure out why.  Any idea?

trigger calculatePropertyGroupAmountBeforeFull on Pitch__c (before insert, before update) {
  // Get the records that are being triggered on.
  List<Pitch__c> records = Trigger.new;

  // Get the property group amount for each record.
  for (Pitch__c record : records) {
    List<AggregateResult> propertyGroupAmounts = [

      SELECT SUM(Opportunity__r.Amount)
      FROM Pitch__c
      WHERE Id = :record.Id OR     
     Property_Group__c = :record.Property_Group__c
      GROUP BY propertyhighspot__r.Property_Group_Text__c

    ];

    // Set the property group amount for each record.
    if (propertyGroupAmounts != null && propertyGroupAmounts.size() > 0) {
      record.Property_Group_Amount__c = (Decimal)propertyGroupAmounts[0].get('expr0');
    } else {
      // Set the property group amount to 0 if there is no amount.
      record.Property_Group_Amount__c = 0;
    }
  }

  // Check if the trigger is currently running.
  if (RecursiveTriggerHandler.isFirstTime) {
    return;
  }


  // Get the property group amount for each record.
  for (Pitch__c record : records) {
    List<AggregateResult> propertyGroupAmounts = [
      SELECT SUM(Opportunity__r.Amount)
      FROM Pitch__c
      WHERE Id = :record.Id OR Property_Group__c = :record.Property_Group__c
      GROUP BY propertyhighspot__r.Property_Group_Text__c
    ];

    // Set the property group amount for each record.
    if (propertyGroupAmounts != null && propertyGroupAmounts.size() > 0) {
      record.Property_Group_Amount__c = (Decimal)propertyGroupAmounts[0].get('expr0');
    } else {
      // Set the property group amount to 0 if there is no amount.
      record.Property_Group_Amount__c = 0;
    }
  }

  // Update all records with the same value for Property_Group__c.
  List<Pitch__c> matchingRecordsToUpdate = new List<Pitch__c>();
  for (Pitch__c record : records) {
    if (record.Property_Group__c != null) {
      // Get all records with the same value for Property_Group__c.
      List<Pitch__c> matchingRecords = [
        SELECT Id, Property_Group_Amount__c
        FROM Pitch__c
        WHERE Property_Group__c = :record.Property_Group__c
        AND Id != :record.Id
      ];

      // Update the property group amount for all matching records.
      for (Pitch__c matchingRecord : matchingRecords) {
        if (!matchingRecord.IsUpdated__c) {
          matchingRecord.Property_Group_Amount__c = record.Property_Group_Amount__c;
          matchingRecord.IsUpdated__c = true;
          matchingRecordsToUpdate.add(matchingRecord);
        }
      }
    }
  }

  // Update all matching records outside of the trigger context.
  if (!matchingRecordsToUpdate.isEmpty()) {
    update matchingRecordsToUpdate;
  }
}

Apex Class
public class RecursiveTriggerHandler{
public static Boolean isFirstTime = true;
}
Hi,

I have a trigger that updates a currency field on a custom object (Pitch).  The amount reflects the Sum of Opportunty Amounts among all Pitch records that have the same Property group.  However, it can only update the one record that triggers it.  I really want to update all the Pitch records that have the same property group so all records would then have the same value.  I get an error when doing the other records.  I am trying to use ChatGPT but am stuck.  Let me know of any suggestions.

Error when updating a record

CalculatePropertyGroupAmountBefore4: Execution Of BeforeUpdate Caused By: System.DmlException: Update Failed. First Exception On Row 0 With Id A0a1O00000cd3zEQAQ;

First Error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CalculatePropertyGroupAmountBefore4: Execution Of BeforeUpdate Caused By: System.DmlException: Update Failed. First Exception On Row 0 With Id A0a1O00000cd3zdQAA;
First Error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CalculatePropertyGroupAmountBefore4: Execution Of BeforeUpdate Caused By: System.DmlException: Update Failed. First Exception On Row 0 With Id A0a1O00000cd3zEQAQ;
First Error: SELF_REFERENCE_FROM_TRIGGER, Object (id = A0a1O00000cd3zE) Is Currently In Trigger CalculatePropertyGroupAmountBefore4, Therefore It Cannot Recursively Update Itself: [] Trigger.CalculatePropertyGroupAmountBefore4:

Line 45, Column 1: [] Trigger.CalculatePropertyGroupAmountBefore4:
Line 45, Column 1: [] Trigger.CalculatePropertyGroupAmountBefore4:
Line 45, Column 1

Trigger CalculatePropertyGroupAmountBefore4 on Pitch__c (before insert, before update) {
  // Check if the trigger is currently running.
  //if (Trigger.isRunning) {
    //return;
  //}

  // Get the records that are being triggered on.
  List<Pitch__c> records = Trigger.new;

  // Get the property group amount for each record.
  for (Pitch__c record : records) {
    List<AggregateResult> propertyGroupAmounts = [
      SELECT SUM(Opportunity__r.Amount)
      FROM Pitch__c
      WHERE Id = :record.Id OR     
     Property_Group__c = :record.Property_Group__c
      GROUP BY propertyhighspot__r.Property_Group_Text__c
    ];

    // Set the property group amount for each record.
    if (propertyGroupAmounts != null && propertyGroupAmounts.size() > 0) {
      record.Property_Group_Amount__c = (Decimal)propertyGroupAmounts[0].get('expr0');
    } else {
      // Set the property group amount to 0 if there is no amount.
      record.Property_Group_Amount__c = 0;
    }
  }

  // Update all records with the same value for Property_Group__c.
  for (Pitch__c record : Trigger.new) {
    if (record.Property_Group__c != null) {
      // Get all records with the same value for Property_Group__c.
      List<Pitch__c> matchingRecords = [
        SELECT Id, Property_Group_Amount__c, IsUpdated__c
        FROM Pitch__c
        WHERE Property_Group__c = :record.Property_Group__c
        AND Id != :record.Id
      ];

      // Update the property group amount for all matching records.
      for (Pitch__c matchingRecord : matchingRecords) {
        if (!matchingRecord.isUpdated__c) {
          matchingRecord.Property_Group_Amount__c = record.Property_Group_Amount__c;
          matchingRecord.isUpdated__c = true;
          update matchingRecord;
        }
      }
    }
  }
}
Hi, I utilized ChatGPT to help create a trigger.  It seems run but does not seem update.  From using the debug log it says "21:29:14.0 (164719242)|VARIABLE_ASSIGNMENT|[5]|pitch|null|"  Can I get assistance understanding why it passes as null?

I essentially want:
1. If a value is set on CustomObject__c for CustomFieldId__c, which is a lookup to Product2, I want Salesforce to find the value for CustomFieldId__r.Property_Group_Text__c.
2. Then I want Salesforce to search all Records from CustomObject__c who have the same CustomFieldId__r.Property_Group_Text__c value
3. And find the SUM of Opportunity_Amount__c, which is populated when the Opportunity is added.

I have tried updating Property_Group_Text__c on the CustomObject and then running second trigger but I'd have problems with the record being in read only mode, so I figured I'd try to have this trigger do two things do the lookup as well.

If I could find some way to have the field on the CustomObject show the Sum of the Opportunity Amounts, either by lookup or by a field on CustomObject as shown, I'd be very appreciative. Aron

trigger UpdateTrigger on CustomObject__c (after insert, after update) {
    Set<String> updatedPropertyGroups = new Set<String>();

    // Loop through the trigger records and add their updated Property_Group_Text__c values to the set
    for (CustomObject__c CustomObject : Trigger.new) {
        if (CustomObject.CustomFieldId__c != null && (Trigger.isInsert || CustomObject.Property_Group_Text__c != Trigger.oldMap.get(CustomObject.Id).Property_Group_Text__c)) {
            updatedPropertyGroups.add(CustomObject.CustomFieldId__r.Property_Group_Text__c);
        }
    }

    // Query the Opportunities related to the updated CustomObject records and Property_Group_Text__c
    List<AggregateResult> results = [SELECT SUM(Opportunity_Amount__c) sumAmount, Property_Group_text__c propertyGroupValue                                      
    FROM                                       
    WHERE CustomFieldId__c IN :Trigger.newMap.keySet() AND Property_Group_text__c IN :updatedPropertyGroups                                     
    GROUP BY Property_Group_text__c];

    // Create a map of Property Group Text values to their SUM(Opportunity__r.Amount) totals
    Map<String, Decimal> propertyGroupAmounts = new Map<String, Decimal>();
    for (AggregateResult result : results) {
        propertyGroupAmounts.put((String) result.get('propertyGroupValue'), (Decimal) result.get('sumAmount'));
    }

    // Create a list of CustomObject__c records to update
    List<CustomObject__c> CustomObjectesToUpdate = new List<CustomObject__c>();

    // Loop through the updated CustomObject records again and update their Property_Group_Amount__c field
    for (CustomObject__c CustomObject : Trigger.new) {
        if (updatedPropertyGroups.contains(CustomObject.Property_Group_text__c)) {
            CustomObject.Property_Group_Amount__c = propertyGroupAmounts.get(CustomObject.Property_Group_text__c);
            CustomObjectesToUpdate.add(CustomObject);
        }
    }

    // Perform a DML update on the list of CustomObject__c records
    if (!CustomObjectesToUpdate.isEmpty()) {
        update CustomObjectesToUpdate;
    }
}
I am aware you can query the ApexClass object in Workbench, but how can I see which Object each class is associated with?  I am an admin given this task so perhaps there is a technical reason why this can't done but let me know if there is way to do this.  Thanks.  Aron
Hi,

I have a Visual Force template using If/Then logic.  If the field is blank, don't show it.  However, it adds a space.  How do I fix?

This code:
{!RelatedTo.Requester_Name__r.Name} Text <apex:repeat value="{!relatedTo.Requester_Name__r}" var="con" > {!IF(ISBLANK(con.Field1__c), NULL, (con.Field1__c) + ',')} {!IF(ISBLANK(con.Primary_Field2__c), NULL, (con.Field2) + ',')} {!IF(ISBLANK(con.Primary_Field3__c), '', (con.Field3) + ',')}</apex:repeat> Text.

Displays:
Name Text Field1, Field2, Field3, Text - This is fine (If 3 fields have a value)
Name Text Field1,   Text.  - This is an issue, due to spacing (If just the first field has a value)

Thanks, Aron!
Hi,

I get error 
Challenge Not yet complete... here's what's wrong:
Could not find a Service Appointment with the Subject of 'Drill Cable Holes'.

I tried this twice in the playground and completed the first part with no issues.  Screen shot attached.

User-added image
I also posted this in the Successs Community but it might be a bit complex/not possible.  I have not gotten a reply.
I recently installed an App that sends out emails and is tied to a Workflow on the Campaign Member object.  It works, but the issue is that since its a Workflow I can’t use the HTML Email Status Report.  I would like to try to create an Email Template on the Contact object that references fields on the Campaign Member object but I am not sure how to link via a formula.  This way I could just do a Mass Email Contacts and then I could use the HTML Email Status Report to see if emails are being read.  Any input would be appreciated.  Thanks.  Aron
Hi...I get this error when I try to “Verify Step”
Challenge Not yet complete... here's what's wrong: Could not find a successful cat dataset training. The training may take a couple of minutes after the model is created.
I have seen this post but the information doesn’t help me:  I have tried deleting/refreshing multiple times.
https://developer.salesforce.com/forums?id=9060G000000UbjnQAC
 
The odd thing is I do see the Dataset Labels after I X out of the errors that generate.
 
Specific errors:
 
I get this error when I try to “Create Dataset.”  (I actually get a few, but they are displayed one at a time and they are similar)
A Component Error has occurred!
 
Message: Access Check Failed! AttributeSet.set(): 'waiting' of component 'markup://c:EinsteinVision_Admin_UI {7:396;a}' is not visible to 'markup://c:EinsteinVision_Admin_UI {7:396;a}'.
 
Component Descriptor: markup://c:EinsteinVision_Admin_UI
 
Filename: https://comptrailhead-dev-ed.lightning.force.com/auraFW/javascript/YJT9Ctwc-kFeKnrsNhEdlA/aura_proddebug.js
 
Function: componentConstructor.Component.set
 
Line: 6255
 
Column: 37
 
Stack Trace: componentConstructor.Component.set()@https://comptrailhead-dev-ed.lightning.force.com/auraFW/javascript/YJT9Ctwc-kFeKnrsNhEdlA/aura_proddebug.js:6255:37
Object.value [as set]()@https://comptrailhead-dev-ed.lightning.force.com/auraFW/javascript/YJT9Ctwc-kFeKnrsNhEdlA/aura_proddebug.js:21262:45
Object.<anonymous>()@components/c/EinsteinVision_Admin_UI.js:31:23
 
I also signed out and signed back and got this error when refreshing the first time.
 
comptrailhead-dev-ed.lightning.force.com says:
 
An internal server error has occurred
Error ID: 557985290-81646 (119852647)

org.auraframework.throwable.AuraExecutionException: apex://EinsteinVision_Admin:7,1: common.apex.runtime.impl.ExecutionException: url
at .(apex://EinsteinVision_Admin:7)
at ui.services.facades.CoreLightningComponentFacadeImpl.runApexAction(CoreLightningComponentFacadeImpl.java:232)
at aura.impl.apex.controller.ApexActionImpl.run(ApexActionImpl.java:72)
at org.auraframework.impl.ServerServiceImpl.run(ServerServiceImpl.java:203)
at org.auraframework.impl.ServerServiceImpl.run(ServerServiceImpl.java:153)
at org.auraframework.http.AuraServlet.doPost(AuraServlet.java:512)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty9.servlet.ServletHolder.handle(ServletHolder.java:845)
at org.eclipse.jetty9.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1693)
at system.filter.AuraDomainRedirectFilter....andlerWrapper.handle(HandlerWrapper.java:134)
at org.eclipse.jetty9.server.Server.handle(Server.java:518)
at org.eclipse.jetty9.server.HttpChannel.handle(HttpChannel.java:308…

Thanks for any help!

User-added image
Hi,

I get error 
Challenge Not yet complete... here's what's wrong:
Could not find a Service Appointment with the Subject of 'Drill Cable Holes'.

I tried this twice in the playground and completed the first part with no issues.  Screen shot attached.

User-added image
Hi, I have a trigger that updates a field on a custom object, Pitch.  I got it to partially work with help from ChatGPT and my own tweaks.

1. What it does is update a field that shows the total of all Opportunity Amounts related to a specific Opportunity Property Group.
2. Next it should find all other Pitch records that have the same Opportunity Property Group do the same update so all related records should be in sync.

ie Select SUM(Opportunity__r.Amount) From Pitch__c where Property_Group__c = :record.Property_Group__c

It does not do step 2 but I can't figure out why.  Any idea?

trigger calculatePropertyGroupAmountBeforeFull on Pitch__c (before insert, before update) {
  // Get the records that are being triggered on.
  List<Pitch__c> records = Trigger.new;

  // Get the property group amount for each record.
  for (Pitch__c record : records) {
    List<AggregateResult> propertyGroupAmounts = [

      SELECT SUM(Opportunity__r.Amount)
      FROM Pitch__c
      WHERE Id = :record.Id OR     
     Property_Group__c = :record.Property_Group__c
      GROUP BY propertyhighspot__r.Property_Group_Text__c

    ];

    // Set the property group amount for each record.
    if (propertyGroupAmounts != null && propertyGroupAmounts.size() > 0) {
      record.Property_Group_Amount__c = (Decimal)propertyGroupAmounts[0].get('expr0');
    } else {
      // Set the property group amount to 0 if there is no amount.
      record.Property_Group_Amount__c = 0;
    }
  }

  // Check if the trigger is currently running.
  if (RecursiveTriggerHandler.isFirstTime) {
    return;
  }


  // Get the property group amount for each record.
  for (Pitch__c record : records) {
    List<AggregateResult> propertyGroupAmounts = [
      SELECT SUM(Opportunity__r.Amount)
      FROM Pitch__c
      WHERE Id = :record.Id OR Property_Group__c = :record.Property_Group__c
      GROUP BY propertyhighspot__r.Property_Group_Text__c
    ];

    // Set the property group amount for each record.
    if (propertyGroupAmounts != null && propertyGroupAmounts.size() > 0) {
      record.Property_Group_Amount__c = (Decimal)propertyGroupAmounts[0].get('expr0');
    } else {
      // Set the property group amount to 0 if there is no amount.
      record.Property_Group_Amount__c = 0;
    }
  }

  // Update all records with the same value for Property_Group__c.
  List<Pitch__c> matchingRecordsToUpdate = new List<Pitch__c>();
  for (Pitch__c record : records) {
    if (record.Property_Group__c != null) {
      // Get all records with the same value for Property_Group__c.
      List<Pitch__c> matchingRecords = [
        SELECT Id, Property_Group_Amount__c
        FROM Pitch__c
        WHERE Property_Group__c = :record.Property_Group__c
        AND Id != :record.Id
      ];

      // Update the property group amount for all matching records.
      for (Pitch__c matchingRecord : matchingRecords) {
        if (!matchingRecord.IsUpdated__c) {
          matchingRecord.Property_Group_Amount__c = record.Property_Group_Amount__c;
          matchingRecord.IsUpdated__c = true;
          matchingRecordsToUpdate.add(matchingRecord);
        }
      }
    }
  }

  // Update all matching records outside of the trigger context.
  if (!matchingRecordsToUpdate.isEmpty()) {
    update matchingRecordsToUpdate;
  }
}

Apex Class
public class RecursiveTriggerHandler{
public static Boolean isFirstTime = true;
}
Hi,

I have a trigger that updates a currency field on a custom object (Pitch).  The amount reflects the Sum of Opportunty Amounts among all Pitch records that have the same Property group.  However, it can only update the one record that triggers it.  I really want to update all the Pitch records that have the same property group so all records would then have the same value.  I get an error when doing the other records.  I am trying to use ChatGPT but am stuck.  Let me know of any suggestions.

Error when updating a record

CalculatePropertyGroupAmountBefore4: Execution Of BeforeUpdate Caused By: System.DmlException: Update Failed. First Exception On Row 0 With Id A0a1O00000cd3zEQAQ;

First Error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CalculatePropertyGroupAmountBefore4: Execution Of BeforeUpdate Caused By: System.DmlException: Update Failed. First Exception On Row 0 With Id A0a1O00000cd3zdQAA;
First Error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CalculatePropertyGroupAmountBefore4: Execution Of BeforeUpdate Caused By: System.DmlException: Update Failed. First Exception On Row 0 With Id A0a1O00000cd3zEQAQ;
First Error: SELF_REFERENCE_FROM_TRIGGER, Object (id = A0a1O00000cd3zE) Is Currently In Trigger CalculatePropertyGroupAmountBefore4, Therefore It Cannot Recursively Update Itself: [] Trigger.CalculatePropertyGroupAmountBefore4:

Line 45, Column 1: [] Trigger.CalculatePropertyGroupAmountBefore4:
Line 45, Column 1: [] Trigger.CalculatePropertyGroupAmountBefore4:
Line 45, Column 1

Trigger CalculatePropertyGroupAmountBefore4 on Pitch__c (before insert, before update) {
  // Check if the trigger is currently running.
  //if (Trigger.isRunning) {
    //return;
  //}

  // Get the records that are being triggered on.
  List<Pitch__c> records = Trigger.new;

  // Get the property group amount for each record.
  for (Pitch__c record : records) {
    List<AggregateResult> propertyGroupAmounts = [
      SELECT SUM(Opportunity__r.Amount)
      FROM Pitch__c
      WHERE Id = :record.Id OR     
     Property_Group__c = :record.Property_Group__c
      GROUP BY propertyhighspot__r.Property_Group_Text__c
    ];

    // Set the property group amount for each record.
    if (propertyGroupAmounts != null && propertyGroupAmounts.size() > 0) {
      record.Property_Group_Amount__c = (Decimal)propertyGroupAmounts[0].get('expr0');
    } else {
      // Set the property group amount to 0 if there is no amount.
      record.Property_Group_Amount__c = 0;
    }
  }

  // Update all records with the same value for Property_Group__c.
  for (Pitch__c record : Trigger.new) {
    if (record.Property_Group__c != null) {
      // Get all records with the same value for Property_Group__c.
      List<Pitch__c> matchingRecords = [
        SELECT Id, Property_Group_Amount__c, IsUpdated__c
        FROM Pitch__c
        WHERE Property_Group__c = :record.Property_Group__c
        AND Id != :record.Id
      ];

      // Update the property group amount for all matching records.
      for (Pitch__c matchingRecord : matchingRecords) {
        if (!matchingRecord.isUpdated__c) {
          matchingRecord.Property_Group_Amount__c = record.Property_Group_Amount__c;
          matchingRecord.isUpdated__c = true;
          update matchingRecord;
        }
      }
    }
  }
}
Hi, I utilized ChatGPT to help create a trigger.  It seems run but does not seem update.  From using the debug log it says "21:29:14.0 (164719242)|VARIABLE_ASSIGNMENT|[5]|pitch|null|"  Can I get assistance understanding why it passes as null?

I essentially want:
1. If a value is set on CustomObject__c for CustomFieldId__c, which is a lookup to Product2, I want Salesforce to find the value for CustomFieldId__r.Property_Group_Text__c.
2. Then I want Salesforce to search all Records from CustomObject__c who have the same CustomFieldId__r.Property_Group_Text__c value
3. And find the SUM of Opportunity_Amount__c, which is populated when the Opportunity is added.

I have tried updating Property_Group_Text__c on the CustomObject and then running second trigger but I'd have problems with the record being in read only mode, so I figured I'd try to have this trigger do two things do the lookup as well.

If I could find some way to have the field on the CustomObject show the Sum of the Opportunity Amounts, either by lookup or by a field on CustomObject as shown, I'd be very appreciative. Aron

trigger UpdateTrigger on CustomObject__c (after insert, after update) {
    Set<String> updatedPropertyGroups = new Set<String>();

    // Loop through the trigger records and add their updated Property_Group_Text__c values to the set
    for (CustomObject__c CustomObject : Trigger.new) {
        if (CustomObject.CustomFieldId__c != null && (Trigger.isInsert || CustomObject.Property_Group_Text__c != Trigger.oldMap.get(CustomObject.Id).Property_Group_Text__c)) {
            updatedPropertyGroups.add(CustomObject.CustomFieldId__r.Property_Group_Text__c);
        }
    }

    // Query the Opportunities related to the updated CustomObject records and Property_Group_Text__c
    List<AggregateResult> results = [SELECT SUM(Opportunity_Amount__c) sumAmount, Property_Group_text__c propertyGroupValue                                      
    FROM                                       
    WHERE CustomFieldId__c IN :Trigger.newMap.keySet() AND Property_Group_text__c IN :updatedPropertyGroups                                     
    GROUP BY Property_Group_text__c];

    // Create a map of Property Group Text values to their SUM(Opportunity__r.Amount) totals
    Map<String, Decimal> propertyGroupAmounts = new Map<String, Decimal>();
    for (AggregateResult result : results) {
        propertyGroupAmounts.put((String) result.get('propertyGroupValue'), (Decimal) result.get('sumAmount'));
    }

    // Create a list of CustomObject__c records to update
    List<CustomObject__c> CustomObjectesToUpdate = new List<CustomObject__c>();

    // Loop through the updated CustomObject records again and update their Property_Group_Amount__c field
    for (CustomObject__c CustomObject : Trigger.new) {
        if (updatedPropertyGroups.contains(CustomObject.Property_Group_text__c)) {
            CustomObject.Property_Group_Amount__c = propertyGroupAmounts.get(CustomObject.Property_Group_text__c);
            CustomObjectesToUpdate.add(CustomObject);
        }
    }

    // Perform a DML update on the list of CustomObject__c records
    if (!CustomObjectesToUpdate.isEmpty()) {
        update CustomObjectesToUpdate;
    }
}
Hi,

I have a Visual Force template using If/Then logic.  If the field is blank, don't show it.  However, it adds a space.  How do I fix?

This code:
{!RelatedTo.Requester_Name__r.Name} Text <apex:repeat value="{!relatedTo.Requester_Name__r}" var="con" > {!IF(ISBLANK(con.Field1__c), NULL, (con.Field1__c) + ',')} {!IF(ISBLANK(con.Primary_Field2__c), NULL, (con.Field2) + ',')} {!IF(ISBLANK(con.Primary_Field3__c), '', (con.Field3) + ',')}</apex:repeat> Text.

Displays:
Name Text Field1, Field2, Field3, Text - This is fine (If 3 fields have a value)
Name Text Field1,   Text.  - This is an issue, due to spacing (If just the first field has a value)

Thanks, Aron!
I also posted this in the Successs Community but it might be a bit complex/not possible.  I have not gotten a reply.
I recently installed an App that sends out emails and is tied to a Workflow on the Campaign Member object.  It works, but the issue is that since its a Workflow I can’t use the HTML Email Status Report.  I would like to try to create an Email Template on the Contact object that references fields on the Campaign Member object but I am not sure how to link via a formula.  This way I could just do a Mass Email Contacts and then I could use the HTML Email Status Report to see if emails are being read.  Any input would be appreciated.  Thanks.  Aron
Hi...I get this error when I try to “Verify Step”
Challenge Not yet complete... here's what's wrong: Could not find a successful cat dataset training. The training may take a couple of minutes after the model is created.
I have seen this post but the information doesn’t help me:  I have tried deleting/refreshing multiple times.
https://developer.salesforce.com/forums?id=9060G000000UbjnQAC
 
The odd thing is I do see the Dataset Labels after I X out of the errors that generate.
 
Specific errors:
 
I get this error when I try to “Create Dataset.”  (I actually get a few, but they are displayed one at a time and they are similar)
A Component Error has occurred!
 
Message: Access Check Failed! AttributeSet.set(): 'waiting' of component 'markup://c:EinsteinVision_Admin_UI {7:396;a}' is not visible to 'markup://c:EinsteinVision_Admin_UI {7:396;a}'.
 
Component Descriptor: markup://c:EinsteinVision_Admin_UI
 
Filename: https://comptrailhead-dev-ed.lightning.force.com/auraFW/javascript/YJT9Ctwc-kFeKnrsNhEdlA/aura_proddebug.js
 
Function: componentConstructor.Component.set
 
Line: 6255
 
Column: 37
 
Stack Trace: componentConstructor.Component.set()@https://comptrailhead-dev-ed.lightning.force.com/auraFW/javascript/YJT9Ctwc-kFeKnrsNhEdlA/aura_proddebug.js:6255:37
Object.value [as set]()@https://comptrailhead-dev-ed.lightning.force.com/auraFW/javascript/YJT9Ctwc-kFeKnrsNhEdlA/aura_proddebug.js:21262:45
Object.<anonymous>()@components/c/EinsteinVision_Admin_UI.js:31:23
 
I also signed out and signed back and got this error when refreshing the first time.
 
comptrailhead-dev-ed.lightning.force.com says:
 
An internal server error has occurred
Error ID: 557985290-81646 (119852647)

org.auraframework.throwable.AuraExecutionException: apex://EinsteinVision_Admin:7,1: common.apex.runtime.impl.ExecutionException: url
at .(apex://EinsteinVision_Admin:7)
at ui.services.facades.CoreLightningComponentFacadeImpl.runApexAction(CoreLightningComponentFacadeImpl.java:232)
at aura.impl.apex.controller.ApexActionImpl.run(ApexActionImpl.java:72)
at org.auraframework.impl.ServerServiceImpl.run(ServerServiceImpl.java:203)
at org.auraframework.impl.ServerServiceImpl.run(ServerServiceImpl.java:153)
at org.auraframework.http.AuraServlet.doPost(AuraServlet.java:512)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty9.servlet.ServletHolder.handle(ServletHolder.java:845)
at org.eclipse.jetty9.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1693)
at system.filter.AuraDomainRedirectFilter....andlerWrapper.handle(HandlerWrapper.java:134)
at org.eclipse.jetty9.server.Server.handle(Server.java:518)
at org.eclipse.jetty9.server.HttpChannel.handle(HttpChannel.java:308…

Thanks for any help!

User-added image
Hi,

I am stuck at the Create and Train the Dataset step on the Build a Cat Rescue App That Recognizes Cat Breeds Trailhead module.

I have successfully created the lightning component, uploaded the zip file and clicked on the train button but when I try to Verifiy I get the following error message:
"Challenge Not yet complete... here's what's wrong: 
Could not find a successful cat dataset training. The training may take a couple of minutes after the model is created."

Could you please advise ?

Thanks for your help.