• LUIGI EMANUEL TAORMINA
  • NEWBIE
  • 50 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 8
    Replies
hi, I wanted to know how to pass a list of records contained in an aura: component, and send it to an apex method to insert these records into some objects

<aura:attribute name="MapQuantity" type="Map" default="{'Id': , 'quantity':}"/>

How can I insert two values ​​obtained from two aura: attribute in the ID, Quantity fields of the map?
 
Hi,this function takes as input a value (Quantity) this value must be subtracted from the value of the Available Quantity field contained in the "prodList" list filtered by the id, with the result of the subtraction "rquantity" must be inserted (update) in the list " v.prodList "passing the id. How can it be done?

Controller:
yesBtn : function(component,event,helper){
        var qty=component.find("prova").get("v.value");
        var name=component.get("v.Name");
        var cr=component.get("v.id");
        var aquantity=component.get("v.AQuantity");
        console.log("id book "+component.get("v.id"));
        if(qty>aquantity){
            var toastEvent = $A.get("e.force:showToast");
            toastEvent.setParams({
                title : 'Error',
                message: 'the quantity you want exceeds that available',
                duration:' 5000',
                key: 'info_alt',
                type: 'Error',
                mode: 'pester'
            });
            toastEvent.fire();
        }
        else{
            var rquantity=aquantity-qty;
            console.log("Available quantity - quantity = " +rquantity);
           
            
          
         
        }

 
Hi,this function takes as input a value (Quantity) this value must be subtracted from the value of the Available Quantity field contained in the "prodList" list filtered by the id, with the result of the subtraction "rquantity" must be inserted (update) in the list " v.prodList "passing the id. How can it be done?


Controller
yesBtn : function(component,event,helper){
        var qty=component.find("prova").get("v.value");
        var name=component.get("v.Name");
        var cr=component.get("v.id");
        var aquantity=component.get("v.AQuantity");
        console.log("id book "+component.get("v.id"));
        if(qty>aquantity){
            var toastEvent = $A.get("e.force:showToast");
            toastEvent.setParams({
                title : 'Error',
                message: 'the quantity you want exceeds that available',
                duration:' 5000',
                key: 'info_alt',
                type: 'Error',
                mode: 'pester'
            });
            toastEvent.fire();
        }
        else{
            var rquantity=aquantity-qty;
            console.log("Available quantity - quantity = " +rquantity);
       console.log("List"+ component.get("v.prodList"));
            
          
         
        }

 
Hi, this method gives me a map. I would like to call this method in aura component and haveit displayed on the screen .

User-added image
my code contains two lightning: datatable where I pass two lists respectively. The first list "prodList" I need to show the products in the first lightning: datatable the second checks my cart. Having said that I have a question, when I go to select a product in the table as seen in the picture, a popup appears with a lightning in it: input which I need to make the user enter the desired quantity of that product. My list contains an "Available Quantity" field, when I go to select a product and enter the quantity you want it makes me a check where I subtract the quantity chosen by the user from the "Available quantity", how do I update the list and automatically check the updated value in the Available Quantity?
CMP
<!-- Create Datatable -->   
    <aura:attribute type="Product2__c[]" name="prodList"/>
    <aura:attribute type="Product2__c[]" name="prodList2"/>
    <aura:attribute name="control" type="Boolean" default='false'/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="Counter" type="Integer" default="0" />
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <div class="container" style="height:250px ; padding:10px ; ">
        
        <lightning:datatable class="datatable1"                            
                             data="{! v.prodList }"     
                             columns="{! v.mycolumns }"     
                             keyField="Id"
                             showRowNumberColumn="true" 
                             editable="true"
                             onrowselection="{! c.getSelectedProd }"
                             />
    </div>
    <!-- Create Popup -->
    <aura:attribute name="popup" type="Boolean" default="false"/>
    <aura:attribute name="quantity" type="Integer" default="0"/>
    <aura:attribute name="Name" type="String" default="Name"/>
    <aura:attribute name="AQuantity" type="Integer" default="0"/>
    <aura:attribute name="id" type="String" default="id"/>
    <aura:if isTrue="{!v.popup}">
        <div>
            <section role="dialog" tabindex="-1" aria-label="Meaningful description of the modal content" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <header class="slds-modal__header">
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick="{!c.closeBtn}">
                            <lightning:icon iconName="utility:close" size="small" variant="neutral"/>
                            <span class="slds-assistive-text">Close</span>
                        </button>
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">{!v.Name}</h2>
                        
                    </header>
                    
                    <div class="slds-modal__content slds-p-around_medium alignLeft" id="modal-content-id-1">
                        <lightning:card>
                            <div >
                                <lightning:layout>
                                    <lightning:layoutItem padding="around-small">
                                        <div class="position">
                                            <lightning:buttonIcon  iconName="utility:add" alternativeText="Add" title="Add" onclick="{!c.increment}" variant="brand"/></div>
                                    </lightning:layoutItem>
                                    <lightning:layoutItem padding="around-small">
                                        <lightning:input type="number" value="{!v.quantity}" name="ItemPrice" class="luigi"
                                                         label="Quantity" step="1" aura:id="prova" />
                                        
                                    </lightning:layoutItem>
                                    <lightning:layoutItem padding="around-small">
                                        <lightning:buttonIcon iconName="utility:dash" alternativeText="Add" title="Add" onclick="{!c.decrement}" variant="brand"/>
                                    </lightning:layoutItem>
                                </lightning:layout>
                            </div>
                        </lightning:card>
                        
                        
                    </div>
                    <footer class="slds-modal__footer">
                        <lightning:button label="Yes"
                                          variant="brand" class="slds-m-top--medium"
                                          onclick="{!c.yesBtn}"/>
                        <lightning:button label="No"
                                          variant="brand" class="slds-m-top--medium"
                                          onclick="{!c.noBtn}"/>
                    </footer>
                </div>
            </section>
            <div class="slds-backdrop slds-backdrop_open"></div>
        </div>
    </aura:if>

Controller:
clickBook: function (cmp, event, helper) {
        cmp.set('v.mycolumns', [
            { label: 'Name Number', fieldName: 'Name'},
            { label: 'Product Name', fieldName: 'Name__c', type: 'text'},
            { label: 'Weight For Single Product', fieldName: 'WeightForSingleProduct__c', type: 'number'},
            { label: 'Available Quantity', fieldName: 'AvailableQuantity__c', type: 'number'},
            { label: 'Genre', fieldName: 'GenreBook__c', type: 'text'},
            
        ]);
            helper.getData(cmp);
            },
            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.AQuantity",selectedRows[i].AvailableQuantity__c);
            component.set("v.Name", selectedRows[i].Name__c);
            component.set("v.id", selectedRows[i].Id);
        }     
        component.set( "v.prodList2", selectedRows );           
        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 qty=component.find("prova").get("v.value");
        var name=component.get("v.Name");
        var aquantity=component.get("v.AQuantity");
        console.log("id book "+component.get("v.id"));
        if(qty>aquantity){
            var toastEvent = $A.get("e.force:showToast");
            toastEvent.setParams({
                title : 'Error',
                message: 'the quantity you want exceeds that available',
                duration:' 5000',
                key: 'info_alt',
                type: 'Error',
                mode: 'pester'
            });
            toastEvent.fire();
        }
        else{
            var rquantity=aquantity-qty;
            console.log("Available quantity - quantity = " +rquantity);
            //problem
            console.set("v.prodList[v.id].AvailableQuantity__c",rquantity);
        }
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            title : 'Success',
            message: name+' added to cart quantity ='+quality,
            duration:' 5000',
            key: 'info_alt',
            type: 'success',
            mode: 'pester'
        });
        toastEvent.fire();
        component.set( "v.popup", false );
    },

 
Hi,my code contains two lightning: datatable where I pass two lists respectively. The first list "prodList" I need to show the products in the first lightning: datatable the second checks my cart. Having said that I have a question, when I go to select a product in the table as seen in the picture, a popup appears with a lightning in it: input which I need to make the user enter the desired quantity of that product. My list contains an "Available Quantity" field, when I go to select a product and enter the quantity you want it makes me a check where I subtract the quantity chosen by the user from the "Available quantity", how do I update the list and automatically check the updated value in the Available Quantity?
User-added image
as you can see I have created a lightning: datatable where through a list I show the products. When I go to select the single product to add to the cart, a popup opens, the popup contains a lightning: input that allows you to enter the quantity you want of that product. at the click of the "yes" button through the aura attributes I go to take AvailableQuantity of the selected product that is inside a list and subtract for the quantity entered by the user. my intent and set the list with the value of the updated AvailableQuantity field.
look at the line with the comment problem
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.AQuantity",selectedRows[i].AvailableQuantity__c);
            component.set("v.Name", selectedRows[i].Name__c);
            component.set("v.id", selectedRows[i].Id);
        }     
        component.set( "v.prodList2", selectedRows );           
        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 qty=component.find("prova").get("v.value");
        var name=component.get("v.Name");
        var aquantity=component.get("v.AQuantity");
        console.log("id book "+component.get("v.id"));
        if(qty>aquantity){
            var toastEvent = $A.get("e.force:showToast");
            toastEvent.setParams({
                title : 'Error',
                message: 'the quantity you want exceeds that available',
                duration:' 5000',
                key: 'info_alt',
                type: 'Error',
                mode: 'pester'
            });
            toastEvent.fire();
        }
        else{
            var rquantity=aquantity-qty;
            console.log("Available quantity - quantity = " +rquantity);
            //problem
            console.set("v.prodList2[v.id].AvailableQuantity__c",rquantity);
        }
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            title : 'Success',
            message: name+' added to cart quantity ='+quality,
            duration:' 5000',
            key: 'info_alt',
            type: 'success',
            mode: 'pester'
        });
        toastEvent.fire();
        component.set( "v.popup", false );
    }

 
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);
                    }
                },

 

As you can see from the code posted below I keep two lightning: datatable, the first datatable I need to display all the books on the screen and I also need to select a book that through a button inserts the values ​​in the second lightning: datatable . I would like to know how to display only the second lightning: datatable inside the lightning: tab "c.clickProva"

CMP:
</lightning:tab>
        <lightning:tab  onactive="{! c.clickHorror }" label="Horror" > <h2 style=" font-size:16px;text-align:center; color:red; font-family: Lucida Console, Courier New, monospace;">Here are all the horror books</h2>  </lightning:tab>
        <lightning:tab onactive="{! c.clickFantasy }" label="Fantasy"  > <h2 style="font-size:16px; text-align:center; color:red;font-family: Lucida Console, Courier New, monospace;">Here are all the fantasy books</h2> </lightning:tab>
        <lightning:tab onactive="{! c.clickAvailable }" label="Available Books"  > <h2 style=" font-size:16px; text-align:center; color:red;font-family: Lucida Console, Courier New, monospace;">Here are all the books available </h2> </lightning:tab> 
        <div ><lightning:tab   onactive="{! c.clickProva }"  iconName="utility:cart" > <h2 style=" font-size:16px; text-align:center; color:red;font-family: Lucida Console, Courier New, monospace;">Prova </h2> </lightning:tab></div>
        
    </lightning:tabset>



CMP:

<!-- Create Datatable -->   
    <aura:attribute type="Product2__c[]" name="prodList"/>
    <aura:attribute type="Product2__c[]" name="prodList2"/>
    <aura:attribute name="control" type="Boolean" default='false'/>
    <aura:attribute name="mycolumns" type="List"/>
    <aura:attribute name="Counter" type="Integer" default="0" />
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <div class="container" style="height:250px ; padding:10px ; ">
        
        <lightning:datatable style="color:red ;font-size:14px;font-family: Lucida Console, Courier New, monospace;" 
                          
                             data="{! v.prodList }"     
                             columns="{! v.mycolumns }"     
                             keyField="Id"
                             showRowNumberColumn="true" 
                             editable="true"
                             onrowselection="{! c.getSelectedProd }"
                             
                             />
    </div>
    <br /> <br />  <br/> 
    <lightning:button
                      label="{!v.Counter}"
                      title="Cart"
                      onclick="{! c.handleClick }"
                      iconName="utility:cart"
                      >
    </lightning:button>
    <br /> <br />
    <aura:if isTrue="{!v.control}">
        <div class="container" style="height:150px;padding:10px">
            <lightning:datatable style="color:rgb(255, 0, 0) ;font-size:14px;font-family: Lucida Console, Courier New, monospace;"
                                
                                 data="{! v.prodList2 }"     
                                 columns="{! v.mycolumns }"     
                                 keyField="Id"    
                                 hideCheckboxColumn="true"  
                                 onrowselection="{! c.getSelectedProd }"/> 
        </div>
        <aura:set attribute="else">
            <h1 style="font-size:28px; text-align:center; color:red">Empty Cart</h1>
        </aura:set>
    </aura:if>

Controller:
//function that generates the table of books  
    init: function (cmp, event, helper) {
        cmp.set('v.mycolumns', [
            { label: 'Name Number', fieldName: 'Name'},
            { label: 'Product Name', fieldName: 'Name__c', type: 'text'},
            { label: 'Weight For Single Product', fieldName: 'WeightForSingleProduct__c', type: 'number'},
            { label: 'Available Quantity', fieldName: 'AvailableQuantity__c', type: 'number'},
            { label: 'Genre', fieldName: 'GenreBook__c', type: 'text'},
            
        ]);
            helper.getData(cmp);
            },
            getSelectedProd: function (component, event) {
            var selectedRows = event.getParam('selectedRows');
            component.set( "v.prodList2", selectedRows );
            var count = component.get('v.Counter');
            count = count+1;
            component.set('v.Counter', count);
            var list = component.get("v.prodList2");
            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 );
            
            },
            
            clickProva : function (component, event, helper) {
                }

 

I would like to know how to take the boolean value at the click of the lightning datatable checkbox in order to check to create a sort of product counter in mode that increases when the product is selected and descriptions when the product has been removed
hi, I'm creating a lightning application the purpose is to show all the Books in a component with the intent of selecting a book and to create a purchase proposal. after having created a component which shows me the cards of the books, selecting a book should redirect me to another component that acts as a cart to continue my 'order'. How can you connect a component that at the click of a button redirects me to another component where it shows me the cart page on the screen?

hi, I'm creating a lightning application the purpose is to show all the Books in a component with the intent of selecting a book and to create a purchase proposal. after having created a component which shows me the cards of the books, selecting a book should redirect me to another component that acts as a cart to continue my 'order'. How can you connect a component that at the click of a button redirects me to another component where it shows me the cart page on the screen?
 
I have a table created with lightning datatable where I get records from a query in an apex class. I added an add button where the click of the button fetches the record from me and creates a new table with the fetched record. How can I do ?
Component:
<aura:attribute name="mydata" type="Object"/>
<aura:attribute name="mycolumns" type="List"/>
<aura:handler name="init" value="{! this }" action="{! c.init }"/>

<div class="container" style="height:280px">

    <lightning:datatable style="color:blue ;font-size:12px" data="{! v.mydata }"
                         columns="{! v.mycolumns }"
                         keyField="Id"
                         hideCheckboxColumn="true"
                         />
</div>

Controller:
init: function (cmp, event, helper) {
    cmp.set('v.mycolumns', [
        { label: 'Name Number', fieldName: 'Name'},
        { label: 'Product Name', fieldName: 'Name__c', type: 'text'},
        { label: 'Weight For Single Product', fieldName: 'WeightForSingleProduct__c', type: 'number'},
        { label: 'Available Quantity', fieldName: 'AvailableQuantity__c', type: 'number'},
        { label: 'Genre', fieldName: 'GenreBook__c', type: 'text'},
          {type: "button", typeAttributes: {
            label: 'Add Cart',
            name: '',
            title: '',
            disabled: false,
            value: '',
            iconPosition: ''
        }},
        {type: "button", typeAttributes: {
            label: 'Preview Cart',
            name: '',
            title: '',
            disabled: false,
            value: '',
            iconPosition: 'l'
        }}
    ]);
    helper.getData(cmp);
}
Helper:
getData : function(cmp) {
    var action = cmp.get('c.getSearchQuery');
    action.setCallback(this, $A.getCallback(function (response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            cmp.set('v.mydata', response.getReturnValue());
        } else if (state === "ERROR") {
            var errors = response.getError();
            console.error(errors);
        }
    }));
    $A.enqueueAction(action);
}


 

<aura:attribute name="MapQuantity" type="Map" default="{'Id': , 'quantity':}"/>

How can I insert two values ​​obtained from two aura: attribute in the ID, Quantity fields of the map?
 
Hi, this method gives me a map. I would like to call this method in aura component and haveit displayed on the screen .

User-added image
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);
                    }
                },

 

I would like to know how to take the boolean value at the click of the lightning datatable checkbox in order to check to create a sort of product counter in mode that increases when the product is selected and descriptions when the product has been removed
I have a table created with lightning datatable where I get records from a query in an apex class. I added an add button where the click of the button fetches the record from me and creates a new table with the fetched record. How can I do ?
Component:
<aura:attribute name="mydata" type="Object"/>
<aura:attribute name="mycolumns" type="List"/>
<aura:handler name="init" value="{! this }" action="{! c.init }"/>

<div class="container" style="height:280px">

    <lightning:datatable style="color:blue ;font-size:12px" data="{! v.mydata }"
                         columns="{! v.mycolumns }"
                         keyField="Id"
                         hideCheckboxColumn="true"
                         />
</div>

Controller:
init: function (cmp, event, helper) {
    cmp.set('v.mycolumns', [
        { label: 'Name Number', fieldName: 'Name'},
        { label: 'Product Name', fieldName: 'Name__c', type: 'text'},
        { label: 'Weight For Single Product', fieldName: 'WeightForSingleProduct__c', type: 'number'},
        { label: 'Available Quantity', fieldName: 'AvailableQuantity__c', type: 'number'},
        { label: 'Genre', fieldName: 'GenreBook__c', type: 'text'},
          {type: "button", typeAttributes: {
            label: 'Add Cart',
            name: '',
            title: '',
            disabled: false,
            value: '',
            iconPosition: ''
        }},
        {type: "button", typeAttributes: {
            label: 'Preview Cart',
            name: '',
            title: '',
            disabled: false,
            value: '',
            iconPosition: 'l'
        }}
    ]);
    helper.getData(cmp);
}
Helper:
getData : function(cmp) {
    var action = cmp.get('c.getSearchQuery');
    action.setCallback(this, $A.getCallback(function (response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            cmp.set('v.mydata', response.getReturnValue());
        } else if (state === "ERROR") {
            var errors = response.getError();
            console.error(errors);
        }
    }));
    $A.enqueueAction(action);
}