• chaitanya motupalli 13
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 7
    Replies
Hi, i have written trigger on opportunity while inset or update. this logic compare opp with already existed prodcuts on org. if it maches we are throughing an error message on opp record. but i am getting null pointer excpetion. please any help

trigger helloOppTrg on Opportunity (after insert,after update) {
    
    list<Id>accIdlst          = new list<Id>();
    list<string>oppOrdernolst = new list<string>();
    for (Opportunity objOpp : Trigger.new) {
        oppOrdernolst.add(objOpp.OrderNumber__c);
        accIdlst.add(objOpp.AccountId);
    }
    system.debug('opp order no entering'+oppOrdernolst);
    system.debug('account id entering'+accIdlst);
    list<Opportunity> oppwithaccount = new list<Opportunity>();
    oppwithaccount = [SELECT Id,AccountId,OrderNumber__c,Account.Name FROM Opportunity WHERE AccountId=:accIdlst];
    list<string>accname= new list<string>();
    for(Opportunity acc:oppwithaccount){
        accname.add(acc.Account.Name);
    }
    system.debug('account name'+accname);
    list<Product2> matchProduct = new list<Product2>();
    matchProduct = [SELECT Id, IsActive, ProductCode, Name FROM Product2
                    WHERE ProductCode =:oppOrdernolst AND Name =:accname];
    system.debug('product records'+matchProduct);
    
    for(Opportunity objOpp:oppwithaccount) {
        system.debug('opp id top'+objOpp.id);
     
        for(Product2 proloop : matchProduct) {
            system.debug('inside second loop');
            if(proloop.IsActive==false && proloop.ProductCode==objOpp.OrderNumber__c
               && proloop.Name==objOpp.Account.Name){
                   system.debug('inside third loop');
                   system.debug('opp id'+objOpp.id); // Id value is showing properly
                    Opportunity oppfromtriggernewmap = Trigger.newMap.get(objOpp.id); // but here it reurns null value
                    system.debug('just opp before error msg'+oppfromtriggernewmap); // Null
                   oppfromtriggernewmap.OrderNumber__c.addError('check is false so can not update/insert record MACHED');// Null pointer exception 
               }
        }
    }
    
}
Hi I have written below apex method for LWC but i am getting "missing return statement required return type" error when trying to deploy to org.
please help me where i am doing wrong here.

public with sharing class bikeSearchResultController {
@AuraEnabled(cacheable=true)
public static list<Car__c> cardetailsapexmethod(string cartypeid){
    try {
        if(String.isEmpty(cartypeid)){
           return [SELECT Id,Available_For_Rent__c,Build_Year__c,Car_Type__c,Name,Picture__c
                   FROM Car__c];
        }else 
        if(!String.isEmpty(cartypeid)){
            return [SELECT Id,Available_For_Rent__c,Build_Year__c,Car_Type__c,Name,Picture__c
                    FROM Car__c
                    WHERE Car_Type__c=:cartypeid];
        }
    } catch (Exception e) {
        throw new AuraHandledException(e.getMessage());
    }
    
}
}

 
trigger JJ_ContentDocument on ContentDocument (before delete) {
    
    if(trigger.isbefore &&trigger.isdelete){
        JJ_ContentDocumentTriggerHandler.beforeDeleteCountCRAttachments(Trigger.old);
    }
}


public class JJ_ContentDocumentTriggerHandler {
    
    public static void beforeDeleteCountCRAttachments(List<ContentDocument> ConDoclst){
        set<id> cdocid = new set<id>(); 
        set<id> clinkparids = new set<id>(); 
        
        for(ContentDocument cd : ConDoclst){
            cdocid.add(cd.id); 
        }
        list<ContentDocumentLink> clinks = [select Id, LinkedEntityId, ContentDocumentId from ContentDocumentLink where ContentDocumentId IN :cdocid];
        for(ContentDocumentLink cl : clinks){
            clinkparids.add(cl.LinkedEntityId);
        }
        
        list<Coaching_Reports_Attachments_JNJ__c> coachinglist = [select id,JJ_No_Of_Content_Documents__c,No_of_Attachments_JNJ__c,(select Id, LinkedEntityId, ContentDocumentId from ContentDocumentLinks) from Coaching_Reports_Attachments_JNJ__c where id IN:clinkparids];
        for(Coaching_Reports_Attachments_JNJ__c a :coachinglist){
            integer exsiz = a.ContentDocumentLinks.size();
            integer cdocsiz = cdocid.size();
            integer coutsiz = exsiz - cdocsiz;
            a.JJ_No_Of_Content_Documents__c= coutsiz;
        }
        if(coachinglist !=null && coachinglist.size()>0){
            try{
                update coachinglist;
            }catch(DmlException  ex) {
                system.debug('error message is'+ex.getMessage());
            }
            
        }
    }
    
}

trigger JJ_ContentDocumentLinkTrigger on ContentDocumentLink (after insert, before delete, after update, before update) {
    if(trigger.isInsert && trigger.isafter){
        JJ_ContentDocumentLinkTriggerHandler.updateJCPAttachments(Trigger.new);
        JJ_ContentDocumentLinkTriggerHandler.afterinsertcountCRAttachmentsAndNotes(Trigger.new);
    }
    
    if(trigger.isdelete && trigger.isbefore){
        JJ_ContentDocumentLinkTriggerHandler.beforedeletecountCRAttachmentsAndNotes(Trigger.old);
     }   
}


    public static void beforedeletecountCRAttachmentsAndNotes(list<ContentDocumentLink> ConDocLinklst){
     
        set<id> cdocid = new set<id>();
        set<id> deltinglinkid = new set<id>();
        for(ContentDocumentLink cl : ConDocLinklst){
            cdocid.add(cl.LinkedEntityId);
            deltinglinkid.add(cl.ContentDocumentId);
        }
        list<Coaching_Reports_Attachments_JNJ__c> coachinglist = [SELECT id,JJ_No_Of_Content_Documents__c,No_of_Attachments_JNJ__c,
                                                                  (SELECT Id, LinkedEntityId, ContentDocumentId 
                                                                   FROM ContentDocumentLinks) 
                                                                   FROM Coaching_Reports_Attachments_JNJ__c 
                                                                   WHERE id IN:cdocid];
        for(Coaching_Reports_Attachments_JNJ__c a :coachinglist){
            integer exsiz = a.ContentDocumentLinks.size();
            integer cdocsiz = deltinglinkid.size();
            integer coutsiz = exsiz -cdocsiz;
            a.JJ_No_Of_Content_Documents__c= coutsiz;
        }
        if(coachinglist !=null && coachinglist.size()>0){
            try{
               update coachinglist;
               system.debug('complete list'+coachinglist);
            }catch(DmlException ex) {
                system.debug('error message is'+ex.getMessage());
            }
         }
    }
 // Sample Test method for contentdocumentlink trigger
@isTest
    static void testDataMethod2(){
        ContentVersion contentVersionInserttwo = new ContentVersion(
            Title = 'Testtwo',
            PathOnClient = 'Testtwo.jpg',
            VersionData = Blob.valueOf('Test Content Data two'),
            IsMajorVersion = true
        );
        insert contentVersionInserttwo;
         ContentVersion contentVersionInsertthree = new ContentVersion(
            Title = 'Testthree',
            PathOnClient = 'Testthree.jpg',
            VersionData = Blob.valueOf('Test Content Data three'),
            IsMajorVersion = true
        );
        insert contentVersionInsertthree;

        Id conDocId2 = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:contentVersionInserttwo.Id].ContentDocumentId;
        Id conDocId3 = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:contentVersionInsertthree.Id].ContentDocumentId;

        Profile p = [SELECT Id FROM Profile WHERE Name='JNJ DM - Sampling View'];
        
        User u = new User(Alias = 'standt', Email='standardusertwo@testorg.com',
                          EmailEncodingKey='UTF-8', LastName='Testingtwo', LanguageLocaleKey='en_US',
                          LocaleSidKey='en_US', ProfileId = p.Id,TimeZoneSidKey='America/Los_Angeles',
                          UserName='testpermissionsetuserchaitu@testorg.com');
        insert u;
        Survey_Target_vod__c surobjrec = new Survey_Target_vod__c();
        surobjrec.Employee_vod__c = u.Id;
        surobjrec.Coaching_End_Date_JNJ__c=Date.today()+2;
        surobjrec.Name='Sample name';
        surobjrec.Start_Date_vod__c=Date.today();
        surobjrec.End_Date_vod__c=Date.today()+7;
        insert surobjrec;
        Coaching_Reports_Attachments_JNJ__c CRArecord = new Coaching_Reports_Attachments_JNJ__c();
        CRArecord.SurveytargetCR__c=surobjrec.Id; 
        insert CRArecord;
        List<ContentDocumentLink> cdlList = new List<ContentDocumentLink>();
        ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId = conDocId2;
        cdl.ShareType = 'V';
        cdl.LinkedEntityId = CRArecord.Id;
        cdlList.add(cdl);
        ContentDocumentLink cdl1 = new ContentDocumentLink();
        cdl1.ContentDocumentId = conDocId3;
        cdl1.LinkedEntityId = CRArecord.Id;
        cdl1.ShareType = 'V';
        cdlList.add(cdl1);
        Insert cdlList;
         List<ContentDocumentLink> cdldeleteList = [SELECT id,LinkedEntityId FROM ContentDocumentLink where LinkedEntityId=:CRArecord.Id];
        delete cdldeleteList;
        Test.startTest();
        JJ_ContentDocumentLinkTriggerHandler.afterinsertcountCRAttachmentsAndNotes(cdlList);
        JJ_ContentDocumentLinkTriggerHandler.beforedeletecountCRAttachmentsAndNotes(cdlList);
        Test.stopTest();
    }

// For content Document

@isTest
public class JJ_ContentDocumentTriggerHandler_Test {
@isTest
    static void testDataMethod2(){
        List<ContentVersion> converList = new List<ContentVersion>();
        ContentVersion contentVersionInserttwo = new ContentVersion(
            Title = 'Testfour',
            PathOnClient = 'Testfour.jpg',
            VersionData = Blob.valueOf('Test Content Data four'),
            IsMajorVersion = true
        );
       
        converList.add(contentVersionInserttwo);
         ContentVersion contentVersionInsertthree = new ContentVersion(
            Title = 'Testfive',
            PathOnClient = 'Testfive.jpg',
            VersionData = Blob.valueOf('Test Content Data five'),
            IsMajorVersion = true
        );
       
        converList.add(contentVersionInsertthree);
        insert converList;
       
        List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
       system.debug('documents are'+documents);      
        Profile p = [SELECT Id FROM Profile WHERE Name='JNJ DM - Sampling View'];
        
        User u = new User(Alias = 'standt', Email='standardusertwo@testorg.com',
                          EmailEncodingKey='UTF-8', LastName='Testingtwo', LanguageLocaleKey='en_US',
                          LocaleSidKey='en_US', ProfileId = p.Id,TimeZoneSidKey='America/Los_Angeles',
                          UserName='testpermissionsetuserchaitu@testorg.com');
        insert u;
        Survey_Target_vod__c surobjrec = new Survey_Target_vod__c();
        surobjrec.Employee_vod__c = u.Id;
        surobjrec.Coaching_End_Date_JNJ__c=Date.today()+2;
        surobjrec.Name='Sample name';
        surobjrec.Start_Date_vod__c=Date.today();
        surobjrec.End_Date_vod__c=Date.today()+7;
        insert surobjrec;
        Coaching_Reports_Attachments_JNJ__c CRArecord = new Coaching_Reports_Attachments_JNJ__c();
        CRArecord.SurveytargetCR__c=surobjrec.Id; 
        insert CRArecord;
        List<ContentDocumentLink> cdlList = new List<ContentDocumentLink>();
        ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId = documents[0].Id;
        cdl.ShareType = 'V';
        cdl.LinkedEntityId = CRArecord.Id;
        cdlList.add(cdl);
        ContentDocumentLink cd2 = new ContentDocumentLink();
        cd2.ContentDocumentId = documents[1].Id;
        cd2.LinkedEntityId = CRArecord.Id;
        cd2.ShareType = 'V';
        cdlList.add(cd2);
        Insert cdlList;
      
        List<ContentDocumentLink> cdldeleteList = [SELECT id,ContentDocumentId,LinkedEntityId FROM ContentDocumentLink where ContentDocumentId =: documents[0].Id];
       
        List<ContentDocument> documentstodelete = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
        delete documentstodelete;
        
        CRArecord.JJ_No_Of_Content_Documents__c=documentstodelete.size();
       
        update CRArecord;
        Test.startTest();
        JJ_ContentDocumentTriggerHandler.beforeDeleteCountCRAttachments(documents);
        Test.stopTest();
    }
}
Hi I have LWC along with apex class.
I have written @wire for imperative call purposes. there is no issue in apex class by placing try catch and checked debug logs there is no error. infact apex class returning records properly. still in LWC js i getting this error.

LWC JS:
@wire(GETCARDETAILS,{idofcartype:'$childretivedid'})
    childdata({data, error}){
     if(data){
        console.log('apex data is',data);
        this.cardetailsjs = data;
      }else if(error){
        console.log('error is coming',error);
        console.log('error stringify',JSON.stringify(error));
        this.showbool=false;
        this.showToast('ERROR', error.body.message, 'error');
      }
    }

In the above code, its going directly to else part and showing an error msg on the console like like below.
Error msg on consoleplease let me know where I am missing code.
 
Hi, i have written trigger on opportunity while inset or update. this logic compare opp with already existed prodcuts on org. if it maches we are throughing an error message on opp record. but i am getting null pointer excpetion. please any help

trigger helloOppTrg on Opportunity (after insert,after update) {
    
    list<Id>accIdlst          = new list<Id>();
    list<string>oppOrdernolst = new list<string>();
    for (Opportunity objOpp : Trigger.new) {
        oppOrdernolst.add(objOpp.OrderNumber__c);
        accIdlst.add(objOpp.AccountId);
    }
    system.debug('opp order no entering'+oppOrdernolst);
    system.debug('account id entering'+accIdlst);
    list<Opportunity> oppwithaccount = new list<Opportunity>();
    oppwithaccount = [SELECT Id,AccountId,OrderNumber__c,Account.Name FROM Opportunity WHERE AccountId=:accIdlst];
    list<string>accname= new list<string>();
    for(Opportunity acc:oppwithaccount){
        accname.add(acc.Account.Name);
    }
    system.debug('account name'+accname);
    list<Product2> matchProduct = new list<Product2>();
    matchProduct = [SELECT Id, IsActive, ProductCode, Name FROM Product2
                    WHERE ProductCode =:oppOrdernolst AND Name =:accname];
    system.debug('product records'+matchProduct);
    
    for(Opportunity objOpp:oppwithaccount) {
        system.debug('opp id top'+objOpp.id);
     
        for(Product2 proloop : matchProduct) {
            system.debug('inside second loop');
            if(proloop.IsActive==false && proloop.ProductCode==objOpp.OrderNumber__c
               && proloop.Name==objOpp.Account.Name){
                   system.debug('inside third loop');
                   system.debug('opp id'+objOpp.id); // Id value is showing properly
                    Opportunity oppfromtriggernewmap = Trigger.newMap.get(objOpp.id); // but here it reurns null value
                    system.debug('just opp before error msg'+oppfromtriggernewmap); // Null
                   oppfromtriggernewmap.OrderNumber__c.addError('check is false so can not update/insert record MACHED');// Null pointer exception 
               }
        }
    }
    
}
trigger JJ_ContentDocument on ContentDocument (before delete) {
    
    if(trigger.isbefore &&trigger.isdelete){
        JJ_ContentDocumentTriggerHandler.beforeDeleteCountCRAttachments(Trigger.old);
    }
}


public class JJ_ContentDocumentTriggerHandler {
    
    public static void beforeDeleteCountCRAttachments(List<ContentDocument> ConDoclst){
        set<id> cdocid = new set<id>(); 
        set<id> clinkparids = new set<id>(); 
        
        for(ContentDocument cd : ConDoclst){
            cdocid.add(cd.id); 
        }
        list<ContentDocumentLink> clinks = [select Id, LinkedEntityId, ContentDocumentId from ContentDocumentLink where ContentDocumentId IN :cdocid];
        for(ContentDocumentLink cl : clinks){
            clinkparids.add(cl.LinkedEntityId);
        }
        
        list<Coaching_Reports_Attachments_JNJ__c> coachinglist = [select id,JJ_No_Of_Content_Documents__c,No_of_Attachments_JNJ__c,(select Id, LinkedEntityId, ContentDocumentId from ContentDocumentLinks) from Coaching_Reports_Attachments_JNJ__c where id IN:clinkparids];
        for(Coaching_Reports_Attachments_JNJ__c a :coachinglist){
            integer exsiz = a.ContentDocumentLinks.size();
            integer cdocsiz = cdocid.size();
            integer coutsiz = exsiz - cdocsiz;
            a.JJ_No_Of_Content_Documents__c= coutsiz;
        }
        if(coachinglist !=null && coachinglist.size()>0){
            try{
                update coachinglist;
            }catch(DmlException  ex) {
                system.debug('error message is'+ex.getMessage());
            }
            
        }
    }
    
}

trigger JJ_ContentDocumentLinkTrigger on ContentDocumentLink (after insert, before delete, after update, before update) {
    if(trigger.isInsert && trigger.isafter){
        JJ_ContentDocumentLinkTriggerHandler.updateJCPAttachments(Trigger.new);
        JJ_ContentDocumentLinkTriggerHandler.afterinsertcountCRAttachmentsAndNotes(Trigger.new);
    }
    
    if(trigger.isdelete && trigger.isbefore){
        JJ_ContentDocumentLinkTriggerHandler.beforedeletecountCRAttachmentsAndNotes(Trigger.old);
     }   
}


    public static void beforedeletecountCRAttachmentsAndNotes(list<ContentDocumentLink> ConDocLinklst){
     
        set<id> cdocid = new set<id>();
        set<id> deltinglinkid = new set<id>();
        for(ContentDocumentLink cl : ConDocLinklst){
            cdocid.add(cl.LinkedEntityId);
            deltinglinkid.add(cl.ContentDocumentId);
        }
        list<Coaching_Reports_Attachments_JNJ__c> coachinglist = [SELECT id,JJ_No_Of_Content_Documents__c,No_of_Attachments_JNJ__c,
                                                                  (SELECT Id, LinkedEntityId, ContentDocumentId 
                                                                   FROM ContentDocumentLinks) 
                                                                   FROM Coaching_Reports_Attachments_JNJ__c 
                                                                   WHERE id IN:cdocid];
        for(Coaching_Reports_Attachments_JNJ__c a :coachinglist){
            integer exsiz = a.ContentDocumentLinks.size();
            integer cdocsiz = deltinglinkid.size();
            integer coutsiz = exsiz -cdocsiz;
            a.JJ_No_Of_Content_Documents__c= coutsiz;
        }
        if(coachinglist !=null && coachinglist.size()>0){
            try{
               update coachinglist;
               system.debug('complete list'+coachinglist);
            }catch(DmlException ex) {
                system.debug('error message is'+ex.getMessage());
            }
         }
    }
 // Sample Test method for contentdocumentlink trigger
@isTest
    static void testDataMethod2(){
        ContentVersion contentVersionInserttwo = new ContentVersion(
            Title = 'Testtwo',
            PathOnClient = 'Testtwo.jpg',
            VersionData = Blob.valueOf('Test Content Data two'),
            IsMajorVersion = true
        );
        insert contentVersionInserttwo;
         ContentVersion contentVersionInsertthree = new ContentVersion(
            Title = 'Testthree',
            PathOnClient = 'Testthree.jpg',
            VersionData = Blob.valueOf('Test Content Data three'),
            IsMajorVersion = true
        );
        insert contentVersionInsertthree;

        Id conDocId2 = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:contentVersionInserttwo.Id].ContentDocumentId;
        Id conDocId3 = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:contentVersionInsertthree.Id].ContentDocumentId;

        Profile p = [SELECT Id FROM Profile WHERE Name='JNJ DM - Sampling View'];
        
        User u = new User(Alias = 'standt', Email='standardusertwo@testorg.com',
                          EmailEncodingKey='UTF-8', LastName='Testingtwo', LanguageLocaleKey='en_US',
                          LocaleSidKey='en_US', ProfileId = p.Id,TimeZoneSidKey='America/Los_Angeles',
                          UserName='testpermissionsetuserchaitu@testorg.com');
        insert u;
        Survey_Target_vod__c surobjrec = new Survey_Target_vod__c();
        surobjrec.Employee_vod__c = u.Id;
        surobjrec.Coaching_End_Date_JNJ__c=Date.today()+2;
        surobjrec.Name='Sample name';
        surobjrec.Start_Date_vod__c=Date.today();
        surobjrec.End_Date_vod__c=Date.today()+7;
        insert surobjrec;
        Coaching_Reports_Attachments_JNJ__c CRArecord = new Coaching_Reports_Attachments_JNJ__c();
        CRArecord.SurveytargetCR__c=surobjrec.Id; 
        insert CRArecord;
        List<ContentDocumentLink> cdlList = new List<ContentDocumentLink>();
        ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId = conDocId2;
        cdl.ShareType = 'V';
        cdl.LinkedEntityId = CRArecord.Id;
        cdlList.add(cdl);
        ContentDocumentLink cdl1 = new ContentDocumentLink();
        cdl1.ContentDocumentId = conDocId3;
        cdl1.LinkedEntityId = CRArecord.Id;
        cdl1.ShareType = 'V';
        cdlList.add(cdl1);
        Insert cdlList;
         List<ContentDocumentLink> cdldeleteList = [SELECT id,LinkedEntityId FROM ContentDocumentLink where LinkedEntityId=:CRArecord.Id];
        delete cdldeleteList;
        Test.startTest();
        JJ_ContentDocumentLinkTriggerHandler.afterinsertcountCRAttachmentsAndNotes(cdlList);
        JJ_ContentDocumentLinkTriggerHandler.beforedeletecountCRAttachmentsAndNotes(cdlList);
        Test.stopTest();
    }

// For content Document

@isTest
public class JJ_ContentDocumentTriggerHandler_Test {
@isTest
    static void testDataMethod2(){
        List<ContentVersion> converList = new List<ContentVersion>();
        ContentVersion contentVersionInserttwo = new ContentVersion(
            Title = 'Testfour',
            PathOnClient = 'Testfour.jpg',
            VersionData = Blob.valueOf('Test Content Data four'),
            IsMajorVersion = true
        );
       
        converList.add(contentVersionInserttwo);
         ContentVersion contentVersionInsertthree = new ContentVersion(
            Title = 'Testfive',
            PathOnClient = 'Testfive.jpg',
            VersionData = Blob.valueOf('Test Content Data five'),
            IsMajorVersion = true
        );
       
        converList.add(contentVersionInsertthree);
        insert converList;
       
        List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
       system.debug('documents are'+documents);      
        Profile p = [SELECT Id FROM Profile WHERE Name='JNJ DM - Sampling View'];
        
        User u = new User(Alias = 'standt', Email='standardusertwo@testorg.com',
                          EmailEncodingKey='UTF-8', LastName='Testingtwo', LanguageLocaleKey='en_US',
                          LocaleSidKey='en_US', ProfileId = p.Id,TimeZoneSidKey='America/Los_Angeles',
                          UserName='testpermissionsetuserchaitu@testorg.com');
        insert u;
        Survey_Target_vod__c surobjrec = new Survey_Target_vod__c();
        surobjrec.Employee_vod__c = u.Id;
        surobjrec.Coaching_End_Date_JNJ__c=Date.today()+2;
        surobjrec.Name='Sample name';
        surobjrec.Start_Date_vod__c=Date.today();
        surobjrec.End_Date_vod__c=Date.today()+7;
        insert surobjrec;
        Coaching_Reports_Attachments_JNJ__c CRArecord = new Coaching_Reports_Attachments_JNJ__c();
        CRArecord.SurveytargetCR__c=surobjrec.Id; 
        insert CRArecord;
        List<ContentDocumentLink> cdlList = new List<ContentDocumentLink>();
        ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId = documents[0].Id;
        cdl.ShareType = 'V';
        cdl.LinkedEntityId = CRArecord.Id;
        cdlList.add(cdl);
        ContentDocumentLink cd2 = new ContentDocumentLink();
        cd2.ContentDocumentId = documents[1].Id;
        cd2.LinkedEntityId = CRArecord.Id;
        cd2.ShareType = 'V';
        cdlList.add(cd2);
        Insert cdlList;
      
        List<ContentDocumentLink> cdldeleteList = [SELECT id,ContentDocumentId,LinkedEntityId FROM ContentDocumentLink where ContentDocumentId =: documents[0].Id];
       
        List<ContentDocument> documentstodelete = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
        delete documentstodelete;
        
        CRArecord.JJ_No_Of_Content_Documents__c=documentstodelete.size();
       
        update CRArecord;
        Test.startTest();
        JJ_ContentDocumentTriggerHandler.beforeDeleteCountCRAttachments(documents);
        Test.stopTest();
    }
}
Hi I have LWC along with apex class.
I have written @wire for imperative call purposes. there is no issue in apex class by placing try catch and checked debug logs there is no error. infact apex class returning records properly. still in LWC js i getting this error.

LWC JS:
@wire(GETCARDETAILS,{idofcartype:'$childretivedid'})
    childdata({data, error}){
     if(data){
        console.log('apex data is',data);
        this.cardetailsjs = data;
      }else if(error){
        console.log('error is coming',error);
        console.log('error stringify',JSON.stringify(error));
        this.showbool=false;
        this.showToast('ERROR', error.body.message, 'error');
      }
    }

In the above code, its going directly to else part and showing an error msg on the console like like below.
Error msg on consoleplease let me know where I am missing code.
 
Hi,

I have one logic in that logic i'm returning values i'm return values are

{"available":
    {
        "a4C6C0000005rsWUAQ":"Account Test 1",
        "a4C6C0000005y14UAA":"Account Test 2",
        "a4C6C0000005s0rUAA":"Account Test 3"
    },

"hidden":{"a4D6C000000GycrUAC":"Account Test 4"}

}

I need to separate this lightning javascript 

I need to set "available" will be one attribute and
hidden will be in another attribute.

please help me

thanks,
Dhilip
Hi 
Could you please help in vertical alignment of combobox and new button. they both need to be in the same line.

Here is my code i have used to develop this
<template>
    <lightning-card>
        <lightning-layout horizontal-align="center" vertical-align="end" class="slds-form slds-form_horizontal">
            <lightning-layout-item size="4">
                <lightning-combobox placeholder="All Types" options={cartypesarry} value={selectedId}
                    onchange={comboOnchange}></lightning-combobox>
            </lightning-layout-item>
            <lightning-layout-item size="4">
                <lightning-button label="New" onclick={newButtonHandler}></lightning-button>
            </lightning-layout-item>
        </lightning-layout>
    </lightning-card>
</template>


Alignment
Hi,

I have created the custom object with related to order. I have created the rollup summary in Order page. But when i have made changes in related list that time the rollup summary values not affected in parent pahe for Order. When i hae try to edit and save that time shown the error "Some one has modified the record, please reload" that time only the rollup summary values has been chaned. 

So please suggest any one when i have modify/create/delete record in related list that  time auto refresh the Order page(Parent Page) also. How to acheive this in lightning related list(Custom object)