• Eugenia Pestelli
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
Hi everyone. I created my screen flow with some fields, I have an address field, which I can't make mandatory, I then created a lightining component that shows a simple error message when this field is left blank. I have set the component a visibility, it will only appear when this field is empty. The point is that once this screen appears, there are the standard Back and Next buttons. Back is fine, because the user goes back and fills in the field, the problem is Next, which if the user clicks on it goes to the next step and ends the flow, despite the empty field. I tried hiding next, but even when the address field is filled in, the component is not shown, but neither is the next button, so the user can't do anything. So I was wondering if there was a way to hide the "next" button only under a certain condition (i.e. an empty field). Thank you
Hello everybody, can anyone help me to solve this problem? I have a trigger and its test class to take from sandbox to production. Once brought into production I get this error: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] Stack Trace: Class.TestPreventcontentdocument.testTrigger: line 10, column 1. Now I guess the problem is the Id but how can I fix it?


This is my trigger:

trigger Preventcontentdocument on ContentDocumentLink (after insert) { Set<Id> parentIds = new Set<Id>(); for(ContentDocumentLink cdl : trigger.new){ parentIds.add(cdl.LinkedEntityId); } if(parentIds.size() > 0) { List<Candidate__c> updatecandidatelist = new List<Candidate__c>(); List<Candidate__c> cadlist = [SELECT Id, Curriculum_Attachment__c FROM Candidate__c WHERE Id IN: parentIds]; if(cadlist.size() > 0) { for(Candidate__c cd : cadlist) { cd.Curriculum_Attachment__c = true; updatecandidatelist.add(cd); } update updatecandidatelist; } } }


this is my test class:

@isTest private class TestPreventcontentdocument { // Test that verifies that the trigger sets the Curriculum_Attachment__c field to true // when a new ContentDocumentLink is inserted static testMethod void testTrigger() { //create testdata Candidate__c cad = new Candidate__c(Surname__c='SurnameTest', Name__c='NameTest'); cad inserts; ContentDocumentLink cdl = new ContentDocumentLink(LinkedEntityId = cad.Id, ContentDocumentId ='0693L000001YtCDQA0'); insert cdl; // Verify that the Curriculum_Attachment__c field of the candidate is set to true cad = [SELECT Curriculum_Attachment__c FROM Applicant__c WHERE Id = :cdl.LinkedEntityId]; System.assertEquals(true, cad.Curriculum_Attachment__c); } }

Please help me in this.. thank you
User-added image
hello everyone, I have a problem with this component, in addition to this error appearing, not always, but every now and then, I have these squares with objobj written inside on the display.

Can anyone help me figure out the error?


contenitore
<aura:component controller="SezioniApexCtrl" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
   
    
    <aura:handler event="c:AggiungiPadre" action="{!c.AggiungiPadre}"/>
    <aura:handler event="c:SettoriEvent" action="{!c.AggiungiValSel}"/>
    
    <aura:handler event="c:TogliNipoti" action="{!c.TogliNipote}"/>
    <aura:handler event="c:TogliPadre" action="{!c.TogliPadre}"/>
    
     <aura:attribute name="SettoreUno_Salvato" type="String"/>
     <aura:attribute name="SettoreDue_Salvato" type="String"/>
    
    <aura:attribute name="ListSet" type="String[]"/>
    <aura:attribute name="MappaNonniFigli" type="map"/>
    <aura:attribute name="MappaFigliNipoti" type="map"/>
    
    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="MappaPerTracciareSelezioni" type="Map" default="{}"/>
    <aura:attribute name="StringaPerTracciareSelezioni" type="String[]" />
    <lightning:spinner aura:id="mySpinner" size="large" />
    <lightning:accordion activeSectionName="B">
        <aura:iteration items="{!v.ListSet}" var="Nonno">
            <c:AccordianComponent Mylabel="{!Nonno}" MappaNonniFigli="{!v.MappaNonniFigli}" MappaFigliNipoti="{!v.MappaFigliNipoti}"
                                   MappaPerTracciareSelezioni="{!v.MappaPerTracciareSelezioni}" SettoreUno_Salvato="{!v.SettoreUno_Salvato}"
                                  SettoreDue_Salvato="{!v.SettoreDue_Salvato}"  />
        </aura:iteration>
    </lightning:accordion>
    
     <ui:button label="Save Sectors" press="{!c.saveField}"/>
</aura:component>
component

<aura:component >
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    
    <aura:attribute name="Mylabel" type="String"/>
    <aura:attribute name="MappaNonniFigli" type="map"/>
    <aura:attribute name="MappaFigliNipoti" type="map"/>
    <aura:attribute name="ListFigli" type="String[]"/>
    
    <aura:attribute name="SettoreUno_Salvato" type="String"/>
    <aura:attribute name="SettoreDue_Salvato" type="String"/>
    
    <aura:attribute name="MappaPerTracciareSelezioni" type="Map" default="{}"/>
    
     
    <lightning:accordionSection aura:id="First" name="First_Set" label="{!v.Mylabel}" >
        <aura:iteration items="{!v.ListFigli}" var="Figlio">
            <c:FirstInputComponent Mylabel="{!Figlio}" MappaFigliNipoti="{!v.MappaFigliNipoti}" 
                                   MappaPerTracciareSelezioni="{!v.MappaPerTracciareSelezioni}" SettoreUno_Salvato="{!v.SettoreUno_Salvato}"
                                   SettoreDue_Salvato="{!v.SettoreDue_Salvato}" />
            <br>
            
            </br>
        </aura:iteration>
    </lightning:accordionSection>
</aura:component>

controller

({
    doInit : function(component, event, helper) {
        var map = component.get("v.MappaNonniFigli");
        var key =  component.get("v.Mylabel");
        console.log("***map: "+map);
        console.log("***key: "+key);
        console.log("***ListFigli: "+JSON.stringify(map[key]));
        component.set("v.ListFigli",map[key]);
    }
})

apexcode
public with sharing class SezioniApexCtrl {
    
    
    @AuraEnabled
    public static List<string> getSettori() {
        
        List<string> Settori = new List<string>();
        set<string> sett = new set<string>();
        For(Settore__c s: Settore__c.getall().values()){
            sett.add(s.First_Set__c);
        }
        for(string s:sett){
            Settori.add(s);
        }
        
        Settori.sort();
        system.debug('sett: '+Settori);
        
        
        return Settori;
    }
    
    @AuraEnabled
    public static Map<string, list<string>> getSecondSet() {
        
        map<String, list<string>> m1= new  map<String, list<string>>();
        
        For(Settore__c s: Settore__c.getall().values()){
            if(m1.get(s.First_Set__c) == null)
                m1.put(s.First_Set__c,new list<string>());
            set<string> st=new set<string>(m1.get(s.First_Set__c));
            if(!st.contains(s.Second_Set__c))
                m1.get(s.First_Set__c).add(s.Second_Set__c);
        }
        
        system.debug('Mappa: '+m1);
        
        return m1;       
        
    }
    
    @AuraEnabled
    public static Map<string, list<string>> getThirdSet(){
        
        map<String, list<string>> m2= new  map<String, list<string>>();
        
        For(Settore__c s: Settore__c.getall().values()){
            if(m2.get(s.Second_Set__c) == null)
                m2.put(s.Second_Set__c,new list<string>());
            m2.get(s.Second_Set__c).add(s.Third_Set__c);
        }
        
        return m2;
        
    }
    
    @AuraEnabled
    public static void  saveSett (string MyMap, String AccId){

        
        // Map<String, Object> MappaSelezioni = (Map<String, Object>)JSON.deserializeUntyped(MyMap);
        Map<String, List<String>> MappaSelezioni = (Map<String,List<String>>) JSON.deserialize(MyMaP, Map<String,List<String>>.class);
        
        String Nipoti = '';
        String Padri='';
        String Nonni='';
        Set<String> NonniSenzaDoppioni=new Set<String>();
        
        For(String s :MappaSelezioni.keySet()){
            Padri += s+';';
            For(string l: MappaSelezioni.get(s)){
               Nipoti += l + ';';
            }
        }
        system.debug('****Nipoti: '+Nipoti);
        List <account> aziende= new List<account>([SELECT id,Macro_Settore__c, SottoSettore1__c, Sottosettore2__c from Account where id =: AccId Limit 1]);
        if(aziende!=null && aziende.size()>0){
            List<Settore__c> MacroSettori=new List<Settore__c>([SELECT First_Set__c from Settore__c where Second_Set__c =:MappaSelezioni.keySet()]);
            
            For(Settore__c n : MacroSettori){ NonniSenzaDoppioni.add(n.First_Set__c);}
            For(String m : NonniSenzaDoppioni){ Nonni += m + ';'; }
            
            For(account a:aziende){
                a.Sottosettore1__c = Padri;
                a.Sottosettore2__c = Nipoti;
                a.Macro_Settore__c = Nonni;
                update a;}
        }
        }
    
    @AuraEnabled
    public static Map<String,String> AggiornaListaSelezionata (String mappaStringataFigliNipoti){
        String stringaFigliNipoti='';
        Map<String,String> mappaSelezioni=new Map<String,String>();
        
        return mappaSelezioni;
    }
    
    //AGGIUNTA
    @AuraEnabled
    public static List<String>  PopolaCheckFigli (String AccId){
        system.debug('AccId:   ****'+AccId);        
        Set<String> SetConSelezioni=new Set<String>();
        Set<String> SetConSelezioniNipoti=new Set<String>();
        List<String> ListaConSelezioni=new List<String>();
        List<String> ListaConSelezioniNipoti=new List<String>();
        
        List<Account> AccountGiaMemorizzato= new List<Account>([SELECT SottoSettore1__c from Account where id =: AccId]);
           
        For(Account a : AccountGiaMemorizzato){
            SetConSelezioni.add(a.SottoSettore1__c);
        }
        system.debug('SetConSelezioni  '+SetConSelezioni);
        
        For(String s : SetConSelezioni){
            ListaConSelezioni.add(s);
        }
        
        return ListaConSelezioni;
        
    }
    
    @AuraEnabled
    public static List<String>  PopolaCheckNipoti (String AccId){
        system.debug('AccId:   ****'+AccId);        
        
        Set<String> SetConSelezioniNipoti=new Set<String>();
        List<String> ListaConSelezioniNipoti=new List<String>();
        
        List<Account> AccountGiaMemorizzato= new List<Account>([SELECT SottoSettore2__c from Account where id =: AccId]);
        
       
        
        For(Account a : AccountGiaMemorizzato){
            SetConSelezioniNipoti.add(a.SottoSettore2__c);
        }
        system.debug('SetConSelezioni  '+SetConSelezioniNipoti);
       
        For(String s : SetConSelezioniNipoti){
            ListaConSelezioniNipoti.add(s);
        }
        
        return ListaConSelezioniNipoti;
        
    }
    
    @AuraEnabled
    public static Map<String, List<String>>  PopolaMappaIniziale (String AccId){
        system.debug('AccId:   ****'+AccId);        
        
        Map<String, List<String>> MappaDatiSalvati=new Map<String, List<String>>();
        List<String> NipotiSave= new List<String>();
        List<String> FigliSave= new List<String>();
        List<String> NipotiSaveList= new List<String>();
        
        List<Account> AccountGiaMemorizzato= new List<Account>();
        AccountGiaMemorizzato=[SELECT SottoSettore1__c, SottoSettore2__c from Account where id =: AccId];
        if(AccountGiaMemorizzato!=null && AccountGiaMemorizzato.size()>0){
            for(account a:AccountGiaMemorizzato){
               if(String.isNotBlank(a.SottoSettore1__c) && a.SottoSettore1__c.contains(';')) FigliSave=(a.SottoSettore1__c).split(';');
               if(String.isNotBlank(a.SottoSettore2__c) && a.SottoSettore2__c.contains(';')) NipotiSave=(a.SottoSettore2__c).split(';');}}
        
  
         map<String, list<string>> m2= new  map<String, list<string>>();
        
        For(Settore__c s: Settore__c.getall().values()){
            if(m2.get(s.Second_Set__c) == null && String.isNotBlank(s.Third_Set__c))
                m2.put(s.Second_Set__c,new list<string>());
            m2.get(s.Second_Set__c).add(s.Third_Set__c);
        }
        
        for(String s: FigliSave){
            for(String s2 : NipotiSave){
                if((m2.get(s)).contains(s2)){
                   NipotiSaveList.add(s2);
                }
            }
            MappaDatiSalvati.put(s,NipotiSaveList);
        }
            
       
        system.debug(' Mappa Dati Salvati: '+MappaDatiSalvati);
        return MappaDatiSalvati;
        
    }
    //AGGIUNTA
    
}
User-added image
Hello everybody, can anyone help me to solve this problem? I have a trigger and its test class to take from sandbox to production. Once brought into production I get this error: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] Stack Trace: Class.TestPreventcontentdocument.testTrigger: line 10, column 1. Now I guess the problem is the Id but how can I fix it?


This is my trigger:

trigger Preventcontentdocument on ContentDocumentLink (after insert) { Set<Id> parentIds = new Set<Id>(); for(ContentDocumentLink cdl : trigger.new){ parentIds.add(cdl.LinkedEntityId); } if(parentIds.size() > 0) { List<Candidate__c> updatecandidatelist = new List<Candidate__c>(); List<Candidate__c> cadlist = [SELECT Id, Curriculum_Attachment__c FROM Candidate__c WHERE Id IN: parentIds]; if(cadlist.size() > 0) { for(Candidate__c cd : cadlist) { cd.Curriculum_Attachment__c = true; updatecandidatelist.add(cd); } update updatecandidatelist; } } }


this is my test class:

@isTest private class TestPreventcontentdocument { // Test that verifies that the trigger sets the Curriculum_Attachment__c field to true // when a new ContentDocumentLink is inserted static testMethod void testTrigger() { //create testdata Candidate__c cad = new Candidate__c(Surname__c='SurnameTest', Name__c='NameTest'); cad inserts; ContentDocumentLink cdl = new ContentDocumentLink(LinkedEntityId = cad.Id, ContentDocumentId ='0693L000001YtCDQA0'); insert cdl; // Verify that the Curriculum_Attachment__c field of the candidate is set to true cad = [SELECT Curriculum_Attachment__c FROM Applicant__c WHERE Id = :cdl.LinkedEntityId]; System.assertEquals(true, cad.Curriculum_Attachment__c); } }

Please help me in this.. thank you