0

I have gone through Many Links Sample- Link but couldn't get the answer. I Have a Sobject to be filled beforei hit the apex controller. Structure in component is:

<aura:attribute name="newFeedbackObj" type="sObject" default="{
    'sobjectType': 'Feedback__c','Chose_Category__c':'' }"/>

<aura:attribute name="categoryList" type="String[]"/> 

And in doInit method i am fetching all picklist from the object using schema.

<ui:inputSelect label="Categories" class="slds-input" aura:id="feedback_Category"
                                labelClass="slds-form-element__label" change="{!c.onChangePickVal}">
                <aura:iteration items="{!v.categoryList}" var="s"> 
                    <ui:inputSelectOption text="{!s}" /> 
                </aura:iteration>            
            </ui:inputSelect>

When compenent loads, all the picklists values comes correctly. Upon changing the value, i am calling a jsController as below.

    onChangePickVal : function(cmp){
            var selectCmp = cmp.find("feedback_Category");   
            console.log('selectCmp >>'+selectCmp);
    component.set("v.newFeedbackObj.Chose_Category__c", selectCmp.get("v.value"));
console.log('Selected Value>>'+selectCmp.get("v.value"));
        }

But at the end, the chosen pick list value is not being sent. can someone plesae help me. I want to pass the selected value to sObject.

I even get the correct chosen value in by console.log "Selected Value>>". I just don't know how can i pass it to sObject.

5
  • what is the problem? is value is not getting set in attribute newFeedbackObj? Aug 24, 2017 at 20:22
  • @ManjotSingh Yes . The value is always going as blank ( which is default ). Aug 25, 2017 at 3:17
  • What you have is a valid implementation. The way that you are setting the sobject attribute "Chose_Category__c" is fine. It should work. can you console.log "cmp.get("v.newFeedbackObj")", you should be able to see a proxy object logged in the console. But that's fine. You would have 2 properties, handler and target, Can you check if your object is updated under the [target] .. something like this $actual$ : {sobjectType: "Feedback__c", Chose_Category__c: "[ YOUR SELECTED VALUE] "}
    – Sumuga
    Aug 25, 2017 at 8:57
  • try getting again the select component after setting it's value: selectCmp = cmp.find("feedback_Category"); only then get it's value: selectCmp.get("v.value") Aug 27, 2017 at 5:01
  • @ItaiShmida Thanks for yur input but somehow it didnt worked. So as a last option i passed the Selected category as One of the Parameter to my Apex controller and then just before created it I changed the value of the object. var action = component.get("c.createFeedback1"); action.setParams({"parmToBePassed":feedbackFrm , "selectedCat":selectedCat}); And in my apex Controller : 'public static String createFeedback1(Feedback__c parmToBePassed, string selectedCat){ parmToBePassed.Chose_Category__c = selectedCat; Upsert parmToBePassed;' Aug 28, 2017 at 10:54

1 Answer 1

0

@ItaiShmida Thanks for yur input but somehow it didnt worked. So as a last option i passed the Selected category as One of the Parameter to my Apex controller and then just before created it I changed the value of the object.

var action = component.get("c.createFeedback1");
action.setParams({"parmToBePassed":feedbackFrm , "selectedCat":selectedCat});

And in my apex Controller :

public static String createFeedback1(Feedback__c parmToBePassed, string selectedCat){
    parmToBePassed.Chose_Category__c = selectedCat;
    upsert parmToBePassed;
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .