+ Start a Discussion
LUIGI EMANUEL TAORMINALUIGI EMANUEL TAORMINA 

How to get records from a mailing list?

Hi I would like to know if it is possible to display in a function (yesBtn) a field of a sattata list in another function (getSelectedProd). I would like to display the Name__c of this list (prodList2). As you can see I did a test in the function "yesbtn "but it doesn't give me anything back
Controller:
getSelectedProd: function (component, event) {
                component.set("v.popup",true);
            var selectedRows = event.getParam('selectedRows');
            console.log('selRows -> ' + JSON.stringify(selectedRows));
            var selectedRowsIds = [];
            for(var i=0;i<selectedRows.length;i++){
                selectedRowsIds.push(selectedRows[i].Id);
                component.set("v.Name", selectedRows[i].Name__c);
            }     
            component.set( "v.prodList2", selectedRows );
            var count = component.get('v.Counter');
            count = count+1;
            
            var list = component.get("v.prodList2");
            component.set('v.Counter', list.length);
            if(list.length==0){
            component.set("v.control",false);
            }
            else{
            console.log("Size = "+list.length);
            }
            },
            handleClick : function (component, event, helper) {
            component.set( "v.control", true );
            
            },
            yesBtn : function(component,event,helper){
                    var quality=component.find("prova").get("v.value");
                    console.log("Quality "+ quality);
                    var name=component.get("v.Name");
                    console.log("Name book popup " + name);
                    var list=component.get("{!v.prodList2.Name__c}");
                    console.log("Name book list " + list);
                    var qu=component.get("v.prodList2").AvailableQuantity__c;
                    while(list==name){
                        var quantity = 0;
                        quantity=qu-quality;
                        console.log("differenza "+quantity);
                    }
                },

 
Best Answer chosen by LUIGI EMANUEL TAORMINA
mukesh guptamukesh gupta
Hi LUIGI,

Please follow below code:-
 
getSelectedProd: function (component, event) {
            component.set("v.popup",true);
            var selectedRows = event.getParam('selectedRows');
            console.log('selRows -> ' + JSON.stringify(selectedRows));
            var selectedRowsIds = [];
            for(var i=0;i<selectedRows.length;i++){
                selectedRowsIds.push(selectedRows[i].Id);
                component.set("v.Name", selectedRows[i].Name__c);
            }     
            component.set( "v.prodList2", selectedRows );
            var count = component.get('v.Counter');
            count = count+1;
            
            var list = component.get("v.prodList2");
            component.set('v.Counter', list.length);
            if(list.length==0){
            component.set("v.control",false);
            }
            else{
            console.log("Size = "+list.length);
            }
            },
            handleClick : function (component, event, helper) {
            component.set( "v.control", true );
            
            },
            yesBtn : function(component,event,helper){
                    var quality=component.find("prova").get("v.value");
                    console.log("Quality "+ quality);
                    var name=component.get("v.Name");
                    console.log("Name book popup " + name);
                    var list=component.get("v.prodList2.Name__c");
                    console.log("Name book list " + list);
                    var qu=component.get("v.prodList2").AvailableQuantity__c;
                    while(list==name){
                        var quantity = 0;
                        quantity=qu-quality;
                        console.log("differenza "+quantity);
                    }
                },

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 

All Answers

mukesh guptamukesh gupta
Hi LUIGI,

Please follow below code:-
 
getSelectedProd: function (component, event) {
            component.set("v.popup",true);
            var selectedRows = event.getParam('selectedRows');
            console.log('selRows -> ' + JSON.stringify(selectedRows));
            var selectedRowsIds = [];
            for(var i=0;i<selectedRows.length;i++){
                selectedRowsIds.push(selectedRows[i].Id);
                component.set("v.Name", selectedRows[i].Name__c);
            }     
            component.set( "v.prodList2", selectedRows );
            var count = component.get('v.Counter');
            count = count+1;
            
            var list = component.get("v.prodList2");
            component.set('v.Counter', list.length);
            if(list.length==0){
            component.set("v.control",false);
            }
            else{
            console.log("Size = "+list.length);
            }
            },
            handleClick : function (component, event, helper) {
            component.set( "v.control", true );
            
            },
            yesBtn : function(component,event,helper){
                    var quality=component.find("prova").get("v.value");
                    console.log("Quality "+ quality);
                    var name=component.get("v.Name");
                    console.log("Name book popup " + name);
                    var list=component.get("v.prodList2.Name__c");
                    console.log("Name book list " + list);
                    var qu=component.get("v.prodList2").AvailableQuantity__c;
                    while(list==name){
                        var quantity = 0;
                        quantity=qu-quality;
                        console.log("differenza "+quantity);
                    }
                },

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
This was selected as the best answer
LUIGI EMANUEL TAORMINALUIGI EMANUEL TAORMINA

unfortunately it doesn't work