• Luciano Roberto
  • NEWBIE
  • 105 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 36
    Replies
Hello Folks,

I created a list that loads all attachments related to a custom object, but I need to download them and I am trying to create a link unsuccessfully, someone could help me.
Follow my code

 
AttachmentList.cmp
-------------------------------------------------------------------------------------------------------------




<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" controller="AttachmentListController"> 
    
     
      
     <aura:attribute name="recordId" type="Id"/>
     <aura:attribute name="files" type="List"/>
     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    
    
    
    <table class="slds-table slds-table_cell-buffer slds-table_bordered">
             <thead>
            <tr class="slds-line-height_reset">
              <th scope="col"><div class="slds-truncate" title="Name">Anexos</div></th>
              <th scope="col"><div class="slds-truncate" title="tipo">Tipo</div></th>

            </tr>
          </thead>
          
        
        <tbody>
           <aura:iteration items="{!v.files}" var="obj">
                <tr>
                    <th scope="row"> <a href="{!'/portal/servlet.shepherd/version/download/'+obj.Id}">{!obj.Title}</a>   </th> 

                    <!-- <th scope="row"> <a href="{!'/portal/servlet/servlet.FileDownload?file='+obj.Id}" >{!obj.Title}</a>   </th> -->
                  
                  <th scope="row"><div class="slds-truncate" title="Type">{!obj.FileType}</div></th>
                    
                   
                   
                    <td>
                    
                        
	        </td>
                </tr>
            </aura:iteration>
          </tbody>
        </table>
    
    
    
    
	
</aura:component>

AttachmentListController.js
------------------------------------------------------------------------------------------------------------



({
	
    

    doInit : function(component, event, helper) {
			  $A.enqueueAction(component.get('c.getList'));
	},
    
    
    doInit : function(component, event, helper) { 
        $A.enqueueAction(component.get('c.getList')); 
    }, 
    
    
    getList: function(component, event, helper) { 
        var action = component.get("c.getContentDocs"); 
        action.setParams( { 
            arecordId : component.get('v.recordId')
        }); 
        action.setCallback(this, function(actionResult) {
            component.set('v.files',actionResult.getReturnValue()); 
        }); 
        $A.enqueueAction(action); 
    },
    
    
    
    
    
    

    
    
})

AttachmentListController.apxc
---------------------------------------------------------------------------------------------------------



public class AttachmentListController {
    
  @AuraEnabled
    public static List<ContentDocument> getContentDocs(Id arecordId) {
        List<ContentDocumentLink> CDLs = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :arecordId];
        if (CDLs.size() < 1) {
            return new List<ContentDocument>();
        }
        List<Id> CDIdList = new List<Id> (); 
        for (ContentDocumentLink nextCDL : CDLs) { 
            CDIdList.add(nextCDL.ContentDocumentId); 
        } 
        List<ContentDocument> entries = [SELECT Id, Title, FileType FROM ContentDocument WHERE Id IN :CDIdList]; 
        return entries;
    }
     
    
    

}

 
Hello Folks,

I am creating a Lightning component to display the list of attachments related to registering a custom object. Could check where I am going wrong, because nothing is displayed.
 
AttachmentList.cmp 
--------------------------------------------------------------------------------- 
<aura:component implements="forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global" controller="AttachmentListController"> <aura:attribute name="recordId" type="Id" required="true"/> <aura:attribute name="files" type="List"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <span class="text-blue"> <!-- <aura:iteration items="{!v.record.Attachments}" var="obj"> --> <aura:iteration items="{!v.files}" var="obj"> {!obj.Title} <br/> </aura:iteration> </span>
 </aura:component>

AttachmentListcontroller.js -------------------------------------------------------------------------------------------------- 

({ 

doInit : function(component, event, helper) { $A.enqueueAction(component.get('c.getList')); }, getList: function(component, event, helper) { var action = component.get("c.getContentDocs"); action.setParams( { arecordId : component.get('v.recordId') }); action.setCallback(this, function(actionResult) { component.set('v.files',actionResult.getReturnValue()); }); $A.enqueueAction(action); }, 

})

AttachmentListController.apxc ------------------------------------------------------------------------------------------------------------ 

public class AttachmentListController
 { 

@AuraEnabled 
public static List<ContentDocument> getContentDocs(Id arecordId) 
{
 List<ContentDocumentLink> CDLs = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :arecordId];

 //List<ContentDocumentLink> CDLs = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :'a08M000000BuU4vIAF']; if (CDLs.size() < 1) return new List<ContentDocument>(); // Make a List of ContentDocument IDs List <Id> CDIdList = new List <Id> (); for (ContentDocumentLink nextCDL : CDLs) { CDIdList.add(nextCDL.ContentDocumentId); } List<ContentDocument> entries = [SELECT Id, Title, FileType FROM ContentDocument WHERE ContentDocument.Id IN :CDIdList]; return entries;
 }
 }



Thanks
Hello guys,

I need to create a redirection through a trigger when updating a record. Can someone help me with some code to meet this need?

I have a visual force page that creates a record and already opens it in edit mode, but when saving it, it redirects to the visualforce page, what I need is to be redirected to the newly created (updated).

Thanks

Hi Folks,

I have two objects:
ParentObject__c (Parent record)
ChildObjetc__c (Child Record)

The relationship between them is master-detail.

I need to create a visualforce page to be able to create a child record, that is, when accessing the details of the parent record, have a custom button that will call the visualforcepage to be able to create a child record, with the parent record id.
Does anyone have any idea code to help me?

Hi all,
 

404/5000
I have two objects:
Object1__c (parent)
Object2__c (child)
Relationship master details.
For the parent object I have two types of records A, B

For the child object 2 types of records 1, 2 then if the parent object is of type A, the layout for the child will only appear 1 and if the parent object is B, the child layout will be only 2.

Someone has some trigger code to be able to do this verification.

 

Thanks!

Folks,


In the Salesforce Lightning Design System portal, show an example of a toast usage as per link below:

https://www.lightningdesignsystem.com/components/toast/


I used this example as the basis for setting it up in an environment.
The environment is configured as described below:

I have an object, called Alert, where the user can include as many alerts as he wants.
Each record of the object is an alert.

Fields of the Alert__c object:

- Name (Alert ID)
- Alert_Type__c (Example: Success, Info, Error, Warning) - User selects the type of alert you want to display
- Alert1__c (Alert message to be displayed)

 

-------------------------------------------------------------------------------

 

I created a component to display the alert on a certain page as per the code below:

 

Alert.cmp
-----------------


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   

    
<aura:attribute name="html" type="List" />
    
    
<aura:attribute name="showToast" type="boolean" default="false"/>
    
<aura:attribute name="Alert" type="Alert__c" default="{'sobjectType': 'Alert__c',
                         'Tipo_de_Alerta__c': '',
                         'Name': '',
                         'Alerta1__c': ''
                          }"/>
    
    
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    
<aura:if isTrue="{!v.showToast}">
    
           <aura:iteration items="{!v.html}" var="lista">        
					<div class="demo-only" style="height: 4rem;">
		
   							 <div class="slds-notify_container slds-is-relative">    
				
        							<div aura:id="alerta" role="status"> 
                                 
                                 <!--  <div id="{!Lista.Name}" role="status">   -->
													<div  class="slds-notify__content">
                            
                                                                <h2 class="slds-text-heading_small ">                
                                                                     <aura:unescapedHtml value="{!lista.Alerta1__c}" />  
                                                                </h2>
                            
                                                    <lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
                                                     iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small"
                                                     class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
                                                     onclick="{!c.close}"/>      
    
													</div>
									</div>
							</div>
					</div>
			</aura:iteration>
    
    
    
    
   

</aura:if>
    
    
    
</aura:component>

AlertController.js
-----------------------





({


   doInit : function(component, event, helper)
    {

  var action = component.get( "c.getMsgs" );

         action.setCallback(this, function(response) 
                           {                               
                             
                               var state = response.getState();

                               if(state == 'SUCCESS')
                               {                                   
                                   var alertMsgList = response.getReturnValue();
                                   var lista = [ ];                                  
                                   
                                   
                                   if(alertMsgList.length > 0)
                                   {                                       
                                       component.set("v.showToast", true);                             
                                   }
                                 
                                   
                                   
                                   for(var i = 0; i < alertMsgList.length; i ++) 
                                   {                                       
                                     
                                       /*
                                       var alerta = alertMsgList[ i ].Alerta1__c;
                                       var tipo = alertMsgList[ i ].Tipo_de_Alerta__c;
                                       var titulo = alertMsgList[ i ].Name;                                       
                                       */
                                       
                                      lista.push(alertMsgList[i]);

      						       }
                                   
                                   
                                   component.set("v.html",lista);
                                 
                                   var tipoAlerta = component.find( "alerta" );
                                   
                                   
                              //     var tipoAlerta = document.getElementById("!v.Alert.Name");
                              
                                                                      
                                              $A.util.addClass( tipoAlerta, "slds-notify" );
                                              $A.util.addClass( tipoAlerta, "slds-notify_toast" );  
                                              $A.util.addClass( tipoAlerta, "slds-theme_success" );  
   
                                   
     }
                               
               
                          else {
                                   console.log("Failed with state: " + state);
                               }
                           }); 
        
        
        $A.enqueueAction(action);
        
  
        
    },

   
    
   close: function(cmp, event, helper) 
    {
   $A.util.addClass(cmp.find('alerta'), "slds-hide");
    //  $A.util.addClass(document.getElementById('{!v.lista.Name}'), "slds-hide");
    },
   
   
       
    
})

AlertController.apxc
-------------------------------------




public class AlertController {
    
    
       
    
 @AuraEnabled
    public static List<Alert__c> getMsgs() {
        
        List<Alert__c> lst = new List<Alert__c>();
        lst = [select Tipo_de_Alerta__c, Name, Alert_Style__c,  Alerta1__c from Alert__c where Data_inicial__c <= :system.now() and Data_final__c >= :system.now()];
        return lst;
    }
    

    
}

What happens is that for every alert found, it needs to display it according to its characteristics:
- Type of alert
- Identification of each alert (For each alert, your type configuration and the close button will be checked)
- Alert message: This setting is the only one that is working, need to interact for each alert by formatting your type to receive the appropriate CSS and the close button for it.

In the Controller.js I put the part that configures the CSS and the separate close button just to test its operation, so it works only for one record, I need to put it to work in each interaction and to each of the records that are found .
That's what I can not do, if anyone can help me, I'll be very grateful.
Thank you

Folks,

I'm setting up a toast alert in salesforce, where a list of alerts will be shown.
Each alert will have to have its own aura: id so that I can modify its behavior, such as alert type and the close button.
Below is my code as it is currently configured, it has the fixed aura id <div aura: id = "alert" role = "status">, needs to be dynamic.
I was thinking of getting the name of each alert object record to pass to the aura id, but I do not know how to do it.
Can anybody help me

Controller.js
-------------------------------------------------------------------

({

   doInit : function(component, event, helper)
    {
  var action = component.get( "c.getMsgs" );
        
        
         action.setCallback(this, function(response) 
                           {                               
                               var state = response.getState();
                               
                               if(state == 'SUCCESS')
                               {                                   
                                   var alertMsgList = response.getReturnValue();
                                   var lista = [ ];                                  
                                   
                                   
                                   if(alertMsgList.length > 0)
                                   {
                                       
                                       component.set("v.showToast", true);
                                              var tipoAlerta = component.find( "alerta" );        
                                              $A.util.addClass( tipoAlerta, "slds-notify" );
                                              $A.util.addClass( tipoAlerta, "slds-notify_toast" );  
                                                                       
                                   }
                                   
                       
                                   
                                   for(var i = 0; i < alertMsgList.length; i ++) 
                                   {                                       
                                       var alerta = alertMsgList[ i ].Alerta1__c;
                                       var tipo = alertMsgList[ i ].Tipo_de_Alerta__c;
                                       var titulo = alertMsgList[ i ].Name;                                       
                                       
                                      lista.push(alerta);
                         
                                       
      						       }
                                   
  									component.set("v.html",lista);                                  
     }
                               
                          else {
                                   console.log("Failed with state: " + state);
                               }
                           }); 
        
        
        $A.enqueueAction(action);
  
        
    },

   
   close: function(cmp, event, helper) 
    {
    $A.util.addClass(cmp.find('alerta'), "slds-hide");
    },
        
})
 
Alert.cmp

------------------------------------------------------------------------------------------


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   

    
<aura:attribute name="html" type="List" />
    
    
<aura:attribute name="showToast" type="boolean" default="false"/>
    
  
    
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    
<aura:if isTrue="{!v.showToast}">
    
           <aura:iteration items="{!v.html}" var="lista">        
					<div class="demo-only" style="height: 4rem;">
		
   							 <div class="slds-notify_container slds-is-relative">    
				
        							<div aura:id="alerta" role="status">  
													<div  class="slds-notify__content">
                            
                                                                <h2 class="slds-text-heading_small ">                
                                                                     <aura:unescapedHtml value="{!lista}" />  
                                                                </h2>
                            
                                                    <lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
                                                     iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small"
                                                     class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
                                                     onclick="{!c.close}"/>      
    
													</div>
									</div>
							</div>
					</div>
			</aura:iteration>
    
    
    
    
    
</aura:if>
    
    
    
</aura:component>

Thanks

Folks,
I'm configuring the toast, where a list of alerts will be shown, but instead of showing multiple toasts, it is showing only the last one on the list. How do I resolve this issue?

Follow the code

TestAlert.cmp

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   

    
<aura:attribute name="html" type="String" />
<aura:attribute name="showToast" type="boolean" default="false"/>
       
<aura:attribute name="Alert" type="Alert__c" default="{'sobjectType': 'Alert__c',
                         'Tipo_de_Alerta__c': '',
                         'Name': '',
                         'Alerta1__c': ''
                          }"/>
    
    
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

<aura:if isTrue="{!v.showToast}">    
    
<div class="demo-only" style="height: 4rem;">
	<div class="slds-notify_container slds-is-relative">    
		<div aura:id="alerta" role="status"> 
	         <div  class="slds-notify__content">

<h2 class="slds-text-heading_small ">                
     <aura:unescapedHtml value="{!v.html}" />  
</h2>
    
                
                
<lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
 iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small"
 class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
 onclick="{!c.close}"/>      
    
			</div>
		</div>
	</div>
</div>
    </aura:if>
    
</aura:component>
 

TestAlertController.js

({


   doInit : function(component, event, helper)
    {

        
  var action = component.get( "c.getMsgs" ); 

         action.setCallback(this, function(response) 
                           {                               
                               var state = response.getState();
                               
                               if(state == 'SUCCESS')
                               {                                   
                                   var alertMsgList = response.getReturnValue();
                                   
                                   if(alertMsgList.length > 0)
                                   {
                                       
                                       component.set("v.showToast", true);
                                       var tipoAlerta = component.find( "alerta" );        
                                              $A.util.addClass( tipoAlerta, "slds-notify" );
                                              $A.util.addClass( tipoAlerta, "slds-notify_toast" );  
                                       
                                       
                                   }
                                   
                                   
                                   for(var i = 0; i < alertMsgList.length; i ++) 
                                   {                                       
                                       var alerta = alertMsgList[ i ].Alerta1__c;
                                       var tipo = alertMsgList[ i ].Tipo_de_Alerta__c;
                                       var titulo = alertMsgList[ i ].Name;                                       
                                       
                                          
                                       
if	(tipo == 'success')     
            {
                 
// Successs        
     $A.util.addClass( tipoAlerta, "slds-theme_success" );
     component.set("v.html",alerta);  
                
                
            }
                                       
                                       
if	(tipo == 'Info')     
            {   
        
// Info 
     $A.util.addClass( tipoAlerta, "slds-theme_info" ); 
      component.set("v.html",alerta);  
            }


if	(tipo == 'error')     
            {    
// Error  
     $A.util.addClass( tipoAlerta, "slds-theme_error" );
				component.set("v.html",alerta);  
            }                                  
                        
                                       
if	(tipo == 'warning')     
            {                                       
// Warning 

     $A.util.addClass( tipoAlerta, "slds-theme_warning" );
     component.set("v.html",alerta);  
            }     
                                       
                                       
                                       
                                       
          }
     }
                               
                               
                               
                               
                          else {
                                   console.log("Failed with state: " + state);
                               }
                           }); 
        
        
        $A.enqueueAction(action);
        
  
        
    },

   
   close: function(cmp, event, helper) 
    {
    $A.util.addClass(cmp.find('alerta'), "slds-hide");
        
    },
   
   
       
    
})
 

 

Folks,

I'm configuring a toast and I need to pass the controller's text to the <h2> tag of the view of the lightning component

TestAlert.cmp

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   

<aura:attribute name="Alert" type="Alert__c" default="{'sobjectType': 'Alert__c',
                         'Tipo_de_Alerta__c': '',
                         'Name': '',
                         'Alerta1__c': ''
                          }"/>
    
    
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
<div class="demo-only" style="height: 4rem;">
	<div class="slds-notify_container slds-is-relative">    
		<div aura:id="alerta" role="status"> 
			<div  class="slds-notify__content">
                
<h2 class="slds-text-heading_small ">	Alert message here		</h2>
    
<lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
 iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small"
 class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
 onclick="{!c.close}"/>      
    
			</div>
		</div>
	</div>
</div>

    
</aura:component>

Controller.js
doInit : function(component, event, helper)
    {

          
  var tipoAlerta = component.find( "alerta" );
        
  $A.util.addClass( tipoAlerta, "slds-notify" );
  $A.util.addClass( tipoAlerta, "slds-notify_toast" );      
  $A.util.addClass( tipoAlerta, "slds-theme_success" );    


//Code to pass text to view in tag <h2> </h2>
}

Hi Folks,

I have the following code which displays an alert on my component:

 

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   
     
    <aura:attribute name="Alert" type="Alert__c" default="{'sobjectType': 'Alert__c',
                         'Tipo_de_Alerta__c': '',
                         'Name': '',
                         'Alerta1__c': ''
                          }"/>
    
    
    <!-- Alert -->
<div  aura:id="divToast"  class="demo-only" style="height: 4rem;"> 
  <div class="slds-notify_container slds-is-relative">
      
      <div  class="slds-notify slds-notify_toast slds-theme_warning" role="status">
          
      <span class="slds-assistive-text">Warning</span>
      <span class="slds-icon_container slds-icon-utility-warning slds-m-right_small slds-no-flex slds-align-top" title="">  
        
      </span>
      <div class="slds-notify__content">
        <h2 class="slds-text-heading_small ">Alerta 1</h2> 
          
           <lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
        iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="large"
        class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
        onclick="{!c.close}"/>      
      </div>
    </div>
  </div>     
</div>
    
  
   
</aura:component>

In line <div  class="slds-notify slds-notify_toast slds-theme_warning" role="status">,  class can be variable, the value of class, being:

<div  class="slds-notify slds-notify_toast slds-theme_warning" role="status">
<div class="slds-notify slds-notify_toast slds-theme_error" role="status">
<div class="slds-notify slds-notify_toast slds-theme_success" role="status">

 

I need to pass the value of the class through the Controller.js of the component.
It would be something of the type :

<div  class="{!v.Alert.Tipo_de_Alerta__c}" role="status">

 

and in Controller.js according to the condition, pass the class:

doInit : function(component, event, helper)
    {
if (Condition== true)
{
component.set("v.Tipo_de_Alerta__c", "slds-notify slds-notify_toast slds-theme_warning" );
}

if (Another Condition == true)
{
component.set("v.Tipo_de_Alerta__c", "slds-notify slds-notify_toast slds-theme_error" );
}
}
...

Does anyone know how to tell me?

 

Thanks

 

Good morning folks,

I want insert a new record in list of picklist by code js.
I have a metadata that stores the values that are prepended in the picklist, but I want to insert another value in the list, for example
 - Select a value -.

By javascript or some other form.


Follow the code below :



------------------------------------------------------------------------------------------------------------------------------------------------------
Component.cmp
------------------------------------------------------------------------------------------------------------------------------------------------------

<aura:component  implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,forceCommunity:availableForAllPageTypes" access="GLOBAL" controller="NewCaseComponentController">  

 <!-- call doInit function on component load --> 
 
    <aura:handler name="init" value="this" action="{!c.doInit}"/>
   
    <!-- aura attributes--> 
   
   
     <aura:attribute name="caseObj" type="case" default="{'sobjectType': 'Case',
                         'AccountId': '',
                         'MSISDN__c': '',
                         'Status': '',
                         'Motivo1__c': '' ,
                         'Motivo2__c': '' ,
                         'Motivo3__c': '' ,
                       }"/>

   
    <aura:attribute name="listMotivos1" type="List"  description="to store controller field values"/>
    <aura:attribute name="listMotivos2" type="List"  description="to store dependent field values"/>
    <aura:attribute name="listMotivos3" type="List"  description="to store dependent field values"/>
    <aura:attribute name="listMotivos4" type="List" description="to store dependent field values"/>
    <aura:attribute name="listMotivos5" type="List"  description="to store dependent field values"/>
   
    <aura:attribute name="dependentFieldMap" type="map" description="map to store dependent values with controlling value"/>
    <aura:attribute name="subDependentFieldMap" type="map" description="map to store sub dependent values with controlling value"/>
    <aura:attribute name="bDisabledDependentFld" type="boolean" default="true"/>
    <aura:attribute name="bDisabledSubDependentFld" type="boolean" default="true"/>
   
      
           
       
       
 <!--********* FORM ********* -->  
   
  <div class="c-container">
        <lightning:layout multipleRows="true">
            <lightning:layoutItem padding="around-small" size="12">
                <div class="page-section page-header">
                    <h6><b>Novo caso</b></h6>
                </div>
               
            </lightning:layoutItem>
            <lightning:layoutItem padding="around-small" size="12">
                <lightning:layout>
                    <lightning:layoutItem padding="around-small" size="8">
                      
                       
                       
<div class="page-section page-right">
                     
                           
                           
                           
                           
                           
                           
                           
<div class="container-fluid">

 <div class="form-group">
    
    <hr></hr>
    
      <label>MSISDN</label>
       <force:inputField aura:id="MSISDN__c" value="{!v.caseObj.MSISDN__c}"/>
   
        
 
     <hr></hr>
    
    
    
       <!--Controller Field - Motivo 1-->
    <lightning:layoutItem size="12" padding="around-small">   
        <lightning:select aura:id="Motivo1__c"
                          value="{!v.caseObj.Motivo1__c}"
                          name="motivo1"
                          label="Motivo 1"
                          onchange="{!c.onControllerFieldChange}">
         
           
          
            <aura:iteration items="{!v.listMotivos1}" var="val">
               
                <option value="{!val.MasterLabel}">{!val.DependentFieldTextPtBR__c}</option>
            </aura:iteration>
           
        </lightning:select>
    </lightning:layoutItem>
   
   
   
   
<!--Dependent Field - Motivo 2-->
    <lightning:layoutItem size="12" padding="around-small">
        <lightning:select aura:id="Motivo2__c"
                          value="{!v.caseObj.Motivo2__c}"
                          name="motivo2"
                          label="Motivo 2"
                          disabled="{!v.bDisabledDependentFld}"
                          onchange="{!c.onControllerFieldChange}">
            <aura:iteration items="{!v.listMotivos2}" var="val">
                <option value="{!val.Path__c + ',' + val.MasterLabel}">{!val.DependentFieldTextPtBR__c}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem>   
   
   
   
   
   
   
   
   
    <!--Dependent Field - Motivo 3-->
    <lightning:layoutItem size="12" padding="around-small">
        <lightning:select aura:id="Motivo3__c"
                          value="{!v.caseObj.Motivo3__c}"
                          name="motivo3"
                          label="Motivo 3"
                          disabled="{!v.bDisabledDependentFld}"
                          onchange="{!c.onControllerFieldChange}">
            <aura:iteration items="{!v.listMotivos3}" var="val">
                <option value="{!val.Path__c + ',' + val.MasterLabel}">{!val.DependentFieldTextPtBR__c}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem> 
   
     <br></br>
  
    
      <h1>informações do solicitante</h1>
     <hr></hr>
    
 
    
   
    
<label>Montadora</label>
       <force:inputField aura:id="AccountId"  value="{!v.caseObj.AccountId}"/>
      
</div>


   
<div class="form-group">
            <label>Status</label>
            <force:inputField aura:id="Status"  value="{!v.caseObj.Status}"/>
</div>  
      


                                 
                  <br></br>           
                                 
  <div class="col-md-4 text-center">
        <ui:button class="btn btn-default" press="{!c.create}">Register case</ui:button>
  </div>

                                 
                                 
                                 
   
    </div>
       
</div>
                       
                       
                    </lightning:layoutItem>
                   
                   
                   
                </lightning:layout>
            </lightning:layoutItem>
        
           
           
           
           
        </lightning:layout>
    </div>
   

   
</aura:component>



------------------------------------------------------------------------------------------------------------------------------------------------------
ComponentController.js
------------------------------------------------------------------------------------------------------------------------------------------------------

   ({

   
doInit : function(component, event, helper) {
      
    // get the fields API name and pass it to helper function 
     
        var objDetails = component.get("v.objDetail");
        var controllingFieldAPI = component.get("v.controllingFieldAPI");
        var dependingFieldAPI = component.get("v.dependingFieldAPI");
        var subDependingFieldAPI = component.get("v.subDependingFieldAPI");
      
     
   
   
   
    // helper.getOptionsByPath(component, 'v.listControllingValues', '');
       helper.getOptionsByPath(component, 'v.listMotivos1', '');
   
  
       
  
    },
   





handleSelect: function (cmp, event, helper) {
      
        var selectedMenuItemValue = event.getParam("value");
        alert("Menu item selected with value: " + selectedMenuItemValue);
    },


   
   
    onControllerFieldChange: function(component, event, helper) {    
      
      var selectName = event.getSource().get("v.name");
      
       
       
        if(selectName == 'motivo1'){
         
            var controllerValueKey = event.getSource().get("v.value"); // get selected controller field value
            helper.getOptionsByPath(component, 'v.listMotivos2', controllerValueKey);
           
            component.set("v.bDisabledDependentFld" , false); 
        }
       
       
       
       
       
        if(selectName == 'motivo2'){
            var controllerValueKey = event.getSource().get("v.value"); // get selected controller field value
         
            helper.getOptionsByPath(component, 'v.listMotivos3', controllerValueKey);
           
            component.set("v.bDisabledDependentFld" , false); 
        }
       
       
           if(selectName == 'motivo3'){
            var controllerValueKey = event.getSource().get("v.value"); // get selected controller field value
         
            helper.getOptionsByPath(component, 'v.listMotivos4', controllerValueKey);
            component.set("v.bDisabledDependentFld" , false); 
        }
       
       
       
         if(selectName == 'motivo4'){
            var controllerValueKey = event.getSource().get("v.value"); // get selected controller field value
         
            helper.getOptionsByPath(component, 'v.listMotivos5', controllerValueKey);
            component.set("v.bDisabledDependentFld" , false); 
        }
       
       
       
       
   
       
    },
   
   
    onSubControllerFieldChange : function(component, event, helper) {    
        var controllerValueKey = event.getSource().get("v.value"); // get selected sub controller field value
        var depnedentFieldMap = component.get("v.subDependentFieldMap");
      
        if (controllerValueKey != '--- None ---') {
            var ListOfDependentFields = depnedentFieldMap[controllerValueKey];
          
            if(ListOfDependentFields.length > 0){
                component.set("v.bDisabledSubDependentFld" , false); 
                helper.fetchDepValues(component, ListOfDependentFields,"v.listSubDependingValues");    }
      
            else{
                component.set("v.bDisabledSubDependentFld" , true);
                component.set("v.listSubDependingValues", ['--- None ---']); 
            } 
           
        } else {
            component.set("v.listSubDependingValues", ['--- None ---']);
            component.set("v.bDisabledSubDependentFld" , true);  }
    },  

   
   
   
        getInput : function(cmp, evt) {
        var myName = cmp.find("name").get("v.value");
        var myText = cmp.find("outName");
        var greet = "Hi, " + myName;
        myText.set("v.value", greet);
    }

   })


------------------------------------------------------------------------------------------------------------------------------------------------------   
   
ComponentHelper.js
------------------------------------------------------------------------------------------------------------------------------------------------------
({
  getOptionsByPath: function(component, selectName, path){
        var action = component.get("c.getOptionsByPath");
      
          action.setParams({  'path' : path });
        //set callback  
      
          action.setCallback(this, function(response) {
        
              if (response.getState() == "SUCCESS") {
              
                //store the return response from server (map<string,List<string>>) 
                var StoreResponse = response.getReturnValue();
                component.set(selectName, StoreResponse);
            }
             
            else
            {
                alert('Something went wrong..');
            }
             
        });

        $A.enqueueAction(action);
    },

})



ComponentController.apxc
------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
public class NewCaseComponentController {
  @AuraEnabled
    public static List<Dependent_Picklist__mdt> getOptionsByPath(string path)
    {
       
        return  [ select DependentFieldValue__c, Path__c, DependentFieldTextPtBR__c, MasterLabel from Dependent_Picklist__mdt  where path__c = :path order by DependentFieldTextPtBR__c ];
    }
}


Thanks...
Hy Folks,

I need pass text of  picklist to insert a record of case by component lightning .

I need the text instead of the value, by the way, how can I pass on the text and the value?


Code


Component.cmp

 <aura:attribute name="caseObj" type="case" default="{'sobjectType': 'Case',
                         'AccountId': '',
                         'MSISDN__c': '',
                         'Status': '',
                         'Origin': '' ,
                          'Motivo1__c': '' 
                                                 
                       }"/>




     
<label>Montadora</label>
       <force:inputField aura:id="AccountId"  value="{!v.caseObj.AccountId}"/>
       
</div>

    

<div class="form-group">
            <label>MSISDN</label>
            <ui:inputText class="form-control" value="{!v.caseObj.MSISDN__c}"/>
</div>  
    
    
    
<div class="form-group">
            <label>Status</label>
            <force:inputField aura:id="Status"  value="{!v.caseObj.Status}"/>
</div>   
       

<div class="form-group">
            <label>Origem</label>
            <force:inputField aura:id="Origin"  value="{!v.caseObj.Origin}"/>
    
</div> 


<!--   PICKLIST  I NEED GET TEXT OF SELECTION  -->
<!--   ---------------------------------------------------------------  -->

<lightning:layoutItem size="12" padding="around-small">    
        <lightning:select aura:id="Motivo1__c"
                          value="{!v.caseObj.Motivo1__c}"
                          name="motivo1"
                          label="Motivo 1"
                          onchange="{!c.onControllerFieldChange}">
            <aura:iteration items="{!v.listMotivos1}" var="val">
                <option value="{!val.MasterLabel}">{!val.DependentFieldTextPtBR__c}</option>
            </aura:iteration>
        </lightning:select>
    </lightning:layoutItem>


----------------------------------------------------------------

Controller.js

    create: function(component, event, helper)    {
        
        console.log('Create record');
    
       
        
        
        
        var caseObj = component.get("v.caseObj");
        
        
        var action = component.get("c.createRecord");
      
        
        action.setParams({
            caseObj : caseObj
        });


------------------------------------------------------------

ClassController.apxc

 @AuraEnabled
    public static void createRecord (Case caseObj){
        
        
        
        
        try{
            System.debug('NovoCasoComponentController::createRecord::caseObj'+ caseObj);
            
            if(caseObj != null){
                
            
                caseObj.Account = null;
                insert caseObj;
            }
            
        } catch (Exception ex){
            
        }



Thanks!
 

Good Morning folks,

I have a component to inset case, but is experiencing an error of  log:
 

"first error: INVALID_FIELD, Cannot specify both an external ID reference Account and a salesforce id, AccountId: []"


Basically this code :
 

Component.cmp

 <aura:attribute name="caseObj" type="case" default="{'sobjectType': 'Case',
                         'AccountId': '',
                         'MSISDN__c': '',
                         'Status': ''
                    }"/>



<label>Montadora</label>
       <force:inputField aura:id="AccountId"  value="{!v.caseObj.AccountId}"/>
           
</div>
<div class="form-group">
            <label>MSISDN</label>
            <ui:inputText class="form-control" value="{!v.caseObj.MSISDN__c}"/>
</div>  
    
    
    <div class="form-group">
            <label>Status</label>
            <force:inputField aura:id="Status"  value="{!v.caseObj.Status}"/>
</div>   


-----------------------------------------------------------

controller.js

  create: function(component, event, helper)    {
        
        console.log('Create record');
    
        var caseObj = component.get("v.caseObj");
        
        
        var action = component.get("c.createRecord");
      
        
        action.setParams({
            caseObj : caseObj
        });



-------------------------------------------------------------------

Class.apxc

 @AuraEnabled
    public static void createRecord (Case caseObj){
        
        try{
            System.debug('NovoCasoComponentController::createRecord::caseObj'+ caseObj);
            
            if(caseObj != null){
                insert caseObj;
            }
            
        } catch (Exception ex){
            
        }
        
    }    




Thanks

Folks,
I have a component that has a picklist that is populated through a query in Metadata.
I need to add one more line in the picklist.
Example:
PicklistName:  A
                        B
                        C
These values are automatically filled in by the controller.
I need to include the list value: "--- Select -"

Would stay

PicklistName: - Select -
                        A
                        B
                        C

Thanks

Good afternoon people,

I have a list of records in a custom metadata and need to list them in a pickilist of a form of a component that I'm creating. Could someone help me with a code?

Thanks

 

Good Morning folks,

I have a component to inset case, but is experiencing an error of  log:
 

"first error: INVALID_FIELD, Cannot specify both an external ID reference Account and a salesforce id, AccountId: []"


Basically this code :
 

Component.cmp

 <aura:attribute name="caseObj" type="case" default="{'sobjectType': 'Case',
                         'AccountId': '',
                         'MSISDN__c': '',
                         'Status': ''
                    }"/>



<label>Montadora</label>
       <force:inputField aura:id="AccountId"  value="{!v.caseObj.AccountId}"/>
           
</div>
<div class="form-group">
            <label>MSISDN</label>
            <ui:inputText class="form-control" value="{!v.caseObj.MSISDN__c}"/>
</div>  
    
    
    <div class="form-group">
            <label>Status</label>
            <force:inputField aura:id="Status"  value="{!v.caseObj.Status}"/>
</div>   


-----------------------------------------------------------

controller.js

  create: function(component, event, helper)    {
        
        console.log('Create record');
    
        var caseObj = component.get("v.caseObj");
        
        
        var action = component.get("c.createRecord");
      
        
        action.setParams({
            caseObj : caseObj
        });



-------------------------------------------------------------------

Class.apxc

 @AuraEnabled
    public static void createRecord (Case caseObj){
        
        try{
            System.debug('NovoCasoComponentController::createRecord::caseObj'+ caseObj);
            
            if(caseObj != null){
                insert caseObj;
            }
            
        } catch (Exception ex){
            
        }
        
    }    




Thanks

Hello Folks,

I created a list that loads all attachments related to a custom object, but I need to download them and I am trying to create a link unsuccessfully, someone could help me.
Follow my code

 
AttachmentList.cmp
-------------------------------------------------------------------------------------------------------------




<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" controller="AttachmentListController"> 
    
     
      
     <aura:attribute name="recordId" type="Id"/>
     <aura:attribute name="files" type="List"/>
     <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    
    
    
    <table class="slds-table slds-table_cell-buffer slds-table_bordered">
             <thead>
            <tr class="slds-line-height_reset">
              <th scope="col"><div class="slds-truncate" title="Name">Anexos</div></th>
              <th scope="col"><div class="slds-truncate" title="tipo">Tipo</div></th>

            </tr>
          </thead>
          
        
        <tbody>
           <aura:iteration items="{!v.files}" var="obj">
                <tr>
                    <th scope="row"> <a href="{!'/portal/servlet.shepherd/version/download/'+obj.Id}">{!obj.Title}</a>   </th> 

                    <!-- <th scope="row"> <a href="{!'/portal/servlet/servlet.FileDownload?file='+obj.Id}" >{!obj.Title}</a>   </th> -->
                  
                  <th scope="row"><div class="slds-truncate" title="Type">{!obj.FileType}</div></th>
                    
                   
                   
                    <td>
                    
                        
	        </td>
                </tr>
            </aura:iteration>
          </tbody>
        </table>
    
    
    
    
	
</aura:component>

AttachmentListController.js
------------------------------------------------------------------------------------------------------------



({
	
    

    doInit : function(component, event, helper) {
			  $A.enqueueAction(component.get('c.getList'));
	},
    
    
    doInit : function(component, event, helper) { 
        $A.enqueueAction(component.get('c.getList')); 
    }, 
    
    
    getList: function(component, event, helper) { 
        var action = component.get("c.getContentDocs"); 
        action.setParams( { 
            arecordId : component.get('v.recordId')
        }); 
        action.setCallback(this, function(actionResult) {
            component.set('v.files',actionResult.getReturnValue()); 
        }); 
        $A.enqueueAction(action); 
    },
    
    
    
    
    
    

    
    
})

AttachmentListController.apxc
---------------------------------------------------------------------------------------------------------



public class AttachmentListController {
    
  @AuraEnabled
    public static List<ContentDocument> getContentDocs(Id arecordId) {
        List<ContentDocumentLink> CDLs = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :arecordId];
        if (CDLs.size() < 1) {
            return new List<ContentDocument>();
        }
        List<Id> CDIdList = new List<Id> (); 
        for (ContentDocumentLink nextCDL : CDLs) { 
            CDIdList.add(nextCDL.ContentDocumentId); 
        } 
        List<ContentDocument> entries = [SELECT Id, Title, FileType FROM ContentDocument WHERE Id IN :CDIdList]; 
        return entries;
    }
     
    
    

}

 
Hello Folks,

I am creating a Lightning component to display the list of attachments related to registering a custom object. Could check where I am going wrong, because nothing is displayed.
 
AttachmentList.cmp 
--------------------------------------------------------------------------------- 
<aura:component implements="forceCommunity:availableForAllPageTypes,force:hasRecordId" access="global" controller="AttachmentListController"> <aura:attribute name="recordId" type="Id" required="true"/> <aura:attribute name="files" type="List"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <span class="text-blue"> <!-- <aura:iteration items="{!v.record.Attachments}" var="obj"> --> <aura:iteration items="{!v.files}" var="obj"> {!obj.Title} <br/> </aura:iteration> </span>
 </aura:component>

AttachmentListcontroller.js -------------------------------------------------------------------------------------------------- 

({ 

doInit : function(component, event, helper) { $A.enqueueAction(component.get('c.getList')); }, getList: function(component, event, helper) { var action = component.get("c.getContentDocs"); action.setParams( { arecordId : component.get('v.recordId') }); action.setCallback(this, function(actionResult) { component.set('v.files',actionResult.getReturnValue()); }); $A.enqueueAction(action); }, 

})

AttachmentListController.apxc ------------------------------------------------------------------------------------------------------------ 

public class AttachmentListController
 { 

@AuraEnabled 
public static List<ContentDocument> getContentDocs(Id arecordId) 
{
 List<ContentDocumentLink> CDLs = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :arecordId];

 //List<ContentDocumentLink> CDLs = [SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = :'a08M000000BuU4vIAF']; if (CDLs.size() < 1) return new List<ContentDocument>(); // Make a List of ContentDocument IDs List <Id> CDIdList = new List <Id> (); for (ContentDocumentLink nextCDL : CDLs) { CDIdList.add(nextCDL.ContentDocumentId); } List<ContentDocument> entries = [SELECT Id, Title, FileType FROM ContentDocument WHERE ContentDocument.Id IN :CDIdList]; return entries;
 }
 }



Thanks
Hello guys,

I need to create a redirection through a trigger when updating a record. Can someone help me with some code to meet this need?

I have a visual force page that creates a record and already opens it in edit mode, but when saving it, it redirects to the visualforce page, what I need is to be redirected to the newly created (updated).

Thanks

Hi Folks,

I have two objects:
ParentObject__c (Parent record)
ChildObjetc__c (Child Record)

The relationship between them is master-detail.

I need to create a visualforce page to be able to create a child record, that is, when accessing the details of the parent record, have a custom button that will call the visualforcepage to be able to create a child record, with the parent record id.
Does anyone have any idea code to help me?

Hi all,
 

404/5000
I have two objects:
Object1__c (parent)
Object2__c (child)
Relationship master details.
For the parent object I have two types of records A, B

For the child object 2 types of records 1, 2 then if the parent object is of type A, the layout for the child will only appear 1 and if the parent object is B, the child layout will be only 2.

Someone has some trigger code to be able to do this verification.

 

Thanks!

Folks,


In the Salesforce Lightning Design System portal, show an example of a toast usage as per link below:

https://www.lightningdesignsystem.com/components/toast/


I used this example as the basis for setting it up in an environment.
The environment is configured as described below:

I have an object, called Alert, where the user can include as many alerts as he wants.
Each record of the object is an alert.

Fields of the Alert__c object:

- Name (Alert ID)
- Alert_Type__c (Example: Success, Info, Error, Warning) - User selects the type of alert you want to display
- Alert1__c (Alert message to be displayed)

 

-------------------------------------------------------------------------------

 

I created a component to display the alert on a certain page as per the code below:

 

Alert.cmp
-----------------


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   

    
<aura:attribute name="html" type="List" />
    
    
<aura:attribute name="showToast" type="boolean" default="false"/>
    
<aura:attribute name="Alert" type="Alert__c" default="{'sobjectType': 'Alert__c',
                         'Tipo_de_Alerta__c': '',
                         'Name': '',
                         'Alerta1__c': ''
                          }"/>
    
    
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    
<aura:if isTrue="{!v.showToast}">
    
           <aura:iteration items="{!v.html}" var="lista">        
					<div class="demo-only" style="height: 4rem;">
		
   							 <div class="slds-notify_container slds-is-relative">    
				
        							<div aura:id="alerta" role="status"> 
                                 
                                 <!--  <div id="{!Lista.Name}" role="status">   -->
													<div  class="slds-notify__content">
                            
                                                                <h2 class="slds-text-heading_small ">                
                                                                     <aura:unescapedHtml value="{!lista.Alerta1__c}" />  
                                                                </h2>
                            
                                                    <lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
                                                     iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small"
                                                     class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
                                                     onclick="{!c.close}"/>      
    
													</div>
									</div>
							</div>
					</div>
			</aura:iteration>
    
    
    
    
   

</aura:if>
    
    
    
</aura:component>

AlertController.js
-----------------------





({


   doInit : function(component, event, helper)
    {

  var action = component.get( "c.getMsgs" );

         action.setCallback(this, function(response) 
                           {                               
                             
                               var state = response.getState();

                               if(state == 'SUCCESS')
                               {                                   
                                   var alertMsgList = response.getReturnValue();
                                   var lista = [ ];                                  
                                   
                                   
                                   if(alertMsgList.length > 0)
                                   {                                       
                                       component.set("v.showToast", true);                             
                                   }
                                 
                                   
                                   
                                   for(var i = 0; i < alertMsgList.length; i ++) 
                                   {                                       
                                     
                                       /*
                                       var alerta = alertMsgList[ i ].Alerta1__c;
                                       var tipo = alertMsgList[ i ].Tipo_de_Alerta__c;
                                       var titulo = alertMsgList[ i ].Name;                                       
                                       */
                                       
                                      lista.push(alertMsgList[i]);

      						       }
                                   
                                   
                                   component.set("v.html",lista);
                                 
                                   var tipoAlerta = component.find( "alerta" );
                                   
                                   
                              //     var tipoAlerta = document.getElementById("!v.Alert.Name");
                              
                                                                      
                                              $A.util.addClass( tipoAlerta, "slds-notify" );
                                              $A.util.addClass( tipoAlerta, "slds-notify_toast" );  
                                              $A.util.addClass( tipoAlerta, "slds-theme_success" );  
   
                                   
     }
                               
               
                          else {
                                   console.log("Failed with state: " + state);
                               }
                           }); 
        
        
        $A.enqueueAction(action);
        
  
        
    },

   
    
   close: function(cmp, event, helper) 
    {
   $A.util.addClass(cmp.find('alerta'), "slds-hide");
    //  $A.util.addClass(document.getElementById('{!v.lista.Name}'), "slds-hide");
    },
   
   
       
    
})

AlertController.apxc
-------------------------------------




public class AlertController {
    
    
       
    
 @AuraEnabled
    public static List<Alert__c> getMsgs() {
        
        List<Alert__c> lst = new List<Alert__c>();
        lst = [select Tipo_de_Alerta__c, Name, Alert_Style__c,  Alerta1__c from Alert__c where Data_inicial__c <= :system.now() and Data_final__c >= :system.now()];
        return lst;
    }
    

    
}

What happens is that for every alert found, it needs to display it according to its characteristics:
- Type of alert
- Identification of each alert (For each alert, your type configuration and the close button will be checked)
- Alert message: This setting is the only one that is working, need to interact for each alert by formatting your type to receive the appropriate CSS and the close button for it.

In the Controller.js I put the part that configures the CSS and the separate close button just to test its operation, so it works only for one record, I need to put it to work in each interaction and to each of the records that are found .
That's what I can not do, if anyone can help me, I'll be very grateful.
Thank you

Folks,

I'm setting up a toast alert in salesforce, where a list of alerts will be shown.
Each alert will have to have its own aura: id so that I can modify its behavior, such as alert type and the close button.
Below is my code as it is currently configured, it has the fixed aura id <div aura: id = "alert" role = "status">, needs to be dynamic.
I was thinking of getting the name of each alert object record to pass to the aura id, but I do not know how to do it.
Can anybody help me

Controller.js
-------------------------------------------------------------------

({

   doInit : function(component, event, helper)
    {
  var action = component.get( "c.getMsgs" );
        
        
         action.setCallback(this, function(response) 
                           {                               
                               var state = response.getState();
                               
                               if(state == 'SUCCESS')
                               {                                   
                                   var alertMsgList = response.getReturnValue();
                                   var lista = [ ];                                  
                                   
                                   
                                   if(alertMsgList.length > 0)
                                   {
                                       
                                       component.set("v.showToast", true);
                                              var tipoAlerta = component.find( "alerta" );        
                                              $A.util.addClass( tipoAlerta, "slds-notify" );
                                              $A.util.addClass( tipoAlerta, "slds-notify_toast" );  
                                                                       
                                   }
                                   
                       
                                   
                                   for(var i = 0; i < alertMsgList.length; i ++) 
                                   {                                       
                                       var alerta = alertMsgList[ i ].Alerta1__c;
                                       var tipo = alertMsgList[ i ].Tipo_de_Alerta__c;
                                       var titulo = alertMsgList[ i ].Name;                                       
                                       
                                      lista.push(alerta);
                         
                                       
      						       }
                                   
  									component.set("v.html",lista);                                  
     }
                               
                          else {
                                   console.log("Failed with state: " + state);
                               }
                           }); 
        
        
        $A.enqueueAction(action);
  
        
    },

   
   close: function(cmp, event, helper) 
    {
    $A.util.addClass(cmp.find('alerta'), "slds-hide");
    },
        
})
 
Alert.cmp

------------------------------------------------------------------------------------------


<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   

    
<aura:attribute name="html" type="List" />
    
    
<aura:attribute name="showToast" type="boolean" default="false"/>
    
  
    
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    
<aura:if isTrue="{!v.showToast}">
    
           <aura:iteration items="{!v.html}" var="lista">        
					<div class="demo-only" style="height: 4rem;">
		
   							 <div class="slds-notify_container slds-is-relative">    
				
        							<div aura:id="alerta" role="status">  
													<div  class="slds-notify__content">
                            
                                                                <h2 class="slds-text-heading_small ">                
                                                                     <aura:unescapedHtml value="{!lista}" />  
                                                                </h2>
                            
                                                    <lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
                                                     iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small"
                                                     class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
                                                     onclick="{!c.close}"/>      
    
													</div>
									</div>
							</div>
					</div>
			</aura:iteration>
    
    
    
    
    
</aura:if>
    
    
    
</aura:component>

Thanks

Folks,
I'm configuring the toast, where a list of alerts will be shown, but instead of showing multiple toasts, it is showing only the last one on the list. How do I resolve this issue?

Follow the code

TestAlert.cmp

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:backgroundUtilityItem" access="GLOBAL" controller="AlertController">   

    
<aura:attribute name="html" type="String" />
<aura:attribute name="showToast" type="boolean" default="false"/>
       
<aura:attribute name="Alert" type="Alert__c" default="{'sobjectType': 'Alert__c',
                         'Tipo_de_Alerta__c': '',
                         'Name': '',
                         'Alerta1__c': ''
                          }"/>
    
    
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

<aura:if isTrue="{!v.showToast}">    
    
<div class="demo-only" style="height: 4rem;">
	<div class="slds-notify_container slds-is-relative">    
		<div aura:id="alerta" role="status"> 
	         <div  class="slds-notify__content">

<h2 class="slds-text-heading_small ">                
     <aura:unescapedHtml value="{!v.html}" />  
</h2>
    
                
                
<lightning:buttonIcon iconName="utility:close" variant="bare" alternativeText="Close"
 iconClass="{!v.type == 'warning' ? 'light' : 'dark'}" size="small"
 class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse"
 onclick="{!c.close}"/>      
    
			</div>
		</div>
	</div>
</div>
    </aura:if>
    
</aura:component>
 

TestAlertController.js

({


   doInit : function(component, event, helper)
    {

        
  var action = component.get( "c.getMsgs" ); 

         action.setCallback(this, function(response) 
                           {                               
                               var state = response.getState();
                               
                               if(state == 'SUCCESS')
                               {                                   
                                   var alertMsgList = response.getReturnValue();
                                   
                                   if(alertMsgList.length > 0)
                                   {
                                       
                                       component.set("v.showToast", true);
                                       var tipoAlerta = component.find( "alerta" );        
                                              $A.util.addClass( tipoAlerta, "slds-notify" );
                                              $A.util.addClass( tipoAlerta, "slds-notify_toast" );  
                                       
                                       
                                   }
                                   
                                   
                                   for(var i = 0; i < alertMsgList.length; i ++) 
                                   {                                       
                                       var alerta = alertMsgList[ i ].Alerta1__c;
                                       var tipo = alertMsgList[ i ].Tipo_de_Alerta__c;
                                       var titulo = alertMsgList[ i ].Name;                                       
                                       
                                          
                                       
if	(tipo == 'success')     
            {
                 
// Successs        
     $A.util.addClass( tipoAlerta, "slds-theme_success" );
     component.set("v.html",alerta);  
                
                
            }
                                       
                                       
if	(tipo == 'Info')     
            {   
        
// Info 
     $A.util.addClass( tipoAlerta, "slds-theme_info" ); 
      component.set("v.html",alerta);  
            }


if	(tipo == 'error')     
            {    
// Error  
     $A.util.addClass( tipoAlerta, "slds-theme_error" );
				component.set("v.html",alerta);  
            }                                  
                        
                                       
if	(tipo == 'warning')     
            {                                       
// Warning 

     $A.util.addClass( tipoAlerta, "slds-theme_warning" );
     component.set("v.html",alerta);  
            }     
                                       
                                       
                                       
                                       
          }
     }
                               
                               
                               
                               
                          else {
                                   console.log("Failed with state: " + state);
                               }
                           }); 
        
        
        $A.enqueueAction(action);
        
  
        
    },

   
   close: function(cmp, event, helper) 
    {
    $A.util.addClass(cmp.find('alerta'), "slds-hide");
        
    },
   
   
       
    
})