• Suryadeep Singh
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
We need to show the setup gear to users but want to restrict to certain configuration and settings of the setup tool. We dont want to give the access as a Sys Admin for configuration changes etc.
Hey Everyone, 

I am having trouble displaying the Toast message, in a simple Lightning component, Following os the code.

Cmp
<aura:component implements="flexipage:availableForAllPageTypes" access="global">	

    <aura:attribute name="result" type="String" />
    
    <div aura:id="input" class="slds-box small" >
        <div aura:id="panelList">
            <header class="slds-m-bottom--small">
                <div class="slds-media slds-media--center slds-m-bottom--small">
                    <div class="slds-media__figure">
                        <lightning:icon iconName="utility:answer" />
                    </div>
                    <div class="slds-media__body">
                        <h2 class="slds-text-heading--small "> Text Analyzer </h2>
                    </div>
                </div>
                <div class="slds-form-element">
                    <label class="slds-form-element__label slds-assistive-text" for="searchBox">Search</label>
                    <div class="slds-form-element__control">
                        <ui:inputText aura:id="Text2Analyze" class="slds-input" placeholder="Enter any text..." change="{!c.updateSearch}"/>
                    </div>
                </div>
            </header>
        </div>
    </div>
    
</aura:component>

Controller.js
({
	updateSearch : function(component, event, helper) {
		var inputText = escape(component.find("Text2Analyze").get("v.value"));
        console.log(inputText.length);
        helper.toastThis(inputText.length, 'Input text Length')
	}
})

helper.js
({
	toastThis : function(message, title) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            "title": title || "Error:",
            "message": message,
            "type": "error",
            "mode": "sticky"
        });
        toastEvent.fire();
    }
})

demo App
<aura:application extends="force:slds">
    <c:toastComponent />
</aura:application>

And This is the Error I am getting, when i tired to run it
Action failed: c:toastcomponent$controller$updateSearch [Cannot read property 'setParams' of undefined]
Failing descriptor: {c:toastcomponent$controller$updateSearch}


Please point out the mistakes i made. 

Best,
Nithesh