You need to sign in to do that
Don't have an account?
Dima Kryvyi
Lightning Component Framework Specialist Superbadge - Step 2
Hi All,
I'm getting this error on Step 2 of Lightning Component Framework Specialist Superbadge.
BoatSearchFormHelper.js which gets the name of the UITheme and checks whether 'e.force:createRecord' event is supported by the current context (one.app).
Does anyone know the way to check that?
I'm getting this error on Step 2 of Lightning Component Framework Specialist Superbadge.
BoatSearchFormHelper.js which gets the name of the UITheme and checks whether 'e.force:createRecord' event is supported by the current context (one.app).
renderNewButton: function (component) { var action = component.get('c.getUITheme'); action.setCallback(this, function (response) { if (response.getState() === 'SUCCESS') { if (response.getReturnValue() == 'Theme4d' && $A.get('e.force:createRecord')) { component.set('v.showNewButton', true); } } }); $A.enqueueAction(action); }So, if both conditions return true, then the 'showNewButton' attribute is set to 'true' and the 'New' button is rendered in the component markup:
<div class='{!v.showNewButton ? '' : 'slds-hide'}'> <lightning:button variant='neutral' label='New' onclick='{!c.createBoat}'/> </div>I also tried such an option with aura:renderIf:
<aura:renderIf isTrue='{!v.showNewButton}'> <lightning:button variant='neutral' label='New' onclick='{!c.createBoat}'/> <aura:set attribute='else'> </aura:set> </aura:renderIf>Here is the phase from the challenge: "The form’s controller checks whether the event.force:createRecord event is supported by a standalone app and either shows or hides the New button according to best practices."
Does anyone know the way to check that?
All Answers
Thank you for answering.
I've just tried to just put a simple check in the js controller (not in the helper), where showNewButton is the attribute of type Boolean. Then I conditionally render the 'New' button in the markup. Still getting that error after all.
But now I'm getting another error message:
So the idea is that you have to pre-populate the BoatType field for the new boat record dialog with an Id of the boatType record.
So, If I select the 'Yacht' value in the picklist, I'll have it pre-populated. If I select 'All' I'll have that field blank.
It seems that the author of the challenge was very strict about the way he wanted us to achieve the behavior...
Here's my "CreateBoat" function: Where 'typeName' holds the selected value from the picklist, 'typeMap' is a collection of key-value pairs with BoatType as a key and BoatType record Id as a value. Of course this is just a js-object. So, if the value from the picklist gets some Id from the 'typeMap' it'll be used to prepopulate the BoatType field.
Is there something wrong with it?
Thank you for your comment. I figured out that the author of that challenge is expecting us to put that check into the controller and not in the helper. After moving that function to the controller I got 'PASS'.