• Michael J. Lupino
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 6
    Replies
I am attempting to use force:navigateToComponent but running into an odd issue. The internet sites that I'm using as reference seams to point me that I'm following the right path but I'm unclear on the error. Its preventing me from saving the page: 

    <aura:component>
    <lightning:button variant="brand" label="Button Text" onclick="{!c.Navigate}" />
    </aura:component>

Controller JS:

    Navigate : function(component, event, helper) {
    var evt = $A.get("e.force:navigateToComponent");
    evt.setParams({
    componentDef : "c:component2",
    });
    evt.fire();
}

Error Reported on Save: Failed to save undefined: markup://aura:component cannot be instantiated directly. Component will not save in developer console. 

Source Materials: 
https://developerprob.blogspot.com/2016/06/navigate-from-one-component-to-another.html

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToComponent.htm



 
I have a hopefully simple request but I feel like I'm missing something (could be that I'm missing something because I'm doing it at 2AM). I have a UI:inputcheckbox that I would like to wrap with some slds styling. I can't seam to modify the styling for that element. Ideally I'm looking for styling similar to the following page: https://www.lightningdesignsystem.com/components/forms/#flavor-checkbox-add-button (span class="slds-checkbox">)


Lightning Component:

<aura:component controller="TSTWRP_DisplayPosition" implements="force:appHostable,
                                                                flexipage:availableForAllPageTypes,
                                                                flexipage:availableForRecordHome,
                                                                force:hasRecordId,forceCommunity:availableForAllPageTypes" 
                access="global" >
    <!--  <ltng:require styles="/resource/bootstrap/css/bootstrap.min.css" 
      scripts="/resource/bootstrap/js/jquery-2.js,/resource/bootstrap/js/bootstrap.min.js" /> -->
    <aura:attribute name="lstAccounts" 
                    type="TSTWRP_CommonWrapperClass.DisplayAccountRecords[]" />    
    
    
    <!--- on initialization of component init event will fire and doInit action will execute-->
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    
    <div class="container">
        <h2>Account List</h2>
        <br></br>
        <table class="table table-striped">
            <thead>
                <tr>
                    <th></th>
                    <th>Account</th>
                </tr>
            </thead>
            <tbody>
                
                <aura:iteration var="Account" items="{!v.lstAccounts}" >
                    <tr>
                        <td><ui:inputCheckbox value="{!Account.isSelected}"/></td>
                        <td><ui:outputText value="{!Account.AccountName}"/></td>
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
        <br></br>

        <!-- Test Bed -->
        
        
        <ui:button class="btn btn-default" press="{!c.doSomething}">Perform Action</ui:button>
        
    </div>
 </aura:component>
I’m looking at some code that contains some errata from a recent Salesforce University class. Would someone be willing to point me in the direction of how to address?  I know Locker Service is what is causing the issue. I’m not sure how to address it in my code. I didn’t have enough time to ask the instructor to look it over. My issue is that the 2nd selection in the dropdown explosion throws an error. The first does not. If i flip the sound file, I can hear explosion but not sad trombone. 

Here’s the component markup, controller and helper

Component:
<aura:component implements="force:appHostable,force:lightningQuickAction,flexipage:availableForAllPageTypes"
                access="global"
                description="Never press the big red button!!!"
                controller="PanicButtonServerController">
    <aura:attribute name="sound"
                    type="String"
                    default="Sad Trombone"
                    description="valid values=Sad Trombone|Explosion,see docs for more details"/>
    <aura:attribute name="message"
                    type="String"
                    default="D'Oh"
                    description="Message to display while audio is playing"/>
    <aura:attribute name="soundUrl"
                    type="String"
                    default=""
                    access="PUBLIC"/>
   
    <aura:attribute name="soundOptions"
                    type="SoundClip__c[]"
                    default="[]"
                    access="PUBLIC"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <div>
        <lightning:button onclick="{!c.handleClick}" variant="base">
            <div class="panicbutton"  />
        </lightning:button>
        <lightning:select name="soundSelector"
                          label="Select Sound"
                          aura:Id="soundSelector"
                          value="{!v.soundUrl}">
       <aura:iteration items="{!v.soundOptions}" var="option">
                <option value="{!option.fileUrl__c}">
                    {!option.Name}
                </option>
            </aura:iteration>
        </lightning:select>
        <audio aura:id="audioclip" onended="{!c.onPlaybackEnded}" src="{!v.soundUrl}" />
        <div aura:id="message" class="slds-hide message">
            {! v.message }
        </div>
    </div>
</aura:component>

 --- Controller ---
({
     handleClick : function(component, event, helper) {
       
        helper.buttonDown(component,helper);
     },
    playSound: function(component) {
        var domElem = component.find('audioclip').getElement();
        domElem.src = component.get('v.soundUrl');
        domElem.play();
       
    },
    buttonDown: function(component,helper) {
        var msgElem = component.find('message');
        $A.util.removeClass(msgElem,'slds-hide');
        helper.playSound(component);
    },
    buttonUp: function(component,helper) {
        var msgElem = component.find('message');
        $A.util.addClass(msgElem,'slds-hide');
    },
    callServer : function(component,method,callback,params) {
        var action = component.get(method);
        if (params) {
            action.setParams(params);
        }
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                // pass returned value to callback function
                callback.call(this,response.getReturnValue());  
            } else if (state === "ERROR") {
                // generic error handler
                var errors = response.getError();
                if (errors) {
                    console.log("Errors", errors);
                    if (errors[0] && errors[0].message) {
                        throw new Error("Error" + errors[0].message);
                    }
                } else {
                    throw new Error("Unknown Error");
                }
            }
        });
            $A.enqueueAction(action);
    },
    doInit: function(component, event, helper) {
        var defaultSound = component.get('v.sound');
        var baseUrl = $A.get('$Resource.PanicButtonAssets');
        var opts = [
            {
                Name: "Sad Trombone",
                fileUrl: baseUrl + "/PanicButton/SadTrombone.mp3"
            },
            {
                Name: "Explosion",
                fileUrl: baseUrl + "/PanicButton/Explosion.mp3"           
            }
            ];
               component.set("v.soundOptions", opts);
        for (var i=0; i <opts.length; i++) {
            if (opts[i].Name == defaultSound) {
                component.set(
                'v.soundUrl',
                opts[i].fileUrl
                );
                break;
            }
        }
        }
})

--- Helper ---
({
    playSound: function(component) {
        var domElem = component.find('audioclip').getElement();
        domElem.src = component.get('v.soundUrl');
        domElem.play();
    },
    buttonDown: function(component,helper) {
        var msgElem = component.find('message');
        $A.util.removeClass(msgElem,'slds-hide');
        helper.playSound(component);
    },
    buttonUp: function(component,helper) {
        var msgElem = component.find('message');
        $A.util.addClass(msgElem,'slds-hide');
    },
    callServer : function(component,method,callback,params) {
        var action = component.get(method);
        if (params) {
            action.setParams(params);
        }
        action.setCallback(this,function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                // pass returned value to callback function
                callback.call(this,response.getReturnValue());  
            } else if (state === "ERROR") {
                // generic error handler
                var errors = response.getError();
                if (errors) {
                    console.log("Errors", errors);
                    if (errors[0] && errors[0].message) {
                        throw new Error("Error" + errors[0].message);
                    }
                } else {
                    throw new Error("Unknown Error");
                }
            }
        });
        $A.enqueueAction(action);
    }
})
 
Hi, I have an interesting problem and I'm curious to get your feedback or reccomendations: 

I'm loading a lightning component from a visualforce page (via a command button press) that is being rendered in lightning UI. Their is a command button on the form to bring the user to the new lightning page. I am noticing that I can only use force:createrecord in lightning experience which i'm fine with and this works fine if I add it to the app menu. 

The Visualforce page is being displayed in lightning. Is their anyway that I can keep the user in lightning experience and then call or access the lightning component from my visualforce page. I'm not 100% ready to convert the underlying VF page. I feel like I'd add some technical debt if I convert from the force:recordcreate to actually building out the page. 

Are their any creative solutions that I can use to address? To sum up, the visualforce page is being accessed via lightning app menu and then being displayed. The issue I have is envoking a lightning component but rendering inside of Lightning Experience to take advantage of force:createrecord action. Thanks again for your help and support.

Michael
 
There was an error saving the page: The c:componentname component isn't allowed in the main region. The component doesn't implement any of the region's allowed interfaces.

I'm working with Sara Morgan's course on Pluralsight. I noticed I'm hitting this odd error and I'm at a bit of the loss. It appears I can access the app and individual components without any issues and without errors. When i attempt to drag them into app builder, i get the error above  when saving. Has anyone seen this before. I went through and replaced my typed code with hers but I can't seam to find the issue. 

I'm working with her code at this URL: https://github.com/saramorgan/GettingStartedWithLightning/tree/master/M2.  Demo 3 through the last folder: Demo5). You'll need to grab Demo3 thru 5 if you would like to recreate the issue.

I would love to figure out what i'm missing or need to correct to get it to add to the app builder.
Good evening. I'm seeing an odd behavior with the code. It appears my if conditions are being ignored for if blocks that involve VariableA, VariableB an VariableC if the system reports back as null. It seams to treat NULL as a string. The code is designed to scale the where clause based on if a value is not null. If the value is null, i want it to be excluded from the conditions.add commands which therefore would prevent it from being written into StrQuery. If the value is not null, I want it to be included in the conditions.add commands. 

Here's an example: 

If VariableA,B &C contains data the conditions list would report back 3 + 1 for recordid being automatically added

If VariableA,B contans data, the conditions list would report back 2 + 1 for recordid being automatically added

If VariableA contains data (B,C are null) then the list would report back 1 + 1 for recordid being automatically added. 

Ideally I'm looking for the code to work for any combination of A,B,C (eg. B,C, C,A etc.). This makes up 3 conditions to the third power or nine combinations. 

My code is below: 

String strQuery = 'select id from objectname__c '; 
String VariableA;
String VariableB;
String VariableC;
 
List<string> conditions = new List<string>();
   String Esc = '\'';
   conditions.add('RecordID =' + Esc  +RecordID+ Esc +' ');
   system.debug('the filtered value of RecordID is:' + RecordID);

    //adds VariableA when VariableA not null
    if(VariableA != null) {
        conditions.add('FieldA__c  ='+ '' + Esc + VariableA + Esc); 
        system.debug('Added Value from Field A: ' + conditions);
        } 
    //adds VariableB when VariableB not null 
    
    if (VariableB != null) { 
        conditions.add('FieldB__c =' + '' + Esc +VariableB  + Esc); 
        system.debug('Added Value from Field B: ' + conditions);
    } 
    //adds VariableC when VariableC is not nuull
    if (VariableC != null) {
        conditions.add('FieldC__c=' + Esc +VariableC + Esc);
        system.debug('Added Value from Field C: '+ '' + conditions + Esc); 
        } 
    system.debug('Conditions Size is:' +conditions.size()); /number of conditions added

    //////// determines what to add to SOQL query statement
    
    if (conditions.size() > 0) {
        strQuery += 'WHERE ' + conditions[0];
        
        for (Integer i = 1; i < conditions.size(); i++)
            strQuery += 'AND ' + conditions[i];
        }
        
   system.debug('the list of conditions' + conditions);    
   system.debug('the final query' + strQuery);
Hi, 

I have some functionality that reads a group of records from a related list for display in a pageblock table based on a criteria i have set in the SOQL query. I have some values in a field lets call the field filterA that could be duplicate of other items. I'd like to read the full list of records for my query and dedup any entries. 

I've tried set but as the record ids are unique, I'll end up with the same number of records being read. Any ideas on how I can screen out the duplicates? 

Here's a visual example: 

Filter A (values)
A
A
A
A
A
A
B
B
C

My end result would be to get a list with A,B,C vs. displaying all values as I plan to pass A,B,C, to a selectlist and selectoption. I'm interested in this because This field Filter A would then be used in another piece of functionality to effectively filter based on a action from a command button and a SOQL query that would engage Filter A. I prefer to build this list based on the data vs. hardcoding. 
I'd like to create a VF page, add it to lightning and display on this VF Page a Public Calendar. In Classic I can see it, In Lightning I see: This page isn't available in Salesforce Lightning Experience or Salesforce1. This is dispite having checked off to enable the page in lightning. 

My assumption is that there is no custom way to display a public calendar in Lightning at the moment. Is that a correct assumption or is their a potential workaround that could be explored. I'm might be S.O.L. but i wanted to confirm. I realize that the standard out of box method does not allow for users to see public calendars in lightning. I was experimenting to see if their was a custom solution to this. 

Many thanks for reading my note. 
I am attempting to use force:navigateToComponent but running into an odd issue. The internet sites that I'm using as reference seams to point me that I'm following the right path but I'm unclear on the error. Its preventing me from saving the page: 

    <aura:component>
    <lightning:button variant="brand" label="Button Text" onclick="{!c.Navigate}" />
    </aura:component>

Controller JS:

    Navigate : function(component, event, helper) {
    var evt = $A.get("e.force:navigateToComponent");
    evt.setParams({
    componentDef : "c:component2",
    });
    evt.fire();
}

Error Reported on Save: Failed to save undefined: markup://aura:component cannot be instantiated directly. Component will not save in developer console. 

Source Materials: 
https://developerprob.blogspot.com/2016/06/navigate-from-one-component-to-another.html

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToComponent.htm



 
I have a hopefully simple request but I feel like I'm missing something (could be that I'm missing something because I'm doing it at 2AM). I have a UI:inputcheckbox that I would like to wrap with some slds styling. I can't seam to modify the styling for that element. Ideally I'm looking for styling similar to the following page: https://www.lightningdesignsystem.com/components/forms/#flavor-checkbox-add-button (span class="slds-checkbox">)


Lightning Component:

<aura:component controller="TSTWRP_DisplayPosition" implements="force:appHostable,
                                                                flexipage:availableForAllPageTypes,
                                                                flexipage:availableForRecordHome,
                                                                force:hasRecordId,forceCommunity:availableForAllPageTypes" 
                access="global" >
    <!--  <ltng:require styles="/resource/bootstrap/css/bootstrap.min.css" 
      scripts="/resource/bootstrap/js/jquery-2.js,/resource/bootstrap/js/bootstrap.min.js" /> -->
    <aura:attribute name="lstAccounts" 
                    type="TSTWRP_CommonWrapperClass.DisplayAccountRecords[]" />    
    
    
    <!--- on initialization of component init event will fire and doInit action will execute-->
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    
    <div class="container">
        <h2>Account List</h2>
        <br></br>
        <table class="table table-striped">
            <thead>
                <tr>
                    <th></th>
                    <th>Account</th>
                </tr>
            </thead>
            <tbody>
                
                <aura:iteration var="Account" items="{!v.lstAccounts}" >
                    <tr>
                        <td><ui:inputCheckbox value="{!Account.isSelected}"/></td>
                        <td><ui:outputText value="{!Account.AccountName}"/></td>
                    </tr>
                </aura:iteration>
            </tbody>
        </table>
        <br></br>

        <!-- Test Bed -->
        
        
        <ui:button class="btn btn-default" press="{!c.doSomething}">Perform Action</ui:button>
        
    </div>
 </aura:component>
Hi, 

I have some functionality that reads a group of records from a related list for display in a pageblock table based on a criteria i have set in the SOQL query. I have some values in a field lets call the field filterA that could be duplicate of other items. I'd like to read the full list of records for my query and dedup any entries. 

I've tried set but as the record ids are unique, I'll end up with the same number of records being read. Any ideas on how I can screen out the duplicates? 

Here's a visual example: 

Filter A (values)
A
A
A
A
A
A
B
B
C

My end result would be to get a list with A,B,C vs. displaying all values as I plan to pass A,B,C, to a selectlist and selectoption. I'm interested in this because This field Filter A would then be used in another piece of functionality to effectively filter based on a action from a command button and a SOQL query that would engage Filter A. I prefer to build this list based on the data vs. hardcoding. 
I'd like to create a VF page, add it to lightning and display on this VF Page a Public Calendar. In Classic I can see it, In Lightning I see: This page isn't available in Salesforce Lightning Experience or Salesforce1. This is dispite having checked off to enable the page in lightning. 

My assumption is that there is no custom way to display a public calendar in Lightning at the moment. Is that a correct assumption or is their a potential workaround that could be explored. I'm might be S.O.L. but i wanted to confirm. I realize that the standard out of box method does not allow for users to see public calendars in lightning. I was experimenting to see if their was a custom solution to this. 

Many thanks for reading my note.