• Nitika Semwal 11
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 8
    Replies
Hello SFDC developers, 
I am getting error in running code from lightning developer guide book Page no 115- error. c:quickContact$Controller$doInit[Invalid Key c:getAccount], faling descriptor. What I am missing? Please guide. 

code-
quickContact.cmp
<aura:component controller="QuickContactController"
implements="force:lightningQuickActionWithoutHeader,force:hasRecordId">
<aura:attribute name="account" type="Account" />
<aura:attribute name="newContact" type="Contact"
default="{ 'sobjectType': 'Contact' }" /> <!-- default to empty record -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!-- Display a header with details about the account -->
<div class="slds-page-header" role="banner">
<p class="slds-text-heading--label">{!v.account.Name}</p>
<h1 class="slds-page-header__title slds-m-right--small
slds-truncate slds-align-left">Create New Contact</h1>
</div>
<!-- Display the new contact form -->
<lightning:input aura:id="contactField" name="firstName" label="First Name"
value="{!v.newContact.FirstName}" required="true"/>
<lightning:input aura:id="contactField" name="lastname" label="Last Name"value="{!v.newContact.LastName}" required="true"/>
<lightning:input aura:id="contactField" name="title" label="Title"
value="{!v.newContact.Title}" />
<lightning:input aura:id="contactField" type="phone" name="phone" label="Phone
Number"
pattern="^(1?(-?\d{3})-?)?(\d{3})(-?\d{4})$"
messageWhenPatternMismatch="The phone number must contain 7, 10,
or 11 digits. Hyphens are optional."
value="{!v.newContact.Phone}" required="true"/>
<lightning:input aura:id="contactField" type="email" name="email" label="Email"
value="{!v.newContact.Email}" />
<lightning:button label="Cancel" onclick="{!c.handleCancel}"
class="slds-m-top--medium" />
<lightning:button label="Save Contact" onclick="{!c.handleSaveContact}"
variant="brand" class="slds-m-top--medium"/>
</aura:component>
quickContactController.js
({
doInit : function(component, event, helper) {
// Prepare the action to load account record
var action = component.get("c.getAccount");
action.setParams({"accountId": component.get("v.recordId")});
// Configure response handler
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS") {
component.set("v.account", response.getReturnValue());
} else {
console.log('Problem getting account, response state: ' + state);
}
});
$A.enqueueAction(action);
},
handleSaveContact: function(component, event, helper) {
if(helper.validateContactForm(component)) {
// Prepare the action to create the new contact
var saveContactAction = component.get("c.saveContactWithAccount");
saveContactAction.setParams({
"contact": component.get("v.newContact"),
"accountId": component.get("v.recordId")
});
// Configure the response handler for the action
saveContactAction.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS") {
// Prepare a toast UI message
var resultsToast = $A.get("e.force:showToast");
resultsToast.setParams({
"title": "Contact Saved",
"message": "The new contact was created."
});
// Update the UI: close panel, show toast, refresh account page
$A.get("e.force:closeQuickAction").fire();
resultsToast.fire();
$A.get("e.force:refreshView").fire();
}
else if (state === "ERROR") {
console.log('Problem saving contact, response state: ' + state);
}
else {
console.log('Unknown problem, response state: ' + state);
}
});
// Send the request to create the new contact
$A.enqueueAction(saveContactAction);
}
},
handleCancel: function(component, event, helper) {
$A.get("e.force:closeQuickAction").fire();
}
})

quickContactHelper.js
({
validateContactForm: function(component) {
var validContact = true;
// Show error messages if required fields are blank
var allValid = component.find('contactField').reduce(function (validFields,
inputCmp) {
inputCmp.showHelpMessageIfInvalid();
return validFields && inputCmp.get('v.validity').valid;
}, true);
if (allValid) {
// Verify we have an account to attach it to
var account = component.get("v.account");
if($A.util.isEmpty(account)) {
validContact = false;
console.log("Quick action context doesn't have a valid account.");
}
return(validContact);
}
}
})
QuickContactController.apxc
public with sharing class QuickContactController {
@AuraEnabled
public static Account getAccount(Id accountId) {
// Perform isAccessible() checks here
return [SELECT Name, BillingCity, BillingState FROM Account WHERE Id =
:accountId];
}
@AuraEnabled
public static Contact saveContactWithAccount(Contact contact, Id accountId) {
// Perform isAccessible() and isUpdateable() checks here
contact.AccountId = accountId;
upsert contact;
return contact;
}
}
This code worked- 
<aura:component >
    
    <aura:attribute name="item" type="Camping_Item__c" required="True" />
    
    <p>Name:
        <ui:outputText value="{!v.item.Name}"/></p>
    
    <p> Price:
        <lightning:formattedNumber value="{!v.item.Price__c}" style="currency"/>   </p> 
    <p>Quantity:
        <lightning:formattedNumber value="{!v.item.Quantity__c}" style="number"/></p>
    <p> 
        <lightning:input type="toggle" label="Packed?" checked="{!v.item.Packed__c}"/> </p>
        
</aura:component>
Hi All, 

Im trying to do the second challenge in App Customization  but am getting some Super badge am getting the error "Challenge Not yet complete... here's what's wrong:  Couldn’t find the 'Volunteer Shift' relationship field or it is not configured correctly."
Please, anyone, can anyone tell me which relationships should be created between these objects? I have created a master-detail relationship between them. 
User-added image

Also, am not clear with this "Shifts with cascading delete and the option of roll-up summary fields." 

Thank you and any help is appreciated.
Thank you in advance. 
Hello SFDC developers, 
I am getting error in running code from lightning developer guide book Page no 115- error. c:quickContact$Controller$doInit[Invalid Key c:getAccount], faling descriptor. What I am missing? Please guide. 

code-
quickContact.cmp
<aura:component controller="QuickContactController"
implements="force:lightningQuickActionWithoutHeader,force:hasRecordId">
<aura:attribute name="account" type="Account" />
<aura:attribute name="newContact" type="Contact"
default="{ 'sobjectType': 'Contact' }" /> <!-- default to empty record -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!-- Display a header with details about the account -->
<div class="slds-page-header" role="banner">
<p class="slds-text-heading--label">{!v.account.Name}</p>
<h1 class="slds-page-header__title slds-m-right--small
slds-truncate slds-align-left">Create New Contact</h1>
</div>
<!-- Display the new contact form -->
<lightning:input aura:id="contactField" name="firstName" label="First Name"
value="{!v.newContact.FirstName}" required="true"/>
<lightning:input aura:id="contactField" name="lastname" label="Last Name"value="{!v.newContact.LastName}" required="true"/>
<lightning:input aura:id="contactField" name="title" label="Title"
value="{!v.newContact.Title}" />
<lightning:input aura:id="contactField" type="phone" name="phone" label="Phone
Number"
pattern="^(1?(-?\d{3})-?)?(\d{3})(-?\d{4})$"
messageWhenPatternMismatch="The phone number must contain 7, 10,
or 11 digits. Hyphens are optional."
value="{!v.newContact.Phone}" required="true"/>
<lightning:input aura:id="contactField" type="email" name="email" label="Email"
value="{!v.newContact.Email}" />
<lightning:button label="Cancel" onclick="{!c.handleCancel}"
class="slds-m-top--medium" />
<lightning:button label="Save Contact" onclick="{!c.handleSaveContact}"
variant="brand" class="slds-m-top--medium"/>
</aura:component>
quickContactController.js
({
doInit : function(component, event, helper) {
// Prepare the action to load account record
var action = component.get("c.getAccount");
action.setParams({"accountId": component.get("v.recordId")});
// Configure response handler
action.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS") {
component.set("v.account", response.getReturnValue());
} else {
console.log('Problem getting account, response state: ' + state);
}
});
$A.enqueueAction(action);
},
handleSaveContact: function(component, event, helper) {
if(helper.validateContactForm(component)) {
// Prepare the action to create the new contact
var saveContactAction = component.get("c.saveContactWithAccount");
saveContactAction.setParams({
"contact": component.get("v.newContact"),
"accountId": component.get("v.recordId")
});
// Configure the response handler for the action
saveContactAction.setCallback(this, function(response) {
var state = response.getState();
if(state === "SUCCESS") {
// Prepare a toast UI message
var resultsToast = $A.get("e.force:showToast");
resultsToast.setParams({
"title": "Contact Saved",
"message": "The new contact was created."
});
// Update the UI: close panel, show toast, refresh account page
$A.get("e.force:closeQuickAction").fire();
resultsToast.fire();
$A.get("e.force:refreshView").fire();
}
else if (state === "ERROR") {
console.log('Problem saving contact, response state: ' + state);
}
else {
console.log('Unknown problem, response state: ' + state);
}
});
// Send the request to create the new contact
$A.enqueueAction(saveContactAction);
}
},
handleCancel: function(component, event, helper) {
$A.get("e.force:closeQuickAction").fire();
}
})

quickContactHelper.js
({
validateContactForm: function(component) {
var validContact = true;
// Show error messages if required fields are blank
var allValid = component.find('contactField').reduce(function (validFields,
inputCmp) {
inputCmp.showHelpMessageIfInvalid();
return validFields && inputCmp.get('v.validity').valid;
}, true);
if (allValid) {
// Verify we have an account to attach it to
var account = component.get("v.account");
if($A.util.isEmpty(account)) {
validContact = false;
console.log("Quick action context doesn't have a valid account.");
}
return(validContact);
}
}
})
QuickContactController.apxc
public with sharing class QuickContactController {
@AuraEnabled
public static Account getAccount(Id accountId) {
// Perform isAccessible() checks here
return [SELECT Name, BillingCity, BillingState FROM Account WHERE Id =
:accountId];
}
@AuraEnabled
public static Contact saveContactWithAccount(Contact contact, Id accountId) {
// Perform isAccessible() and isUpdateable() checks here
contact.AccountId = accountId;
upsert contact;
return contact;
}
}
This code worked- 
<aura:component >
    
    <aura:attribute name="item" type="Camping_Item__c" required="True" />
    
    <p>Name:
        <ui:outputText value="{!v.item.Name}"/></p>
    
    <p> Price:
        <lightning:formattedNumber value="{!v.item.Price__c}" style="currency"/>   </p> 
    <p>Quantity:
        <lightning:formattedNumber value="{!v.item.Quantity__c}" style="number"/></p>
    <p> 
        <lightning:input type="toggle" label="Packed?" checked="{!v.item.Packed__c}"/> </p>
        
</aura:component>
I'm struggling with the custom lightning component on this part. I don't have much background coding and am having trouble finding resources to help me achieve coding the lightning component. If someone could help give me some framework code to create a custom lightning component to hold a URL or direct me to a resource that help break this down I'd be very appreciative.
 
I am facing another issue on this superbadge, specifically in Challenge #10, i am getting the following error:
The Campaign Influence Lightning report must have the correct 1. Aggregate, 2. Columns, 3. Groupings, and 4. Filter.

The requirements have no mention about what fields, groupings, filters, aggregates to include in the report. What am I missing?
I am new to Visualforce and I am doing the Trailhead: Visualforce Basics Module - Use Standard Controllers.  The instructions state:
To preview your page in the context of Lightning Experience, open your browser’s developer console and enter:
$A.get("e.force:navigateToURL").setParams(
    {"url": "/apex/pageName"}).fire();
I am not sure where to enter this.  When I enter it in the Visualforce page the text just show up on the Visualforce page preview.  I must be missing something.  Any help will be greatly appreciated.
 

This is the trailhead challenge I'm working on.
Create a report of Opportunities grouped by Type. Then follow the dashboard and share a snapshot on Chatter.
Name the report 'Opportunities by Type' and save it to the 'Unfiled Public Reports' folder.
The report must be of type Opportunities.
The report format must be a Summary report.
The report must be grouped by 'Type'.
The date range should be for All Time.
You can include any columns you like, but must include 'Amount' as one of the columns.
Create a dashboard named 'Opportunities Dashboard' and save it to the 'My Personal Dashboards' folder.
Create a dashboard component on the dashboard using the report you just created.
Set the header to 'Opptys by Type' and the title to 'For all time' for the dashboard component.
Use the horizontal bar chart dashboard component, and ensure the record count is displayed on the x-axis.
Follow the 'Opportunities Dashboard' dashboard in Chatter. Make sure that Feed Tracking is enabled for Dashboards first.
Post a snapshot of the 'Opptys by Type' dashboard component to Dashboard Chatter feed.

But I'm getting the following error when I check if the challenge has been completed
Challenge Not yet complete... here's what's wrong: 
The dashboard snapshot post to Chatter was not found.
Can someone hepl me?
If possible post the snapshots?