1

I'm using force:lightningQuickAction to reference lightning component for salesforce1 object specific Quick-Action. I was working with lightning component force:inputField(I was using this to get Lead OwnerId), after save lightning component breaks completely. I don't think i'm doing a good job of explaining the issue here but please take a look at the errors i get which i click on the button which calls the lightning QuickAction. Did anyone face this issue? thank you for your time and efforts.

enter image description here

and I try to change it to different lightning component, i dont see a name of the component anymore, instead i see the id of component. is there any chance this might be a bug ? enter image description here

Here is my component

    <aura:component controller="leadController" implements="force:lightningQuickAction,force:hasRecordId" access="global">
   <aura:handler name="init" value="{!this}" action="{!c.init}"/>
    <aura:attribute name="lead"  type="Lead" default="{ sobjectType: 'Lead'}"/>
    <aura:attribute name="ownervalue" type="String" />
    <label class="slds-form-element__label" for="select-01">
    <abbr class="slds-required" title="required">*</abbr>Change Lead Owner</label>
    <br/>
        <force:inputField value="{!v.lead.OwnerId}"/>
    <br/>
        <label class="slds-form-element__label" for="select-01">
        <abbr class="slds-required" title="required">*</abbr>Lead Options</label>
    <br/>
        <!--Update this section when picklist values issue fixed by salesforce -->
        <div class="slds-form-element__control">
            <div class="slds-select_container">
             <select id="selid" class="slds-select" value="{!v.lead.PicklistField1__c}" >
                <option value="-- None --">-- None --</option>  
               <option value="PickList Value1">PickList Value1</option>
               <option value="PickList Value2">PickList Value2</option>
              </select>
            </div> 
        </div>
    <br/>
        <label class="slds-form-element__label" for="select-01">
        <abbr class="slds-required" title="required">*</abbr>Not My Lead Comments</label>
    <br/>
        <force:inputField value="{!v.lead.some_Comments__c}"/> 

    <br/>
   <!-- <div class="slds-modal__footer"> -->
      <button class="slds-button slds-button--neutral">Cancel</button>
      <button class="slds-button slds-button--brand" press="{!c.saveLeadjs}">Save</button>
 <!--   </div> -->

</aura:component>

here is my component controller.

init : function(component, event, helper) {

    var ldid = component.get("v.recordId");
    console.log("init");

        var action = component.get("c.getLead");
        action.setParams({
           "leadid": ldid
        });

        action.setCallback(this, function(response){
            var state = response.getState();
            var toast = $A.get("e.force:showToast");
            if(component.isValid() && state ==="SUCCESS"){
                component.set("v.lead", response.getReturnValue());

                console.log("Component loaded successfully!");
                if (toast){
                //fire the toast event in Salesforce1
                toast.setParams({
                    "title": "Success!",
                    "message": "The component loaded successfully."
                });
                toast.fire();
                }
            } else {
                console.log("we have an error");
            }
            console.log(response.getReturnValue());
        });

    $A.enqueueAction(action);
},

And finally my controller method to get the lead.

@AuraEnabled
public static sobject getLead(id leadid){
    string ld = leadid;
    //Lead ld = new lead();
    sObject s = Database.query( ' SELECT Name,Street,Phone, OwnerId, Industry,some_Comments__c,PicklistField1__c,PicklistField2__c FROM Lead  where id =: ld  ' )[0];
    upsert s;
    return s;
}
  • Please share your code so we can help you here . – Mohith Shrivastava Oct 14 '16 at 1:20
  • @MohithShrivastava I added the code that i'm using for lightning component. thank you for your time & efforts. – naruto-sfdc Oct 14 '16 at 4:28
0

The action definition page displaying the id like that could certainly be a bug. However, I've tried this code in my own org and I can't reproduce your issue. Is there more to your lightning component that you have not already posted that could be causing this? One of the IDs you posted above (2105208638) occurs when an aura definition cannot be found, so maybe there is a reference to some lightning component that is no longer there.

  • Hi Anastasia, this is everything i have on that component. I could not reproduce in the first attempt either, something snaps when you are working on it and I couldn't trace it. thank you for your time. – naruto-sfdc Oct 19 '16 at 2:03
0

So learnt hard way never have unused attributes in the lightning. the culprit was an attribute (it's actually me).

<aura:attribute name="lead" type="Lead" default="Lead.OwnerId"/> this is what i did earlier and changed back to <aura:attribute name="lead" type="Lead" default="{ sobjectType: 'Lead'}"/> but for some reason the cache still had first attribute default value. once i fixed that it worked fine.

attribute default value SHOULD HAVE BEEN{!V.lead.ownerId}.`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.