• anivesh muppa
  • NEWBIE
  • 5 Points
  • Member since 2016
  • Senior Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 7
    Replies

Hello,

How to Zip the Attachments that are in a record using only Apex, that should support more than 500kb.

I have tried with github code, but it is not supporting more than 500kb and also facing batch failure like  time out error

Can anyone direct me to solved this issue....

Thank you Inadvance,

please look at the highlighted part in the picture.....!

This is the lookup criteria given to contact field on opportunity object 
User-added image
Trying to create opportunity from contact object 

creating the opportunity record from contact
value at the contact field is not populating.
value at contact field is not populating ,please find the highlighted part in pic
 

I have look into the debug==> im getting these values "(etag, selfLink)" And "(etag, selfLink, selfLink)" these values are loading into map i.e FileIdAndNameMapForTheaccount and im placing this map in pageblock table
Hi Everyone,
I got a problem which im enable to understand it .
Im trying to get the files which are in google drive using REST
the response i get is in tthe form of 'Etag' and 'selflink'
i have debug it in which i found "(etag, selfLink)"and for next iteration for loop i get "(etag, selfLink, selfLink)"  and than i load this values into the map (Map<String,String> FileIdAndNameMapForTheaccount)
In vf page :
 <apex:pageBlockTable Value="{!FileIdAndNameMapForTheaccount}" var="file">
                <apex:column headerValue="drive file">
                    <apex:outputLink value="https://www.drive.google.com/open?id={!file}">{!FileIdAndNameMapForTheaccount[file]}</apex:outputLink>
                 </apex:column>
  </apex:pageBlockTable>

Please help me in solving this,

Thanks Inadvance,
Anivesh

Hi all,
can you please help me out with this problem that im geting the soql statements are two I have debug it but can't resolve it.Please correct it.


public class Accountinsert {
@auraEnabled
    public static void  Accs (string nam ,string id, boolean check){
        system.debug('inputs here ' +nam+' '+id+' '+check);
    account acc=[SELECT Id,Name,(select LastName,FirstName From Contacts) FROM Account WHERE Id =:id];
        
        acc.name = nam;
        update acc;
        if(check==true){
            delete acc.contacts;
            
        }
    }
User-added image
Thank you inadvance....!
i got an issue like i want  to display records of multiple objects in a tabpanel and when i click on record name it should display detail page of respective record.



Thank You in advance , 
I received the following error message and researched on the forms and the solution seems to be adding UPDATE FOR but I couldnt make that update in SOQL query as I received an error message "Cannot lock rows for an SObject type that can not be updated: AggregateResult"

So im not sure if I need to edit the code where I call List<Account> to an SOQL statement.  See my code below.

ISSUE MESSAGE:

Apex script unhandled trigger exception by user/organization: 0053400000AEv6J/00D80000000PTja
 
accountIssueScore: execution of AfterUpdate
 
caused by: System.DmlException: Update failed. First exception on row 0 with id 0018000001AKu9XAAT; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record or 1 records: 0018000001AKu9XAAT: []
 
Trigger.accountIssueScore: line 17, column 1
 
trigger accountIssueScore on Case (after update, after insert) {

        List<AggregateResult> contactAggrList = [SELECT AccountId, SUM(Severity_Value__c) 
                                                 FROM Case 
                                                 WHERE Id IN :Trigger.New
                                                 AND 
                                                 AccountId <> null
                                                 AND Severity__c IN ('Blocker','Critical','Major')
                                                 Group By AccountId FOR UPDATE
                                                 ];

        List<Account> accountsToUPdate3 = new List<Account>();

        for(AggregateResult contactAggr : contactAggrList) {
            accountsToUPdate3.add(new Account(Id = (Id)contactAggr.get('AccountId'),
                                             Issue_Score__c = (Decimal)contactAggr.get('expr0'))); 

        }

        update accountsToUPdate3;
}

​​​​​​​
 
I am calling a webservice (synchronous) and in case of CalloutException, I'm trying to create an error log in a custom object. The problem is, the record insertion is happening in a future method and after an exception has encountered, the method is not getting called. In case, I remove the @future annotation, the record does not get committed to the database. Has anyone faced similar issue and is there any workaround?
  • January 10, 2019
  • Like
  • 0

I have look into the debug==> im getting these values "(etag, selfLink)" And "(etag, selfLink, selfLink)" these values are loading into map i.e FileIdAndNameMapForTheaccount and im placing this map in pageblock table
Hi Everyone,
I got a problem which im enable to understand it .
Im trying to get the files which are in google drive using REST
the response i get is in tthe form of 'Etag' and 'selflink'
i have debug it in which i found "(etag, selfLink)"and for next iteration for loop i get "(etag, selfLink, selfLink)"  and than i load this values into the map (Map<String,String> FileIdAndNameMapForTheaccount)
In vf page :
 <apex:pageBlockTable Value="{!FileIdAndNameMapForTheaccount}" var="file">
                <apex:column headerValue="drive file">
                    <apex:outputLink value="https://www.drive.google.com/open?id={!file}">{!FileIdAndNameMapForTheaccount[file]}</apex:outputLink>
                 </apex:column>
  </apex:pageBlockTable>

Please help me in solving this,

Thanks Inadvance,
Anivesh

Hi all,
can you please help me out with this problem that im geting the soql statements are two I have debug it but can't resolve it.Please correct it.


public class Accountinsert {
@auraEnabled
    public static void  Accs (string nam ,string id, boolean check){
        system.debug('inputs here ' +nam+' '+id+' '+check);
    account acc=[SELECT Id,Name,(select LastName,FirstName From Contacts) FROM Account WHERE Id =:id];
        
        acc.name = nam;
        update acc;
        if(check==true){
            delete acc.contacts;
            
        }
    }
User-added image
Thank you inadvance....!
I was able to develope an API which can send emails from saleforce through mailgun. emails are successfully being send. but attachments are not working.. we despirately in need of ability to send attachements. Please find my code .. this perticular code is not showing any error its working but attachments are not getting send only the email is send. 

@RemoteAction  @future (callout=true)
    public static void sendEmailResponse(String notId, String response, Boolean hasAttachment, string csvFileId, String responseSubject, String toEmail, String toCCEmail){
        System.debug('********** inside send email******');
        if(toEmail == '' || response == ''){ 
            return;
        }
        String status = '';
        
        if(toEmail != '' && response != ''){ 
            string sURL =   'https://api.mailgun.net/v3/sandboxedaf562949124727b836108ded5d10ed.mailgun.org/messages'; 
            string sBody = '';
            String strSubject = responseSubject;
            string sReturn = '';
            String attachmentBody = '';
            String bodyPayload='';
            String separationString = 'A_RANDOM_STRING';
            HttpRequest req = new HttpRequest();
            HttpResponse res = new HttpResponse();
            Http http = new Http();
            
            String authUserName = 'postmaster@sandboxedafxxxxxxxxxed.mailgun.org'; 
            String authUserPassword = '1fxxxxxxxxxxxxxxxxxxxxxx';
            String filePath; 
            if(hasAttachment){
                Attachment csvFile = [select id, body, Name from Attachment where id=:csvFileId];
                String header = '--' + separationString + 
                 + 'Content-Disposition: form-data; name="file"; filename="'+csvFile.name
                 +'"\nContent-Type: application/octet-stream\n\n';
                 attachmentBody =  EncodingUtil.base64Encode(csvFile.Body);
                 String footer = '--' + separationString + '--';
                  bodyPayload= header+attachmentBody+footer;
                 
                // filePath = 'https://c.cs91.content.force.com/servlet/servlet.FileDownload?file='+csvFile.id;
                filePath = 'http://che.org.il/wp-content/uploads/2016/12/pdf-sample.pdf'; // a sample public file for testing purpose

            }
            
            String fromemail = 'NoReply<zahir.basith@virtual1.com>'; 
            String toSetCCEmail ='';
            if(responseSubject != '' || responseSubject != Null){
                responseSubject = EncodingUtil.urlEncode( responseSubject, 'UTF-8');
            }
            String subject = responseSubject;
            String message  = response.unescapeHtml4();
            message = EncodingUtil.urlEncode( message, 'UTF-8');
            
            Blob headerValue = Blob.valueOf('api:key-xxxxxxxxxxxxxxxxxxxxxxxx');
            String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
            req.setHeader('Authorization', authorizationHeader);
            req.setHeader('Content-Type','multipart/form-data; boundary=' + separationString);
            req.setHeader('Host', 'sandboxedaf562949124727b836108ded5d10ed.mailgun.org');
            
            if(toCCEmail != ''){
                toSetCCEmail= '&cc='+toCCEmail;
            } 
            string mailBody;
            if(hasAttachment){
                mailBody = sURL+'?from='+fromemail+'&to='+toEmail+'&attachment='+filePath+'&subject='+subject+'&html='+message;
                req.setBody('{ "from": "'+fromemail+'",  "to": "'+toEmail+'", "cc":"'+toCCEmail+'", "attachments": "'+filePath+'", "subject": "'+subject+'",  "html": "'+message+'"}');
            }else{
                mailBody = sURL+'?from='+fromemail+'&to='+toEmail+'&subject='+subject+'&html='+message;
                req.setBody('{ "from": "'+fromemail+'",  "to": "'+toEmail+'", "cc":"'+toCCEmail+'", "subject": "'+subject+'",  "html": "'+message+'"}'); 
            }
                
            req.setMethod('POST');   
            req.setEndPoint(mailBody);  
            
            integer iLength = mailBody.length();
            req.setHeader('Content-Length', string.valueOf(iLength));
            
            if( !System.isBatch() && !test.isRunningTest() ) { 
                res = http.send(req);  
            } else{  
                res.setStatusCode(200);
                res.setStatusCode(414);
            }  
            
            String messageID = ''; 
            if( res.getStatusCode() == 200 ){   
                
               System.debug('Email sent');
            }  
            
            status = ''+res.getStatusCode()+''; 
        }
        //return status;
    }
i got an issue like i want  to display records of multiple objects in a tabpanel and when i click on record name it should display detail page of respective record.



Thank You in advance , 
Screen scraping might actualy be a decent option for me. I am already doing a "snapshot" type replication as part of my solution but I don't want to grow that into a full fledged system.

Thanks