• Punima Sharma
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi, 
I am not able to complete Trailhead:Bulk Apex Triggers challenge ,I am facing  issue ' Challenge not yet complete... here's what's wrong: 
                                               Executing against the trigger does not work as expected'.  Debug logs are also not descriptive like error message.

Code :

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

    List<Task> tasks = new List<Task>();
     
    for (Opportunity opp: Trigger.New) {
        If (Trigger.isUpdate){
        if(opp.StageName!=trigger.oldMap.get(opp.Id).stageName && opp.StageName == 'Closed Won'){
            tasks.add(new Task(Subject = 'Follow Up Test Task',WhatId = opp.Id)) ;
        }
    } 
   
    If (Trigger.isInsert){
        if(opp.StageName == 'Closed Won'){
            tasks.add(new Task(Subject = 'Follow Up Test Task',WhatId = opp.Id)) ;
        } 
    } 
}    
    if (tasks.size()< 0){
        insert tasks;
    }
}
I have no workflow,flow or powerbuilder process related to opportunity.

P.S.
I have followed suggestion of other users (Chris Edwards and Sandeep Bhanot) which they have posted  in a similar post but in my case this issue is not fixed.
 
Hi, 
I am not able to complete Trailhead:Bulk Apex Triggers challenge ,I am facing  issue ' Challenge not yet complete... here's what's wrong: 
                                               Executing against the trigger does not work as expected'.  Debug logs are also not descriptive like error message.

Code :

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

    List<Task> tasks = new List<Task>();
     
    for (Opportunity opp: Trigger.New) {
        If (Trigger.isUpdate){
        if(opp.StageName!=trigger.oldMap.get(opp.Id).stageName && opp.StageName == 'Closed Won'){
            tasks.add(new Task(Subject = 'Follow Up Test Task',WhatId = opp.Id)) ;
        }
    } 
   
    If (Trigger.isInsert){
        if(opp.StageName == 'Closed Won'){
            tasks.add(new Task(Subject = 'Follow Up Test Task',WhatId = opp.Id)) ;
        } 
    } 
}    
    if (tasks.size()< 0){
        insert tasks;
    }
}
I have no workflow,flow or powerbuilder process related to opportunity.

P.S.
I have followed suggestion of other users (Chris Edwards and Sandeep Bhanot) which they have posted  in a similar post but in my case this issue is not fixed.
 
On the getting started with APEX, I cannot complete the challange and I am receiving the following error:
 
Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.

But in the Debug Execute Anonymous Window, I can successfully run the code.  Here is the code used in the Anonymous window.

List<String> rtnStr = StringArrayTest.generateStringArray(4);
System.debug(rtnStr);
System.debug('rtnstr.size='+rtnstr.size());
As prevously said, if I do a Check Challange from the trailhead module I recieve the error.  In looking at the log there are two suspicious lines.
18:53:07:031 EXCEPTION_THROWN [1]|System.AssertException: Assertion Failed: Expected: Test 1, Actual: Test 0
18:53:07:031 FATAL_ERROR System.AssertException: Assertion Failed: Expected: Test 1, Actual: Test 0  
Can anyone help with this.  Adding a test case did not remedy the problem but I may have done something wrong there.  

And here is my code:
public class StringArrayTest {

    public static String[] generateStringArray(Integer count){
        List<String> mylist = new List<String>();
        for (Integer i=1; i<=count; i++) {
            String myStr = 'Test '  + i;
            System.Debug('Created '+ myStr);
            mylist.add(myStr);
        }
        System.debug('Completed!');
        return mylist;
    }

}

Question is:  Should I have to have a test case to complete this challange or have I got something else wrong?

TIA for your help
ux5
  • July 30, 2015
  • Like
  • 0
Hi All,

Below are the requirements to complete Challenge

The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.


I have created new custom Checkbox(MatchBillingAddress) and Below is my trigger:

trigger AccountAddressTrigger on Account (before update,before insert)
{
   List<Account> list1=[SELECT Id,Match_Billing_Address__c,ShippingPostalCode,BillingPostalCode from Account];
  for(Integer i=0;i<list1.size();i++)
   {
    if(list1[i].Match_Billing_Address__c=true && list1[i].BillingPostalCode!=NULL)
    {
    list1[i].ShippingPostalCode=list1[i].BillingPostalCode;
    update list1[i];
    }
   }
  }

I got Error like : Executing the trigger did not work as expected.

Can anyone please help me to achieve this. Thanks