Skip to main content Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era. Register now.

#Trailhead Challenges2,399 discussing

Hands-on challenges are the “secret sauce” of Trailhead. Before searching for solutions to superbadge challenges, review the Salesforce Certification Program Agreement and Policies.

ALL the code: 

 

AND ( 

 

    AND( 

 

ProductCode__c  =  "CA-38",  

  

 SUM (Amount__c)  > 0  

 

)  

 

 

        AND(  

ProductCode__c  =  "AD-Y-11", 

 ProductCode__c  =  "AD-Y-12",  

ProductCode__c  =  "AD-Y-13", 

 ProductCode__c  =  "AD-Y-14" , 

 NOT (    SUM (Amount__c)  > 0   ) 

 ) 

 

)

Erreur de formule

 

Hi team, 

Someone to help me.  

I want a rule that prevents the sum of specific products from being equal to zero. 

 

 

 

#Trailhead Challenges

10 answers
  1. Feb 26, 9:49 PM

    @Ohou Jean-Luc Soboh You'll need to create a Flow to accomplish this, as a formula or validation rule alone can't retrieve specific product records and sum their amounts. In the Flow, use the **Get Records** element to fetch the amounts for multiple products, aggregate them, and check if the total exceeds zero.

0/9000

We tried to insert Opportunity records as part of the challenge check, but the insert failed. Error: thException: OPP_INSERT | System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ClosedOpportunityTrigger: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0 with id 00TWU0000002p852AA; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Trigger.ClosedOpportunityTrigger: line 13, column 1: []

 

I get this error on checking the Bulk Apex Trigger challenge in the Apex Triggers Badge. Reading the error, it seems the test script is inserting an opportunity with Id. Anyone else getting this error? My trigger is inserting tasks without any Id and works like a charm, even on newly created opportunity.

 

#Trailhead Challenges  #Trailhead

11 answers
  1. Jan 23, 2024, 3:31 PM

    Hi, @Yvonne Riemeijer

     

    Nothing to worry about, everything is fine. I also try to relax on weekends, but weekdays are busy with work.

    So, thank you for the provided trigger code. I ran it in my system and encountered a similar error.Hi, Nothing to worry about, everything is fine. I also try to relax on weekends, but weekdays are busy with work.So, thank you for the provided trigger code.I made some changes to it, and now everything is working. Please use this code, and the challenge will be completed.

    trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> tasksToCreate = new List<Task>();

    for(Opportunity oppty : Trigger.New) {

    if (oppty.StageName == 'Closed Won') {

    Task nwTask = new Task();

    nwTask.Subject = 'Follow Up Test Task';

    nwTask.WhatId = oppty.Id;

    tasksToCreate.add(nwTask);

    }

    }

    if (!tasksToCreate.isEmpty()){

    insert tasksToCreate;

    }

    }

    And, by the way, here's where the mistake was:

    It was necessary to simply write outside the loop:1.jpg2.jpg

    It was really interesting =)

     

    Sincerely,

    Mykhailo Vdovychenko

    Bringing Cloud Excellence with IBVCLOUD OÜ

0/9000
I faced issue  "We can't find an activated order that includes a 'FREE Bouquet' order item." in  Use Apex to Automate Business Processes  (Create and Test a Trigger) module but  i have already activated order include free bouquet.I faced issue
5 answers
  1. Khyati Mehta (Speridian Technologies) Forum Ambassador
    Jun 14, 2021, 4:57 AM
    Hi Apoorv,

     

    I am sure you would have followed the exact steps that are being provided in the Trailhead module. If not, then follow these steps:

     

    1)In the Path, click Activated.

     

    2)Click Mark as Current Status. You should see that the order has a new item, which has a unit price of $0. If you don’t see it, refresh your browser.

     

    And, if you have followed these steps, then try demarking the status and marking it again, it does work sometimes. Also, don't forget to refresh the page while demarking.

     

    Hope this helps!
0/9000

I'm not sure what I'm missing. I might've done something wrong.

 

Create Automation for Submitting Positions for Approval

Now that you’ve set up an approval process, continue to automate recruiting tasks by creating a flow that automatically submits new positions for approval.

Use Flow Builder to Create a New Automation

Use Flow Builder to set up the automation.

  1. From Setup, enter flows in the Quick Find box and select Flows.
  2. Click New Flow.
  3. Select Record-Triggered Flow and click Create.
  4. Enter and select Position for the Object.
  5. Select A record is created or updated in the Configure Trigger section.
  6. In the Condition Requirements, select All Conditions Are Met (AND).
  7. Click Add Condition until there are 5 field options available.
  8. Set the conditions.
  9.  
  10. FieldOperatorValue1. | Status__c | Equals | New
  11. 2. | Job_Description__c | Is Null | {!$GlobalConstant.False}
  12. 3. | Department__c | Is Null | {!$GlobalConstant.False}
  13. 4. | Education__c | Is Null | {!$GlobalConstant.False}
  14. 5. | Hiring_Manager__c | Is Null | {!$GlobalConstant.False}
  15. Select Only when a record is updated to meet the condition requirements in the When to Run the Flow for Updated Records section
  16. Ensure Actions and Related Records is selected.
  17. On the flow canvas, hover over and click to add an element.
  18. In the Add Element search box, enter action and select Action.
  19. Enter submit in search all actions… and select Submit for Approval.
  20. Fill in the details:
    • Label: Submit Position for Approval
    • For Record ID, select $Record > Id
  21. Click Done.
  22. Click the Submit Position for Approval action.
  23. Click Edit Element.
  24. Toggle the Approval Process Name Or ID to Include and select Submit_Position_for_Approval > entityId.
  25. Click Done.
  26. Click Save.
  27. Enter Submit New Positions for Approval for the Flow Label.
  28. Click Activate.
  29. Click to return to setup.

You’re almost done setting automating processes for the recruiting team. Move on to the final step, where you create another flow, but this time with radio buttons that interviewers can use to easily rate candidates.

 

Step not yet complete in Tutorial Trials Test The 'Submit New Positions for Approval' flow is not configured to trigger when a record is created or updated

The 'Submit New Positions for Approval' flow is not configured to trigger when a record is created or updated..png

 

 

#Trailhead Challenges

0/9000

 Could not find the required Chatter post when inserting a Communications record with Number__c set to 1;  

 

#Trailhead Challenges

2 answers
  1. Feb 8, 9:32 PM

    My daughter helped me find the answer. When setting up the Trigger, I had selected under Condition Requirements:

     

    "All Conditions Are Met (AND) instead of

    Any Condition Is Met (OR)

    It was as simple as that. 

0/9000

I am in the Add a Flow to Your Prompt Template part of the Quick Start: Create a Prompt Builder Flex Template the first time i tried to finish the test i received ID error: -561342874. i'll share a picture of it with this question, the second time i try to do the test it doesn't show me one of the steps (Template-Triggered Prompt Flow

can anyone give me a good reason why this is happening to me?

the testing environment having a lot of issues please help

 

 

test1.jpg

 

 

Untitled.jpg

 

is not shown in the steps  

 

#Trailhead Challenges

0/9000

When I test my code through the "Execute Anonymous Window", it seems to work fine.

When I check the challenge, I get this error.  I don't know what it means.

Developer script exception from State of Wyoming : ClosedOpportunityTrigger : ClosedOpportunityTrigger: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0 with id 00Tbm000004HLlhEAG; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id] Trigger.ClosedOpportunityTrigger: line 23, column 1

 

Challenge

Create a Bulk Apex trigger

Create a bulkified Apex trigger that adds a follow-up task to an opportunity if its stage is Closed Won. Fire the Apex trigger after inserting or updating an opportunity.

  • Create an Apex trigger:
    • Name: ClosedOpportunityTrigger
    • Object: Opportunity
    • Events: after insert and after update
    • Condition: Stage is Closed Won
    • Operation: Create a task:
      • Subject: Follow Up Test Task
      • WhatId: the opportunity ID (associates the task with the opportunity)
    • Bulkify the Apex trigger so that it can insert or update 200 or more opportunities

This is my code:

 

trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> taskList = new List<Task>();

    

    List<Opportunity> toProcess = null;

    

    switch on Trigger.operationType {

        when AFTER_INSERT {

        // All inserted Opportunity will need the Opportunity

            toProcess = Trigger.New;

        }

        // Check if the status has changed to Closed Won

        when AFTER_UPDATE {

            toProcess = [SELECT Id,StageName FROM Opportunity

                         WHERE Id IN :Trigger.New];

        }

    }

    for (Opportunity opp : toProcess) {

        // Add a default task for this opportunity

        system.debug('Opportunity: ' + opp.Id + 'StageName: ' + opp.StageName);

        If (opp.StageName == 'Closed Won') {

          taskList.add(new Task(Subject = 'Follow Up Test Task', WhatId = opp.Id));

    }

    if (taskList.size() > 0) {

        system.debug(taskList);

        insert taskList;

    }

  }

}

 

#Trailhead Challenges

3 answers
  1. Divya Chauhan (Kcloud Technologies) Forum Ambassador
    Jan 16, 6:26 AM

    Hello@Marlene Meiring,

    • Make sure you have saved the code
    • try,

    trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

    List<Task> taskList = new List <task>();

    for(Opportunity opp : Trigger.New){

    if(opp.StageName == 'Closed Won'){

    taskList.add(new Task(Subject = 'Follow Up Test Task', WhatId = opp.Id));

    }

    }

    if(taskList.size()>0){

    insert taskList;

    }

    }

0/9000
4 answers
  1. Jan 5, 6:29 PM

    Below code worked for me-:

     

    trigger ClosedOpportunityTrigger on Opportunity (after insert,after update) {

    list<Task> newTask= new list<Task>();

    for(Opportunity oppWon :[Select Id from Opportunity where StageName='Closed Won'

    and Id in: Trigger.new]){

    newTask.add(new Task (Subject ='Follow Up Test Task',WhatId=oppWon.Id));

    }

    if(newTask.size()>0){

    upsert newTask;

    }

    }

    make sure that 

    (a) you're using the correct trailhead org, 

    (b) you successfully saved the file (e.g. it didn't have a stray character that caused a compilation error), and 

    (c) you don't have any other triggers or processes that may interfere (e.g. validation rules). If you're still having problems, create a new Trailhead Org and copy the code fresh into that org.

     

     You can also raise a case with the trailhead support team

0/9000

Hello everyone,

 

I'm stuck on this last trail:

 

https://trailhead.salesforce.com/content/learn/projects/customize-a-salesforce-object/create-validation-rules-1?trailmix_creator_id=strailhead&trailmix_slug=prepare-for-your-salesforce-certified-associate-credential

 

I was already looking at Ask the Community here, I tried to make some suggestions like:

 

Disable the button to restrict the picklist

 

In the dependency field, select all options

 

Apart from the trail rule, there are no other active ones, not even triggers.

 

I even created a new playground just for the task and it gives the same error

 

"Step not yet complete in Org_Magdeson

An unexpected error occurred while inserting Opportunity records and we couldn't check your work. Make sure Opportunity records can be inserted in this org, and click "Check Challenge" again. If this continues, contact the Trailhead Help team."

 

I created a test opportunity and the rule worked correctly with the field dependencies.

 

Has anyone managed to do something else?

 

Thanks in advance!

 

#Trailhead Challenges

0/9000

When I check my challenge - I get the error message The trigger ClosedOpportunityTrigger is using events in the 'before' context. Make sure to use after insert and after update.

 

Here is my trigger below - So I don't understand why it's saying I'm using before context.  I've deleted this trigger once and re-made it only to receive the same error on submission 

 

trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {

List<Task> taskToUpdate = new List<Task>();

//get Opp Ids from Closed Won Opps

for(Opportunity opp : [SELECT ID FROM Opportunity WHERE StageName = 'Closed Won' IN :Trigger.New]) {

//create follow up task against IDS that are stored in opp variable

taskToUpdate.add(new Task(Subject = 'Follow up Test Task',

WhatID=opp.ID));

}

insert taskToUpdate;

}

2 answers
0/9000