-
ChatterFeed
-
0Best Answers
-
3Likes Received
-
0Likes Given
-
7Questions
-
10Replies
Getting Errors in Lightning Experience Spring '17
Keep getting this error below in the App Manager panel and have been seeing werid behavior in other places. Some apps I did for trailheads no longer function correctly either, some produce Aura.loadComponent(): Failed to initialize application errors while others are not displaying any data.
Uncaught TypeError: Cannot read property 'b' of null throws at https://geowil-dev-ed.lightning.force.com/auraFW/javascript/hS-U-Sm-fapuqhqczmdv5g/aura_prod.js:345:219
Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 1999217911-47099 (713029975)
Uncaught TypeError: Cannot read property 'b' of null throws at https://geowil-dev-ed.lightning.force.com/auraFW/javascript/hS-U-Sm-fapuqhqczmdv5g/aura_prod.js:345:219
Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 1999217911-47099 (713029975)
- George Williams
- February 07, 2017
- Like
- 0
- Continue reading or reply
Quick Start: Lightning Components Broken
For whatever reason the Lightning app built during the above Trailhead project does not work when previewed. I keep getting this error:
This page has an error. You might just need to refresh it. Error during init [Cannot read property 'apply' of undefined]
No issues with the project chanllenges, in fact I have completed the project trail. Checked my code, exact same as given during the project steps.
This page has an error. You might just need to refresh it. Error during init [Cannot read property 'apply' of undefined]
No issues with the project chanllenges, in fact I have completed the project trail. Checked my code, exact same as given during the project steps.
- George Williams
- January 30, 2017
- Like
- 0
- Continue reading or reply
Connect to Salesforce with Server-Side Controllers - No doInit in JavaScript Controller Error
I am running into an issue getting the challenge to pass. Everything is working correctly but for whatever reason Trailhead cannot see the doInit function in my JS controller. Here is all of my code:
CampingList.cmp:
CampingList JS Controller:
CampingList JS Helper:
CampingListController:
Full error from the challenge:
Challenge Not yet complete... here's what's wrong:
The campingList JavaScript controller doesn't have a 'doInit' function or doesn't call the Apex controller to get items from the database.
CampingList.cmp:
<aura:component controller="CampingListController"> <aura:attribute type="Camping_Item__c[]" name="items"/> <aura:attribute type="Camping_Item__c" name="newItem" default="{ 'sobjectType': 'Camping_Item__c', 'Quantity__c': 0, 'Price__c': '0'}"/> <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> <div aria-labelledby="campItemForm"> <!-- BOXED AREA --> <fieldset class="slds-box slds-theme--default slds-container--small"> <legend id="campItemForm" class="slds-text-heading--small slds-p-vertical--medium"> Add Expense </legend> <!-- CREATE NEW EXPENSE FORM --> <form class="slds-form--stacked"> <div class="slds-form-element slds-is-required"> <div class="slds-form-element__control"> <ui:inputText aura:id="cmpLstItmName" label="Name" class="slds-input" labelClass="slds-form-element__label" value="{!v.newItem.Name}" required="true"/> </div> </div> <div class="slds-form-element slds-is-required"> <div class="slds-form-element__control"> <ui:inputNumber aura:id="cmpLstItmQty" label="Quantity" class="slds-input" labelClass="slds-form-element__label" value="{!v.newItem.Quantity__c}" required="true"/> </div> </div> <div class="slds-form-element slds-is-required"> <div class="slds-form-element__control"> <ui:inputCurrency aura:id="cmpLstItmPrice" label="Price" class="slds-input" labelClass="slds-form-element__label" value="{!v.newItem.Price__c}" placeholder="0.00" required="true"/> </div> </div> <div class="slds-form-element"> <ui:inputCheckbox aura:id="cmpLstItmPacked" label="Packed?" class="slds-checkbox" labelClass="slds-form-element__label" value="{!v.newItem.Packed__c}"/> </div> <div class="slds-form-element"> <ui:button label="Create Camping List Item" class="slds-button slds-button--brand" press="{!c.clickCreateCmpLstItem}"/> </div> </form> <!-- / CREATE NEW EXPENSE FORM --> </fieldset> <!-- / BOXED AREA --> </div> <!-- / CREATE NEW EXPENSE --> <div class="slds-card slds-p-top--medium"> <header class="slds-card__header"> <h3 class="slds-text-heading--small">Camping Items</h3> </header> <section class="slds-card__body"> <div id="list" class="row"> <aura:iteration items="{!v.items}" var="item"> <c:CampingListItem item="{!item}"/> </aura:iteration> </div> </section> </div> </aura:component>
CampingList JS Controller:
({ doInit : function(component, event, helper){ var action = component.get("c.getItems"); //console.log('loading data'); action.setCallback(this,function(response){ var respState = response.getState(); if (component.isValid() && respState == "SUCCESS"){ //console.log(response.getReturnValue()); helper.controllerHelper(component,response.getReturnValue()); } else if (respState == "ERROR"){ } }); $A.enqueueAction(loadData); }, clickCreateCmpLstItem : function(component, event, helper) { if (helper.validateForm(component)){ helper.createItem(component); } } })
CampingList JS Helper:
({ controllerHelper : function(component,cmpItmList){ component.set('v.items',cmpItmList); }, createItem : function(component){ var action = component.get("c.saveItem"); var items = component.get("v.items"); var allItems = items; allItems.push(component.get("v.newItem")); var campItems = JSON.stringify(allItems); action.setParams({"cmpItms": campItems}); action.setCallback(this,function(response){ var respState = response.getState(); if (component.isValid() && respState == "SUCCESS"){ component.set("v.items",response.getReturnValue()); } else if (respState == "ERROR"){ } }); $A.enqueueAction(action); }, validateForm : function(component){ var isValid = true; var cmpItmName = component.find("cmpLstItmName"); var itmName = cmpItmName.get('v.value'); var cmpItmQty = component.find("cmpLstItmQty"); var itmQty = cmpItmQty.get('v.value'); var cmpItmPrc = component.find("cmpLstItmPrice"); var itmPrc = cmpItmPrc.get('v.value'); var cmpItmPked = component.find("cmpLstItmPacked"); var itmPked = cmpItmPked.get('v.value'); if ($A.util.isEmpty(itmName)){ isValid = false; cmpItmName.set("v.errors", [{message:"Item name can't be blank."}]); } else{ cmpItmName.set("v.errors", null); } if ($A.util.isEmpty(cmpItmQty)){ isValid = false; cmpItmQty.set("v.errors", [{message:"Item amount can't be blank."}]); } else{ cmpItmQty.set("v.errors", null); } if ($A.util.isEmpty(cmpItmPrc)){ isValid = false; cmpItmPrc.set("v.errors", [{message:"Item price can't be blank."}]); } else{ cmpItmPrc.set("v.errors", null); } if (isValid){ return true; } else{ return false; } } })
CampingListController:
public with sharing class CampingListController { public static Map<String,Schema.SObjectField> schemaMap; public static String[] campItmFlds; public CampingListController(){ } public static void setupFLSCheck(){ campItmFlds = new String[] {'Id','Name','Quantity__c','Price__c','Packed__c'}; schemaMap = Schema.SObjectType.Camping_Item__c.fields.getMap(); } @auraenabled public static List<Camping_Item__c> getItems(){ setupFLSCheck(); for (String fld : campItmFlds){ if (!schemaMap.get(fld).getDescribe().isAccessible()){ // Check if the user has access to view field throwError('You do not have access to the '+fld+ ' field on the Camping_Item__c object.' ); //Send error to client return null; // Suppress editor logs } } return [select ID,Name,Quantity__c,Price__c,Packed__c from Camping_Item__c]; } @auraenabled public static List<Camping_Item__c> saveItem(Camping_Item__c item){ return new List<Camping_Item__c>{item}; } @auraenabled public static List<Camping_Item__c> saveItem(String cmpItms){ setupFLSCheck(); List<SObject> cmpItms2 = convertJSONToListOfSObject(cmpItms); List<Camping_Item__c> cmpitms3= new List<Camping_Item__c>(); for (SObject so : cmpItms2){ cmpitms3.add((Camping_Item__c)so); } for (Camping_Item__c cItem : cmpitms3){ System.debug('Camp Item: ' + cItem.Name); System.debug('Camp Id: ' + cItem.Id); } for (String fld : campItmFlds){ if (!schemaMap.get(fld).getDescribe().isAccessible()){ // Check if the user has access to view field throwError('You do not have access to the '+fld+ ' field on the Camping_Item__c object.' ); return null; // Suppress editor logs } else if (!schemaMap.get(fld).getDescribe().isUpdateable() && fld != 'Id'){ throwError('You cannot update the '+fld+' field on the Camping_Item__c object.'); return null; } } upsert cmpItms3; return cmpItms3; } public static void throwError(string errMsg){ try{ throw new AuraHandledException(errMsg); } catch(Exception e){ system.debug(e.getMessage()); } } private static List<SObject> convertJSONToListOfSObject(String json) { Object[] values = (Object[])System.JSON.deserializeUntyped(json); List<SObject> newSObjectsList = new List<SObject>(); for (Object v : values) { Map<String, Object> m = (Map<String, Object>)v; Schema.SObjectType targetType = Schema.getGlobalDescribe().get('Camping_Item__c'); SObject o = targetType.newSObject(); Map<String, Schema.SObjectField> fields = targetType.getDescribe().fields.getMap(); for (String fieldName : m.keySet()) { // Filter out any psuedo fields such as LastNameLocal Schema.SObjectField fi = fields.get(fieldName); if (fi != null) { if (fi.getDescribe().isCreateable() && fi.getDescribe().isUpdateable() && fieldName != 'Id') { if(fieldName == 'Price__c'){ String prcStr = String.valueOf(m.get(fieldName)); o.put(fieldName,Decimal.valueOf(prcStr)); } else{ o.put(fieldName, m.get(fieldName)); } } } } newSObjectsList.add(o); } return newSObjectsList; } }
Full error from the challenge:
Challenge Not yet complete... here's what's wrong:
The campingList JavaScript controller doesn't have a 'doInit' function or doesn't call the Apex controller to get items from the database.
- George Williams
- January 06, 2017
- Like
- 0
- Continue reading or reply
Unit tests pass but are not displayed in code coverage
I have been running into a problem during unit testing over the last few months where for whatever reason some tests mysteriously disappear from the code coverage drop down list after they finish running. This happens with both re-run tests and new tests either started from the developer console or the Apex Test Execution page. As an example I have been trying to run 25 tests on a controller today but even though all 25 tests are passing only 9 of them are being used in the code coverage caluclations in the developers console.
I have Parrallel Testing disabled, I have tried clearing the test history and test data. I have tried creating new workspaces, and I have tried re-saving my test class then running the test. I have even tried deleting Chrome's history and saved data. None of these has fixed the issue.
Does any one have additional advice or know of any existing open bugs that might be causing this?
I have Parrallel Testing disabled, I have tried clearing the test history and test data. I have tried creating new workspaces, and I have tried re-saving my test class then running the test. I have even tried deleting Chrome's history and saved data. None of these has fixed the issue.
Does any one have additional advice or know of any existing open bugs that might be causing this?
- George Williams
- November 23, 2015
- Like
- 0
- Continue reading or reply
Issues with Internet Explorer 11 and Salesforce Generated Code
I have been tasked with finding some solutions for a problem we are facing with Internet Explorer 11 and Salesforce/Merchantforce. The problem is that IE11 does not accept how Salesforce is processing AJAX calls to submit data, which generates an error in the console.
Here is the error message:
Unable to get property 'Submit' of undefined or null reference
And the html element that is generating this error:
<select id="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" name="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" onchange="A4J.AJAX.Submit('pageId:j_id5',event,{'similarityGroupingId':'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13','parameters':{'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13':'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13'} ,'status':'pageId:st1'} )"><option value="">--None--</option><option value="Custom CAA">Custom CAA</option>
<option value="Standalone Agreement Document">Standalone Agreement Document</option>
<option value="Standard CAA">Standard CAA</option>
</select>
We are also seeing this same kind of error on some Salesforce pages, like the page describing Inbount/Outbound Change Sets the first time you go to those areas in the Setup sub-site. The button to dismiss the introduction page are broken and produce similar error messages in IE11.
This is a critical problem as our company is about to roll out IE11 to everyone and these issues are going to impact our end-users who cannot be expected to use non-IE browsers.
We contact Salesforce and they suggested overwriting the meta tag with ApexPages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=9');
The controller for our page is manged and cannot be edited so I have tried adding it in the extension controller and making an new extension controller for just this, but that did not work.
Does anyone have any suggestions?
Thanks in advance.
Here is the error message:
Unable to get property 'Submit' of undefined or null reference
And the html element that is generating this error:
<select id="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" name="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" onchange="A4J.AJAX.Submit('pageId:j_id5',event,{'similarityGroupingId':'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13','parameters':{'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13':'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13'} ,'status':'pageId:st1'} )"><option value="">--None--</option><option value="Custom CAA">Custom CAA</option>
<option value="Standalone Agreement Document">Standalone Agreement Document</option>
<option value="Standard CAA">Standard CAA</option>
</select>
We are also seeing this same kind of error on some Salesforce pages, like the page describing Inbount/Outbound Change Sets the first time you go to those areas in the Setup sub-site. The button to dismiss the introduction page are broken and produce similar error messages in IE11.
This is a critical problem as our company is about to roll out IE11 to everyone and these issues are going to impact our end-users who cannot be expected to use non-IE browsers.
We contact Salesforce and they suggested overwriting the meta tag with ApexPages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=9');
The controller for our page is manged and cannot be edited so I have tried adding it in the extension controller and making an new extension controller for just this, but that did not work.
Does anyone have any suggestions?
Thanks in advance.
- George Williams
- October 07, 2015
- Like
- 3
- Continue reading or reply
Contact report action VF page select list not showing my VF page
my VF page:
<apex:page standardController="Contact" recordSetVar="contacts"> <apex:form > <apex:pageBlock title="Contact Assistant Information" id="contact_ast_info"> <apex:pageBlockTable value="{! contacts }" var="c"> <apex:column value="{! c.assistantname }"/> <apex:column > <a href="tel:{!c.assistantphone}">{!c.assistantphone}</a> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>However, even though other pages set up similar this one are showing up in the list this one does not. Cannot find where the problem is.
- George Williams
- July 29, 2015
- Like
- 0
- Continue reading or reply
Developer Console Broken in IE9
The dev console is unusable in Internet Explorer 9. When ever there is an open if statement, line (no semi-colon where one is expected) or really just any reason it wants to think of the console will start jamming lines ontop of each other. I am having to write the code in Notepad and then copy/paste into the console.
- George Williams
- July 26, 2015
- Like
- 0
- Continue reading or reply
Issues with Internet Explorer 11 and Salesforce Generated Code
I have been tasked with finding some solutions for a problem we are facing with Internet Explorer 11 and Salesforce/Merchantforce. The problem is that IE11 does not accept how Salesforce is processing AJAX calls to submit data, which generates an error in the console.
Here is the error message:
Unable to get property 'Submit' of undefined or null reference
And the html element that is generating this error:
<select id="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" name="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" onchange="A4J.AJAX.Submit('pageId:j_id5',event,{'similarityGroupingId':'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13','parameters':{'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13':'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13'} ,'status':'pageId:st1'} )"><option value="">--None--</option><option value="Custom CAA">Custom CAA</option>
<option value="Standalone Agreement Document">Standalone Agreement Document</option>
<option value="Standard CAA">Standard CAA</option>
</select>
We are also seeing this same kind of error on some Salesforce pages, like the page describing Inbount/Outbound Change Sets the first time you go to those areas in the Setup sub-site. The button to dismiss the introduction page are broken and produce similar error messages in IE11.
This is a critical problem as our company is about to roll out IE11 to everyone and these issues are going to impact our end-users who cannot be expected to use non-IE browsers.
We contact Salesforce and they suggested overwriting the meta tag with ApexPages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=9');
The controller for our page is manged and cannot be edited so I have tried adding it in the extension controller and making an new extension controller for just this, but that did not work.
Does anyone have any suggestions?
Thanks in advance.
Here is the error message:
Unable to get property 'Submit' of undefined or null reference
And the html element that is generating this error:
<select id="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" name="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" onchange="A4J.AJAX.Submit('pageId:j_id5',event,{'similarityGroupingId':'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13','parameters':{'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13':'pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13'} ,'status':'pageId:st1'} )"><option value="">--None--</option><option value="Custom CAA">Custom CAA</option>
<option value="Standalone Agreement Document">Standalone Agreement Document</option>
<option value="Standard CAA">Standard CAA</option>
</select>
We are also seeing this same kind of error on some Salesforce pages, like the page describing Inbount/Outbound Change Sets the first time you go to those areas in the Setup sub-site. The button to dismiss the introduction page are broken and produce similar error messages in IE11.
This is a critical problem as our company is about to roll out IE11 to everyone and these issues are going to impact our end-users who cannot be expected to use non-IE browsers.
We contact Salesforce and they suggested overwriting the meta tag with ApexPages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=9');
The controller for our page is manged and cannot be edited so I have tried adding it in the extension controller and making an new extension controller for just this, but that did not work.
Does anyone have any suggestions?
Thanks in advance.
- George Williams
- October 07, 2015
- Like
- 3
- Continue reading or reply
Getting Errors in Lightning Experience Spring '17
Keep getting this error below in the App Manager panel and have been seeing werid behavior in other places. Some apps I did for trailheads no longer function correctly either, some produce Aura.loadComponent(): Failed to initialize application errors while others are not displaying any data.
Uncaught TypeError: Cannot read property 'b' of null throws at https://geowil-dev-ed.lightning.force.com/auraFW/javascript/hS-U-Sm-fapuqhqczmdv5g/aura_prod.js:345:219
Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 1999217911-47099 (713029975)
Uncaught TypeError: Cannot read property 'b' of null throws at https://geowil-dev-ed.lightning.force.com/auraFW/javascript/hS-U-Sm-fapuqhqczmdv5g/aura_prod.js:345:219
Aura.loadComponent(): Failed to initialize application. An internal server error has occurred Error ID: 1999217911-47099 (713029975)
- George Williams
- February 07, 2017
- Like
- 0
- Continue reading or reply
Quick Start: Lightning Components Broken
For whatever reason the Lightning app built during the above Trailhead project does not work when previewed. I keep getting this error:
This page has an error. You might just need to refresh it. Error during init [Cannot read property 'apply' of undefined]
No issues with the project chanllenges, in fact I have completed the project trail. Checked my code, exact same as given during the project steps.
This page has an error. You might just need to refresh it. Error during init [Cannot read property 'apply' of undefined]
No issues with the project chanllenges, in fact I have completed the project trail. Checked my code, exact same as given during the project steps.
- George Williams
- January 30, 2017
- Like
- 0
- Continue reading or reply
Connect to Salesforce with Server-Side Controllers - No doInit in JavaScript Controller Error
I am running into an issue getting the challenge to pass. Everything is working correctly but for whatever reason Trailhead cannot see the doInit function in my JS controller. Here is all of my code:
CampingList.cmp:
CampingList JS Controller:
CampingList JS Helper:
CampingListController:
Full error from the challenge:
Challenge Not yet complete... here's what's wrong:
The campingList JavaScript controller doesn't have a 'doInit' function or doesn't call the Apex controller to get items from the database.
CampingList.cmp:
<aura:component controller="CampingListController"> <aura:attribute type="Camping_Item__c[]" name="items"/> <aura:attribute type="Camping_Item__c" name="newItem" default="{ 'sobjectType': 'Camping_Item__c', 'Quantity__c': 0, 'Price__c': '0'}"/> <aura:handler name="init" action="{!c.doInit}" value="{!this}"/> <div aria-labelledby="campItemForm"> <!-- BOXED AREA --> <fieldset class="slds-box slds-theme--default slds-container--small"> <legend id="campItemForm" class="slds-text-heading--small slds-p-vertical--medium"> Add Expense </legend> <!-- CREATE NEW EXPENSE FORM --> <form class="slds-form--stacked"> <div class="slds-form-element slds-is-required"> <div class="slds-form-element__control"> <ui:inputText aura:id="cmpLstItmName" label="Name" class="slds-input" labelClass="slds-form-element__label" value="{!v.newItem.Name}" required="true"/> </div> </div> <div class="slds-form-element slds-is-required"> <div class="slds-form-element__control"> <ui:inputNumber aura:id="cmpLstItmQty" label="Quantity" class="slds-input" labelClass="slds-form-element__label" value="{!v.newItem.Quantity__c}" required="true"/> </div> </div> <div class="slds-form-element slds-is-required"> <div class="slds-form-element__control"> <ui:inputCurrency aura:id="cmpLstItmPrice" label="Price" class="slds-input" labelClass="slds-form-element__label" value="{!v.newItem.Price__c}" placeholder="0.00" required="true"/> </div> </div> <div class="slds-form-element"> <ui:inputCheckbox aura:id="cmpLstItmPacked" label="Packed?" class="slds-checkbox" labelClass="slds-form-element__label" value="{!v.newItem.Packed__c}"/> </div> <div class="slds-form-element"> <ui:button label="Create Camping List Item" class="slds-button slds-button--brand" press="{!c.clickCreateCmpLstItem}"/> </div> </form> <!-- / CREATE NEW EXPENSE FORM --> </fieldset> <!-- / BOXED AREA --> </div> <!-- / CREATE NEW EXPENSE --> <div class="slds-card slds-p-top--medium"> <header class="slds-card__header"> <h3 class="slds-text-heading--small">Camping Items</h3> </header> <section class="slds-card__body"> <div id="list" class="row"> <aura:iteration items="{!v.items}" var="item"> <c:CampingListItem item="{!item}"/> </aura:iteration> </div> </section> </div> </aura:component>
CampingList JS Controller:
({ doInit : function(component, event, helper){ var action = component.get("c.getItems"); //console.log('loading data'); action.setCallback(this,function(response){ var respState = response.getState(); if (component.isValid() && respState == "SUCCESS"){ //console.log(response.getReturnValue()); helper.controllerHelper(component,response.getReturnValue()); } else if (respState == "ERROR"){ } }); $A.enqueueAction(loadData); }, clickCreateCmpLstItem : function(component, event, helper) { if (helper.validateForm(component)){ helper.createItem(component); } } })
CampingList JS Helper:
({ controllerHelper : function(component,cmpItmList){ component.set('v.items',cmpItmList); }, createItem : function(component){ var action = component.get("c.saveItem"); var items = component.get("v.items"); var allItems = items; allItems.push(component.get("v.newItem")); var campItems = JSON.stringify(allItems); action.setParams({"cmpItms": campItems}); action.setCallback(this,function(response){ var respState = response.getState(); if (component.isValid() && respState == "SUCCESS"){ component.set("v.items",response.getReturnValue()); } else if (respState == "ERROR"){ } }); $A.enqueueAction(action); }, validateForm : function(component){ var isValid = true; var cmpItmName = component.find("cmpLstItmName"); var itmName = cmpItmName.get('v.value'); var cmpItmQty = component.find("cmpLstItmQty"); var itmQty = cmpItmQty.get('v.value'); var cmpItmPrc = component.find("cmpLstItmPrice"); var itmPrc = cmpItmPrc.get('v.value'); var cmpItmPked = component.find("cmpLstItmPacked"); var itmPked = cmpItmPked.get('v.value'); if ($A.util.isEmpty(itmName)){ isValid = false; cmpItmName.set("v.errors", [{message:"Item name can't be blank."}]); } else{ cmpItmName.set("v.errors", null); } if ($A.util.isEmpty(cmpItmQty)){ isValid = false; cmpItmQty.set("v.errors", [{message:"Item amount can't be blank."}]); } else{ cmpItmQty.set("v.errors", null); } if ($A.util.isEmpty(cmpItmPrc)){ isValid = false; cmpItmPrc.set("v.errors", [{message:"Item price can't be blank."}]); } else{ cmpItmPrc.set("v.errors", null); } if (isValid){ return true; } else{ return false; } } })
CampingListController:
public with sharing class CampingListController { public static Map<String,Schema.SObjectField> schemaMap; public static String[] campItmFlds; public CampingListController(){ } public static void setupFLSCheck(){ campItmFlds = new String[] {'Id','Name','Quantity__c','Price__c','Packed__c'}; schemaMap = Schema.SObjectType.Camping_Item__c.fields.getMap(); } @auraenabled public static List<Camping_Item__c> getItems(){ setupFLSCheck(); for (String fld : campItmFlds){ if (!schemaMap.get(fld).getDescribe().isAccessible()){ // Check if the user has access to view field throwError('You do not have access to the '+fld+ ' field on the Camping_Item__c object.' ); //Send error to client return null; // Suppress editor logs } } return [select ID,Name,Quantity__c,Price__c,Packed__c from Camping_Item__c]; } @auraenabled public static List<Camping_Item__c> saveItem(Camping_Item__c item){ return new List<Camping_Item__c>{item}; } @auraenabled public static List<Camping_Item__c> saveItem(String cmpItms){ setupFLSCheck(); List<SObject> cmpItms2 = convertJSONToListOfSObject(cmpItms); List<Camping_Item__c> cmpitms3= new List<Camping_Item__c>(); for (SObject so : cmpItms2){ cmpitms3.add((Camping_Item__c)so); } for (Camping_Item__c cItem : cmpitms3){ System.debug('Camp Item: ' + cItem.Name); System.debug('Camp Id: ' + cItem.Id); } for (String fld : campItmFlds){ if (!schemaMap.get(fld).getDescribe().isAccessible()){ // Check if the user has access to view field throwError('You do not have access to the '+fld+ ' field on the Camping_Item__c object.' ); return null; // Suppress editor logs } else if (!schemaMap.get(fld).getDescribe().isUpdateable() && fld != 'Id'){ throwError('You cannot update the '+fld+' field on the Camping_Item__c object.'); return null; } } upsert cmpItms3; return cmpItms3; } public static void throwError(string errMsg){ try{ throw new AuraHandledException(errMsg); } catch(Exception e){ system.debug(e.getMessage()); } } private static List<SObject> convertJSONToListOfSObject(String json) { Object[] values = (Object[])System.JSON.deserializeUntyped(json); List<SObject> newSObjectsList = new List<SObject>(); for (Object v : values) { Map<String, Object> m = (Map<String, Object>)v; Schema.SObjectType targetType = Schema.getGlobalDescribe().get('Camping_Item__c'); SObject o = targetType.newSObject(); Map<String, Schema.SObjectField> fields = targetType.getDescribe().fields.getMap(); for (String fieldName : m.keySet()) { // Filter out any psuedo fields such as LastNameLocal Schema.SObjectField fi = fields.get(fieldName); if (fi != null) { if (fi.getDescribe().isCreateable() && fi.getDescribe().isUpdateable() && fieldName != 'Id') { if(fieldName == 'Price__c'){ String prcStr = String.valueOf(m.get(fieldName)); o.put(fieldName,Decimal.valueOf(prcStr)); } else{ o.put(fieldName, m.get(fieldName)); } } } } newSObjectsList.add(o); } return newSObjectsList; } }
Full error from the challenge:
Challenge Not yet complete... here's what's wrong:
The campingList JavaScript controller doesn't have a 'doInit' function or doesn't call the Apex controller to get items from the database.
- George Williams
- January 06, 2017
- Like
- 0
- Continue reading or reply
Create an Apex class that writes and reads from the org cache Trailhead Challenge error
Hello,
I am trying to complete the challenge for the Use Org & Session Cache module on Salesforce Trailhead. Here are the instructions:
In this challenge, you’ll write an Apex class that writes and reads a bus schedule from the org cache. Your method for reading the cache has to handle cache misses.
Here is the error I am receiving:
Challenge Not yet complete... here's what's wrong:
The Apex Class BusScheduleCache is not properly implemented. Please follow the requirements and ensure everything is setup correctly
Can someone please help?
I am trying to complete the challenge for the Use Org & Session Cache module on Salesforce Trailhead. Here are the instructions:
In this challenge, you’ll write an Apex class that writes and reads a bus schedule from the org cache. Your method for reading the cache has to handle cache misses.
- Create a partition called BusSchedule with 0 MB for the size of org cache and session cache. The 0 MB allocation enables you to test cache misses.
- Create a public Apex class called BusScheduleCache.
- Add this variable to the class: private Cache.OrgPartition part;
- In the constructor, create a new instance of Cache.OrgPartition by passing it the partition name (local.BusSchedule). Assign this object to the class variable (part).
- Add two public methods. a. The first method, putSchedule(), returns void and takes these parameters: String busLine, Time[] schedule. b. The second method, getSchedule(), returns a bus schedule as a time array (Time[]) and takes this parameter: String busLine.
- Implement the putSchedule() method so that it stores the passed-in values in the org cache by using the partition class variable (part).
- Implement the getSchedule() method so that it returns the schedule for the specified bus line by using the partition class variable (part).
- Add logic to the getSchedule() method to handle cache misses. If null is returned for the cached value, getSchedule() should return the following default schedule as a Time array with two Time objects: one Time object value of 8am and another of 5pm. Use the Apex Time.newInstance() method to create the Time objects.
public class BusScheduleCache { // Get partition private Cache.OrgPartition part; String partitionName = 'local.BusSchedule'; public BusScheduleCache(String partitionName) { Cache.OrgPartition newpart = Cache.Org.getPartition(partitionName); part = newpart; } public static void putSchedule(String busLine, Time[] schedule) { Cache.Org.put(busline, schedule); } public static Time[] getSchedule(String busLine) { Time[] schedule; // Get a cached value Object obj = Cache.Org.get(busLine); // Cast return value to a specific data type Time t2 = (Time)obj; if (t2 != null) { schedule.add(t2); } else { Time t3 = Time.newInstance(8,0,0,0); schedule.add(t3); Time t4 = Time.newInstance(17,0,0,0); schedule.add(t4); } return schedule; } }
Here is the error I am receiving:
Challenge Not yet complete... here's what's wrong:
The Apex Class BusScheduleCache is not properly implemented. Please follow the requirements and ensure everything is setup correctly
Can someone please help?
- Lehel Gyeresi
- November 22, 2016
- Like
- 0
- Continue reading or reply
Unable to validate AccountManager APEX Web Service Trailhead Challenge
I've completed the challenge, it has 100% coverage. I've checked all the method names. The URL is valid. I've used Work Bench and curl to test and even tested with multiple Accounts with and without contacts.
I know on other challenges, punctionation was important. What about the defination of the return? Are there expected names?
I built a class to hold Account ID & Name along with a List of Contact names and IDs. Is this my issue? Anyone else have a challenge with this challenge?
Any help or hints will be appreciated.
Here are snippets of my code:
@RestResource(urlMapping='/Accounts/*/contacts')
global with sharing class AccountManager {
....
global class APIAccount {
public ID Id;
public String Name;
List<APIContact> Contacts;
...
@HttpGet
global static APIAccount getAccount() {
RestRequest request = RestContext.request;
...
I know on other challenges, punctionation was important. What about the defination of the return? Are there expected names?
I built a class to hold Account ID & Name along with a List of Contact names and IDs. Is this my issue? Anyone else have a challenge with this challenge?
Any help or hints will be appreciated.
Here are snippets of my code:
@RestResource(urlMapping='/Accounts/*/contacts')
global with sharing class AccountManager {
....
global class APIAccount {
public ID Id;
public String Name;
List<APIContact> Contacts;
...
@HttpGet
global static APIAccount getAccount() {
RestRequest request = RestContext.request;
...
- John Lay 9
- December 21, 2015
- Like
- 1
- Continue reading or reply
Unit tests pass but are not displayed in code coverage
I have been running into a problem during unit testing over the last few months where for whatever reason some tests mysteriously disappear from the code coverage drop down list after they finish running. This happens with both re-run tests and new tests either started from the developer console or the Apex Test Execution page. As an example I have been trying to run 25 tests on a controller today but even though all 25 tests are passing only 9 of them are being used in the code coverage caluclations in the developers console.
I have Parrallel Testing disabled, I have tried clearing the test history and test data. I have tried creating new workspaces, and I have tried re-saving my test class then running the test. I have even tried deleting Chrome's history and saved data. None of these has fixed the issue.
Does any one have additional advice or know of any existing open bugs that might be causing this?
I have Parrallel Testing disabled, I have tried clearing the test history and test data. I have tried creating new workspaces, and I have tried re-saving my test class then running the test. I have even tried deleting Chrome's history and saved data. None of these has fixed the issue.
Does any one have additional advice or know of any existing open bugs that might be causing this?
- George Williams
- November 23, 2015
- Like
- 0
- Continue reading or reply
Contact report action VF page select list not showing my VF page
my VF page:
<apex:page standardController="Contact" recordSetVar="contacts"> <apex:form > <apex:pageBlock title="Contact Assistant Information" id="contact_ast_info"> <apex:pageBlockTable value="{! contacts }" var="c"> <apex:column value="{! c.assistantname }"/> <apex:column > <a href="tel:{!c.assistantphone}">{!c.assistantphone}</a> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>However, even though other pages set up similar this one are showing up in the list this one does not. Cannot find where the problem is.
- George Williams
- July 29, 2015
- Like
- 0
- Continue reading or reply