• Maverick Blaze
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi All,

I have configured opportunity record should be moved stage by stage in order using below syntax. I have query that, can we back trace the record in descending order. For eg: Stage - 4 to Stage-3 and Stage-3 to Stage-2 etc.,

OR(
AND(ISPICKVAL(StageName, "Stage 1 - Identified Opportunity"), NOT(ISPICKVAL( PRIORVALUE(StageName) , "Stage 0 - Prospect"))),
AND(ISPICKVAL(StageName, "Stage 2 - Response"), NOT(ISPICKVAL( PRIORVALUE(StageName) , "Stage 1 - Identified Opportunity"))),
AND(ISPICKVAL(StageName, "Stage 3 – Selection"), NOT(ISPICKVAL( PRIORVALUE(StageName) , "Stage 2 - Response"))),
AND(ISPICKVAL(StageName, "Stage 4 – Negotiation"), NOT(ISPICKVAL( PRIORVALUE(StageName) , "Stage 3 – Selection")))
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;
    }
  }
}

                     
Good Morning,

I am trying to create a formula field "Total Health Score" where If the score is 1 - 4.75 = Good, 5 - 6.75 = okay and 7-10 = At Risk with colored Flags Red, Green and Yellow. I created the picklist field called "Total Customer Health Score" with At Risk, Good, and Okay. I am having trouble with if it is zero, then a green flag show. How would I either show a different flag or something else or not show anything if it is zero. Here is my formula I have now:

IF(
Total_Customer_Health_Score__c  <= 4.75 ,
IMAGE('/img/samples/flag_green.gif','Green Flag'),
IF(
Total_Customer_Health_Score__c  <= 6.75,
IMAGE('/img/samples/flag_yellow.gif','Yellow Flag'),
IF(
Total_Customer_Health_Score__c   >= 7,
IMAGE('/img/samples/flag_red.gif', 'Red Flag'),
IF(
Total_Customer_Health_Score__c = 0,
NULL, NULL))))
Create and assign the solution providing Shinje access to the Language Preference field.  for this what I have to do given to Shinje Tashi user