• Ben Myhre
  • NEWBIE
  • 20 Points
  • Member since 2016
  • Sundog


  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
Developer Intermediate > Lightning Components > Using JavaScript Controllers With Components

Here is the Component:

<aura:component >
    <aura:attribute name="total" type="Integer" default="0"/>
    <ui:inputNumber aura:id="inputOne" label="Enter 1"/>
    <ui:inputNumber aura:id="inputTwo" label="Enter 2"/>
    <ui:inputNumber aura:id="inputThree" label="Enter 3"/>
    
    <ui:button label="Submit" press="{!c.calculate}"/>
    <ui:outputNumber aura:id="totalValue" value="{!v.total}"/>
</aura:component>

Here is the Controller:

({
    calculate : function(component, event, helper) {
        var inputOne = parseInt(component.find("inputOne").get("v.value"));

        var inputTwo = parseInt(component.find("inputTwo").get("v.value"));
        var inputThree = parseInt(component.find("inputThree").get("v.value"));
        var total = inputOne + inputTwo - inputThree;
        if (isNaN(total)){
            component.set("v.errors", [{message:"Total not a number: " + total}]);
        } else {
            component.set("v.total", total);
        }
    }
})

The error it gives me is "Challenge Not yet complete... here's what's wrong: 
The client side controller does not set a value for the outputNumber component".... BUT based on when I plig this into an app and run it, it sure appeas that the value for outputNumber is being set.

Any help would be appreciated.
  1. I created a visual force page and then enabled it for mobile apps. I verified that this exists and is enabled.
  2. Build> Create> Global Action I added a new Global Action, action type "Custom Visualforce" and label "Quick Account" This is saved
  3. Create > Global Action > Publisher Layout. There is only one. I override the default for SF one and added "Quick Account" for sf1 experience and saved
  4. The action does not show up at all on sf 1. I logged out and back in several times. Am I missing a step?
I think that I am meeting all of the criteria for this to pass, but when I submit the challenge it gives the following:

Challenge Not yet complete... here's what's wrong: 
Case records were not returned upon calling 'getNewCases'. Either the method does not exist, or it does not return the expected list of cases

Here is the challenge

Create a Visualforce page that uses a custom controller to display a list of cases with the status of 'New'.
  • The page must be named 'NewCaseList'.
  • The custom controller Apex class must be named 'NewCaseListController'.
  • The 'NewCaseListController' Apex class must have a publically scoped method named 'getNewCases'.
  • The 'getNewCases' Apex method should have the return type of 'List' and return a list of case records with the ID and CaseNumber fields and filtered to only have a status of 'New'.
  • The 'NewCaseList' Visualforce page must use an apex:repeat component which is bound to 'newCases'.
  • The apex:repeat component must refer to the var attribute as 'case'.
  • Within the apex:repeat component, bind a apex:outputLink component to the ID of the case so that the page directs the user to the detail page of the respective case record.
Here is my page:
 
<apex:page controller="NewCaseListController">
    <apex:form >
        <apex:pageBlock title="Cases List" id="cases_list">
            
        <!-- Contacts List -->
        <apex:repeat value="{! newCases }" var="case">
            <p>
            	<apex:outputLink value="/{! case.Id }">{!case.CaseNumber}
            	</apex:outputLink> 
            </p>
        
            
        </apex:repeat>

        </apex:pageBlock>
    </apex:form>
</apex:page>

Here is my controller:
 
public class NewCaseListController {
    public static List<Case> getNewCases(){
        List<Case> cases = [SELECT Id, CaseNumber
                           FROM CASE
                           WHERE Status = 'New'];
    	return cases;
    }

}

What am I doing wrong on this? When I preview the page, it seems to be displaying what I would expect. If I change a status from new to something else, it disappears. 
This is the challenge:

To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of 'Closed Won'. The task's subject must be 'Follow Up Test Task'.
- The Apex trigger must be called 'ClosedOpportunityTrigger'
- With 'ClosedOpportunityTrigger' active, if an opportunity is inserted or updated with a stage of 'Closed Won', it will have a task created with the subject 'Follow Up Test Task'.
 - To associate the task with the opportunity, fill the 'WhatId' field with the opportunity ID.
- This challenge specifically tests 200 records in one operation.

Here is my code:
trigger ClosedOpportunityTrigger on Opportunity (before insert, before update) {
    List<Opportunity> opportunities = [SELECT Id, StageName
                                       FROM Opportunity
                                       WHERE Id
                                       IN :Trigger.New];
	List<Task> tasksToUpdate = new List<Task>();
    System.debug('##### OPS' + opportunities);
    for(Opportunity o : opportunities){
        System.debug('##### ' + o.StageName);
        if(o.StageName == 'Closed Won'){
            Task thisTask = new Task(WhatId = o.Id, Subject = 'Follow Up Test Task');
            tasksToUpdate.add(thisTask);
            System.debug('##### ' + tasksToUpdate);
        }
    }
    insert tasksToUpdate;
}

When I try to validate through trailhead, it gives a "Challenge Not yet complete... here's what's wrong: 
Executing against the trigger does not work as expected." error.

I added some debug print and it seems to show that the soql statement just does not pull any results, so it does not enter the if statement. It seems a pretty straightforward soql statement to me, but I must be missing something. This happens no matter if I add or update an item.

Thanks in advance
 
Developer Intermediate > Lightning Components > Using JavaScript Controllers With Components

Here is the Component:

<aura:component >
    <aura:attribute name="total" type="Integer" default="0"/>
    <ui:inputNumber aura:id="inputOne" label="Enter 1"/>
    <ui:inputNumber aura:id="inputTwo" label="Enter 2"/>
    <ui:inputNumber aura:id="inputThree" label="Enter 3"/>
    
    <ui:button label="Submit" press="{!c.calculate}"/>
    <ui:outputNumber aura:id="totalValue" value="{!v.total}"/>
</aura:component>

Here is the Controller:

({
    calculate : function(component, event, helper) {
        var inputOne = parseInt(component.find("inputOne").get("v.value"));

        var inputTwo = parseInt(component.find("inputTwo").get("v.value"));
        var inputThree = parseInt(component.find("inputThree").get("v.value"));
        var total = inputOne + inputTwo - inputThree;
        if (isNaN(total)){
            component.set("v.errors", [{message:"Total not a number: " + total}]);
        } else {
            component.set("v.total", total);
        }
    }
})

The error it gives me is "Challenge Not yet complete... here's what's wrong: 
The client side controller does not set a value for the outputNumber component".... BUT based on when I plig this into an app and run it, it sure appeas that the value for outputNumber is being set.

Any help would be appreciated.
Developer Intermediate > Lightning Components > Using JavaScript Controllers With Components

Here is the Component:

<aura:component >
    <aura:attribute name="total" type="Integer" default="0"/>
    <ui:inputNumber aura:id="inputOne" label="Enter 1"/>
    <ui:inputNumber aura:id="inputTwo" label="Enter 2"/>
    <ui:inputNumber aura:id="inputThree" label="Enter 3"/>
    
    <ui:button label="Submit" press="{!c.calculate}"/>
    <ui:outputNumber aura:id="totalValue" value="{!v.total}"/>
</aura:component>

Here is the Controller:

({
    calculate : function(component, event, helper) {
        var inputOne = parseInt(component.find("inputOne").get("v.value"));

        var inputTwo = parseInt(component.find("inputTwo").get("v.value"));
        var inputThree = parseInt(component.find("inputThree").get("v.value"));
        var total = inputOne + inputTwo - inputThree;
        if (isNaN(total)){
            component.set("v.errors", [{message:"Total not a number: " + total}]);
        } else {
            component.set("v.total", total);
        }
    }
})

The error it gives me is "Challenge Not yet complete... here's what's wrong: 
The client side controller does not set a value for the outputNumber component".... BUT based on when I plig this into an app and run it, it sure appeas that the value for outputNumber is being set.

Any help would be appreciated.
This is the challenge:

To complete this challenge, you need to add a trigger for Opportunity. The trigger will add a task to any opportunity inserted or updated with the stage of 'Closed Won'. The task's subject must be 'Follow Up Test Task'.
- The Apex trigger must be called 'ClosedOpportunityTrigger'
- With 'ClosedOpportunityTrigger' active, if an opportunity is inserted or updated with a stage of 'Closed Won', it will have a task created with the subject 'Follow Up Test Task'.
 - To associate the task with the opportunity, fill the 'WhatId' field with the opportunity ID.
- This challenge specifically tests 200 records in one operation.

Here is my code:
trigger ClosedOpportunityTrigger on Opportunity (before insert, before update) {
    List<Opportunity> opportunities = [SELECT Id, StageName
                                       FROM Opportunity
                                       WHERE Id
                                       IN :Trigger.New];
	List<Task> tasksToUpdate = new List<Task>();
    System.debug('##### OPS' + opportunities);
    for(Opportunity o : opportunities){
        System.debug('##### ' + o.StageName);
        if(o.StageName == 'Closed Won'){
            Task thisTask = new Task(WhatId = o.Id, Subject = 'Follow Up Test Task');
            tasksToUpdate.add(thisTask);
            System.debug('##### ' + tasksToUpdate);
        }
    }
    insert tasksToUpdate;
}

When I try to validate through trailhead, it gives a "Challenge Not yet complete... here's what's wrong: 
Executing against the trigger does not work as expected." error.

I added some debug print and it seems to show that the soql statement just does not pull any results, so it does not enter the if statement. It seems a pretty straightforward soql statement to me, but I must be missing something. This happens no matter if I add or update an item.

Thanks in advance