• Abhi Mehta
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 7
    Questions
  • 5
    Replies
Hi Community,

I have a scenerio if anyone post something in case feed(FeedItem) then the latest comment should be copied to a field on case(Type - long text area)
Now trigger is working but, next line is getting ignored.

Ex :- 
My first line
My second line

What is happening is, in my trigger the following string value is coming out to be, Output :- My first lineMy second line.

Can anyone help?
Can someone help me with the batch class, I need to show count of cases on their respective account. Please don't suggest trigger or reports.

Why i need batch is because, i need cases in past 365days. And need to update it daily.

Scenerio - 

There will be two org, one salesforce and another non-salesforce. 

What we need to do is to search account in both the orgs and display the output on VF page.
Can anyone help with the api or can shed some light ?

 // Get the report ID
    List <Report> reportList = [SELECT Id,DeveloperName FROM Report where DeveloperName = 'Count_Of_Cases_Related_To_Particular_Acc'];
    String reportId = (String)reportList.get(0).get('ID');
    
    // Run a report synchronously
    Reports.reportResults results = Reports.ReportManager.runReport('00O3D000000f6T3', true);
    
    // Get the first down-grouping in the report
    Reports.Dimension dim = results.getGroupingsDown();
    Reports.GroupingValue groupingVal = dim.getGroupings()[0];
    System.debug('Key: ' + groupingVal.getKey());
    System.debug('Label: ' + groupingVal.getLabel());
    System.debug('Value: ' + groupingVal.getValue());
    
    // Construct a fact map key, using the grouping key value
    String factMapKey = groupingVal.getKey() + '!T';
    
    // Get the fact map from the report results
    Reports.ReportFactWithDetails factDetails =
        (Reports.ReportFactWithDetails)results.getFactMap().get(factMapKey);
    
    // Get the first summary amount from the fact map
    Reports.SummaryValue sumVal = factDetails.getAggregates()[0];
    System.debug('Summary Value: ' + sumVal.getLabel());
    
    // Get the field value from the first data cell of the first row of the report
    list<Reports.ReportDetailRow> detailRow = factDetails.getRows();
    System.debug('########### detailRow'+detailRow);
    
The List(detailRow) is not fetching any data. Everything is working fine.
public class LegalAgreement_AfterSigning_Helper {
    public static void ToCreateLegalAgreement_Helper(list<echosign_dev1__SIGN_Agreement__c> ecosignList,Map<id,echosign_dev1__SIGN_Agreement__c> oldecosignList ){
        list<id> AgreementId =new list<id>();
        Set<string> AgreementType = new Set<string>();
        list<id> OppId = new list<id>();
        boolean flag=false;

        For (echosign_dev1__SIGN_Agreement__c Agreements: ecosignList){ 
            echosign_dev1__SIGN_Agreement__c AgreementInOld = oldecosignList.get(Agreements.Id);                
            if(Agreements.echosign_dev1__Opportunity__c!=null){
                if (Agreements.Send_to_Legal_Agreement__c == true && AgreementInOld.Send_to_Legal_Agreement__c!=true){                                       
                    AgreementId.add(Agreements.id);
                    OppId.add(Agreements.echosign_dev1__Opportunity__c);    
                    flag=true;
                } 
            }   
        }
        if(flag){
            List<Legal_Agreement_Type__mdt> LegaltypeList= [select id,MasterLabel from Legal_Agreement_Type__mdt];
            echosign_dev1__SIGN_Agreement__c AgreeementRecord = [select id,Name,echosign_dev1__Opportunity__c,echosign_dev1__Account__c,echosign_dev1__Account__r.name,echosign_dev1__Opportunity__r.AccountId,echosign_dev1__Opportunity__r.Account.Name from  echosign_dev1__SIGN_Agreement__c where id in : AgreementId limit 1];
            List<ContentVersion> ContentVersionList =  new list<ContentVersion>();
            List<Attachment> AttachmentList = [SELECT Id,Name,Body,Parentid,createddate FROM Attachment WHERE ParentId in : AgreementId order by createddate Asc];
            Attachment SignedAttachment = new Attachment();
            for(Attachment att: AttachmentList){
                if(att.name.contains('- signed.pdf')){
                    SignedAttachment = att;
                }
                else if(att.name.contains('approved.pdf')){
                    SignedAttachment = att;
                }
                for(Legal_Agreement_Type__mdt legType : LegaltypeList){
                    if(att.name.contains(legType.MasterLabel)){
                        AgreementType.add(legType.MasterLabel);
                    }
                }
            }
            
            for(String agtype:AgreementType){
                ContentVersion contentVersion_1 = new ContentVersion(
                    Title =SignedAttachment.Name,
                    PathOnClient =SignedAttachment.Name,
                    VersionData = SignedAttachment.Body,
                    IsMajorVersion = true,
                    IsCongaFile__c= true
                );
                ContentVersionList.add(contentVersion_1);
            }
            if(ContentVersionList.size()>0){
                insert ContentVersionList;
            }

            list<Legal_Agreements__c> LegalAgreementList = new list<Legal_Agreements__c>();     
            list<Legal_Agreements__c> LegalAgreList = [select id,name,Contract_Description__c,CreatedDate from Legal_Agreements__c where Opportunity__c in:OppId order by CreatedDate Asc];
            Map<String, id> LegalagremType = new Map<String, id>();             
            for(Legal_Agreements__c LegalAgRecord: LegalAgreList){
                for(String agrtype: AgreementType){
                    if(LegalAgRecord.Contract_Description__c.contains(agrtype)){
                        LegalagremType.put(LegalAgRecord.Contract_Description__c, LegalAgRecord.id);
                    }
                }
            }           
            for(String agtype:AgreementType){
                if(LegalagremType.containsKey(agtype)){
                    Legal_Agreements__c LegalAgreement = new Legal_Agreements__c();
                    LegalAgreement.id= LegalagremType.get(agtype);
                    LegalAgreement.Contract_Description__c = agtype ;
                    LegalAgreementList.add(LegalAgreement);
                }
                else{
                    Legal_Agreements__c LegalAgreement = new Legal_Agreements__c();
                    LegalAgreement.Opportunity__c = AgreeementRecord.echosign_dev1__Opportunity__c;
                    LegalAgreement.Account__c = AgreeementRecord.echosign_dev1__Opportunity__r.AccountId;           
                    LegalAgreement.Name =AgreeementRecord.echosign_dev1__Opportunity__r.Account.Name+ '-'+ agtype +' '+System.Today().year();
                    LegalAgreement.Contract_Description__c = agtype ;
                    LegalAgreementList.add(LegalAgreement);
                }
            }            
            if(!LegalAgreementList.isEmpty()){
                upsert LegalAgreementList;
            }             
            List<id> ContentVersionId = new list<id>();
            for(ContentVersion contver : ContentVersionList){
                ContentVersionId.add(contver.id);
            }           
            list<ContentVersion> Contentrec = [SELECT ContentDocumentId,id,Title FROM ContentVersion where id=:ContentVersionId];           
            List<ContentDocumentLink> ContentDocumentLinkList = new List<ContentDocumentLink>();
            for(integer i=0; i<Contentrec.size(); i++)
            {
                ContentDocumentLink con = new ContentDocumentLink();
                con.ContentDocumentId= Contentrec[i].ContentDocumentId;
                con.LinkedEntityId = LegalAgreementList[i].id;
                con.ShareType='I';
                ContentDocumentLinkList.add(con);
            }
            if(ContentDocumentLinkList.size()>0){
                insert ContentDocumentLinkList;
            }   
        }
    }
}
Hello. I am attempting to upload mdt records using SFDX CLI. I get the error The column Label is not found on the custom metadata type. I saved the file as CSV (Comma delimited) and CSV UTF-8 (Comma delimited) and received the same error. Similar error using MasterLabel. Any help would be appreciated. Thank you.
Can someone help me with the batch class, I need to show count of cases on their respective account. Please don't suggest trigger or reports.

Why i need batch is because, i need cases in past 365days. And need to update it daily.
public class LegalAgreement_AfterSigning_Helper {
    public static void ToCreateLegalAgreement_Helper(list<echosign_dev1__SIGN_Agreement__c> ecosignList,Map<id,echosign_dev1__SIGN_Agreement__c> oldecosignList ){
        list<id> AgreementId =new list<id>();
        Set<string> AgreementType = new Set<string>();
        list<id> OppId = new list<id>();
        boolean flag=false;

        For (echosign_dev1__SIGN_Agreement__c Agreements: ecosignList){ 
            echosign_dev1__SIGN_Agreement__c AgreementInOld = oldecosignList.get(Agreements.Id);                
            if(Agreements.echosign_dev1__Opportunity__c!=null){
                if (Agreements.Send_to_Legal_Agreement__c == true && AgreementInOld.Send_to_Legal_Agreement__c!=true){                                       
                    AgreementId.add(Agreements.id);
                    OppId.add(Agreements.echosign_dev1__Opportunity__c);    
                    flag=true;
                } 
            }   
        }
        if(flag){
            List<Legal_Agreement_Type__mdt> LegaltypeList= [select id,MasterLabel from Legal_Agreement_Type__mdt];
            echosign_dev1__SIGN_Agreement__c AgreeementRecord = [select id,Name,echosign_dev1__Opportunity__c,echosign_dev1__Account__c,echosign_dev1__Account__r.name,echosign_dev1__Opportunity__r.AccountId,echosign_dev1__Opportunity__r.Account.Name from  echosign_dev1__SIGN_Agreement__c where id in : AgreementId limit 1];
            List<ContentVersion> ContentVersionList =  new list<ContentVersion>();
            List<Attachment> AttachmentList = [SELECT Id,Name,Body,Parentid,createddate FROM Attachment WHERE ParentId in : AgreementId order by createddate Asc];
            Attachment SignedAttachment = new Attachment();
            for(Attachment att: AttachmentList){
                if(att.name.contains('- signed.pdf')){
                    SignedAttachment = att;
                }
                else if(att.name.contains('approved.pdf')){
                    SignedAttachment = att;
                }
                for(Legal_Agreement_Type__mdt legType : LegaltypeList){
                    if(att.name.contains(legType.MasterLabel)){
                        AgreementType.add(legType.MasterLabel);
                    }
                }
            }
            
            for(String agtype:AgreementType){
                ContentVersion contentVersion_1 = new ContentVersion(
                    Title =SignedAttachment.Name,
                    PathOnClient =SignedAttachment.Name,
                    VersionData = SignedAttachment.Body,
                    IsMajorVersion = true,
                    IsCongaFile__c= true
                );
                ContentVersionList.add(contentVersion_1);
            }
            if(ContentVersionList.size()>0){
                insert ContentVersionList;
            }

            list<Legal_Agreements__c> LegalAgreementList = new list<Legal_Agreements__c>();     
            list<Legal_Agreements__c> LegalAgreList = [select id,name,Contract_Description__c,CreatedDate from Legal_Agreements__c where Opportunity__c in:OppId order by CreatedDate Asc];
            Map<String, id> LegalagremType = new Map<String, id>();             
            for(Legal_Agreements__c LegalAgRecord: LegalAgreList){
                for(String agrtype: AgreementType){
                    if(LegalAgRecord.Contract_Description__c.contains(agrtype)){
                        LegalagremType.put(LegalAgRecord.Contract_Description__c, LegalAgRecord.id);
                    }
                }
            }           
            for(String agtype:AgreementType){
                if(LegalagremType.containsKey(agtype)){
                    Legal_Agreements__c LegalAgreement = new Legal_Agreements__c();
                    LegalAgreement.id= LegalagremType.get(agtype);
                    LegalAgreement.Contract_Description__c = agtype ;
                    LegalAgreementList.add(LegalAgreement);
                }
                else{
                    Legal_Agreements__c LegalAgreement = new Legal_Agreements__c();
                    LegalAgreement.Opportunity__c = AgreeementRecord.echosign_dev1__Opportunity__c;
                    LegalAgreement.Account__c = AgreeementRecord.echosign_dev1__Opportunity__r.AccountId;           
                    LegalAgreement.Name =AgreeementRecord.echosign_dev1__Opportunity__r.Account.Name+ '-'+ agtype +' '+System.Today().year();
                    LegalAgreement.Contract_Description__c = agtype ;
                    LegalAgreementList.add(LegalAgreement);
                }
            }            
            if(!LegalAgreementList.isEmpty()){
                upsert LegalAgreementList;
            }             
            List<id> ContentVersionId = new list<id>();
            for(ContentVersion contver : ContentVersionList){
                ContentVersionId.add(contver.id);
            }           
            list<ContentVersion> Contentrec = [SELECT ContentDocumentId,id,Title FROM ContentVersion where id=:ContentVersionId];           
            List<ContentDocumentLink> ContentDocumentLinkList = new List<ContentDocumentLink>();
            for(integer i=0; i<Contentrec.size(); i++)
            {
                ContentDocumentLink con = new ContentDocumentLink();
                con.ContentDocumentId= Contentrec[i].ContentDocumentId;
                con.LinkedEntityId = LegalAgreementList[i].id;
                con.ShareType='I';
                ContentDocumentLinkList.add(con);
            }
            if(ContentDocumentLinkList.size()>0){
                insert ContentDocumentLinkList;
            }   
        }
    }
}
Hello. I am attempting to upload mdt records using SFDX CLI. I get the error The column Label is not found on the custom metadata type. I saved the file as CSV (Comma delimited) and CSV UTF-8 (Comma delimited) and received the same error. Similar error using MasterLabel. Any help would be appreciated. Thank you.