• Michael M
  • SMARTIE
  • 1909 Points
  • Member since 2019

  • Chatter
    Feed
  • 1
    Best Answers
  • 5
    Likes Received
  • 0
    Likes Given
  • 229
    Questions
  • 420
    Replies
Hello, How do I adjust the margins of my VF page? I have tried different things but none seem to work. the text starts all the way to the left side of the page and I want it to be indented, and I want the right margin also to stick out more. 

<apex:page standardcontroller="Lead" extensions="FinancialChecklistPageExtension" lightningStylesheets="true" action="{!firstScreen}">
    <style>
           .One
             {
            margin-left:30px;
            margin-right:30px;
            padding-left:30px;
            padding-right:30px;
        font-size:15px;
             }
    </style>
        <script type="text/javascript">
           function disableOnSubmit(input) {
            var btn = input;
            setTimeout(function(){ 
                btn.disabled = 'disabled';
               
                btn.className = 'btnDisabled';
                btn.value = "Processing..."; 
            }, 50);
        }
           function disableOnSubmit2(input) {
            var btn = input;
            setTimeout(function(){ 
                btn.disabled = 'disabled';
             
                btn.className = 'btnDisabled';
                btn.value = "Saving..."; 
            }, 50);
        }
    </script>
   
   
    <apex:form id="theForm" >
       
       <div align="center" draggable="false">
        <apex:outputPanel style="text-align:center;" rendered="{!IF(kansasSelected =false && njselected = false && nyselected = false && riselected = false,true,false)}">
          
            <br/><br/><br/><br/>
       <b>Which region is this for?<br/><br/></b> &nbsp;     <apex:selectList style="align:center;text-align:center" value="{!region}" multiselect="false" size="1">
                            <apex:selectOption itemValue="" itemLabel="--- Please Select ---"/>
                            <apex:selectOption itemValue="Kansas" itemLabel="Kansas"/>
                            <apex:selectOption itemValue="New Jersey" itemLabel="New Jersey"/>
                            <apex:selectOption itemValue="New York" itemLabel="New York"/>
                            <apex:selectOption itemValue="Rhode Island" itemLabel="Rhode Island"/>
                        </apex:selectList><br/><br/>    
            
                    <div align="center"  draggable="false" >
                        <apex:commandButton value="Next" action="{!showForm}" onclick="disableOnSubmit(this);" reRender="theForm" />
                    </div> 
        
            </apex:outputPanel> 
        </div>

         
 <!-- KANSAS -->    
        <apex:outputPanel styleClass="One" rendered="{!kansasSelected}" > 
                        <div style="text-align:center; font-size:18px">
                             <b><u>Kansas Finance Check List</u></b><br/> 
                        </div> 
                    <apex:repeat value="{!financialChecklistTemp}" var="fc">
                        
                        <div style="text-align:center;">
                            Created Date: <apex:inputField value="{!fc.CreatedDate}" /><br/><br/>
                        </div>
                        
                        <b>*All of these elements factor in whether or not the facility will get the Medicaid eligibility necessary</b>
                        <br/><br/>
                        
                        1. Is the patient alert and oriented?  If not, is there a POA, guardian, attorney or responsible family member to assist with Medicaid process?    
                        <apex:inputField value="{!fc.KS_Is_the_patient_alert_and_oriented__c}" /><br/>
                        2. Does patient/family have access to documents? (Birth Certificate, SS Card, ID’s, Insurance Cards, Marriage Cert, Divorce or Death Decrees, etc.)    
                        <apex:inputField value="{!fc.KS_Does_patient_have_access_to_docs__c}" /><br/>
                        3. <b><u>For patients under 65</u></b> – does the patient receive disability or is the patient in the process of applying? 
                        This would be necessary to obtain LTC Medicaid benefits. <b><u>If the patient is under 65 and does not have disability refer to finance for review.</u></b>
                        <apex:inputField value="{!fc.KS_For_patients_under_65__c}" /><br/>
                        4.    Is resident single, separated or married?  If married and or separated, is legal spouse willing and able to participate with Medicaid process? 
                        <apex:inputField value="{!fc.KS_IS_resident_single_separated__c}" /><br/>
                         5.    What is patient’s income and resources? (Pensions, Social Security, Checking, Savings, Residential Property, IRA’s, 
                         Stocks, Bonds, etc.) – <b><u>If income or assets exceed $2,000 refer to finance for review</u></b>
                        <apex:inputField value="{!fc.KS_What_is_patient_s_income__c}" /><br/>
                         6.    Does patient understand and agree that <B>ALL</B> income must be turned over to the facility on a monthly basis, with the exception of $62 Personal Need’s Allowance?
                        <apex:inputField value="{!fc.KS_Does_patient_understand_and_agree__c}" /><br/>
                         7.    Has patient transferred any assets in the last five years? This includes any gifts or loans that remain unpaid.  
                         If so, this will result in a period of Medicaid ineligibility and <b><u>should be referred to finance.</u></b>   
                        <apex:inputField value="{!fc.KS_Has_patient_transferred_any_assets__c}" /><br/>
                        8.    All admissions regardless of payer need the “less than 30” from the hospital (unless the patient has an existing care assessment)  
                        <apex:inputField value="{!fc.KS_All_admissions_regardless__c}" /><br/>
                        <br/><br/>    
                        
                        General information: When running eligibility “medical necessity or QMB only” means it needs a new Medicaid application (not just a conversion to LTC). Those are typically more challenging. 
                        <br/><br/>
                    <div align="center"  draggable="false" >
                        <apex:commandButton value="Save" action="{!savetasks}" onclick="disableOnSubmit2(this);" reRender="theForm" />
                        </div> <br/><br/>
                    <div align="center"  draggable="false" >
                        <apex:commandButton value="Attach to Referral" action="{!generatePdf}" onclick="disableOnSubmit2(this);" reRender="theForm" />
                    </div> 
                        </apex:repeat>
                    </apex:outputPanel> 

        
        </apex:form> 
         
</apex:page>
Hello, I keep getting an ApexApplication email saying:

Failed to invoke future method 'public static void UploadDocument(String)' on class 'S3Controller' for job id '7073l0000FSMaBy'

caused by: System.LimitException: Query of LOB fields caused heap usage to exceed limit.



The line of code that is causing the error is this:
List<ContentVersion> versions=[SELECT VersionData,Title,ContentDocumentId,FileExtension FROM ContentVersion WHERE ContentDocumentId = :ids AND IsLatest = true];

How can I change my code so that if that error comes up, I still query the files but ONLY query the 1st file (as a way of avoiding the error)?


I TRIED this:

        List<ContentVersion> versions = new list<contentversion>();
        try{
        versions=[SELECT VersionData,Title,ContentDocumentId,FileExtension FROM ContentVersion WHERE ContentDocumentId = :ids AND IsLatest = true];
        }
        catch (exception e){
            versions=[SELECT VersionData,Title,ContentDocumentId,FileExtension FROM ContentVersion WHERE ContentDocumentId = :ids AND IsLatest = true limit 2];
        }

BUT it didn't work. I am still getting the same ApexApplication error email. 
Hello, I am working on "PUTting" files attached to my Lead records into an s3 bucket. Some of the files get neatly placed in the s3 bucket, however when there are multiple files, I get a 200 response on the some of them but a 400 response on the rest of them, stating The provided 'x-amz-content-sha256' header does not match what was computed.. Any idea how I can fix this?

My code is here:


public  class S3Controller {
    
    public static void UploadDocToS3Server(string recordId)
    {
        UploadDocument(recordId);
    }
    
    @future(callout=true)
    public static void UploadDocument(string recordId)
    {
        String key = '123'; 
        String secret = '123+123+123';
        String bucket = '123'; 
        String host = 's3-us-east-1.amazonaws.com';
        String method = 'PUT';
        ProfilityCallout service=new ProfilityCallout(key,secret,bucket,method,host);
          service.UploadDocuments(recordId);
    
    }

}


public class ProfilityCallout {
    
    public string awsKey {get;set;}
    public string awsSecret {get;set;}
    public string bucketName {get;set;}
    public string methodName {get;set;}
    public string hostName {get;set;}
    
    public ProfilityCallout(string key, string secret, string bucket, string method, string host) {
        awsKey=key;
        awsSecret=secret;
        bucketName=bucket;
        methodName=method;
        hostName=host;
    }
    
    public static string ContentType(string fileType) {
        switch on fileType.toLowerCase() {
            when 'docx'
            {
                return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
            }
            when 'csv'
            {
                return 'application/vnd.ms-excel';
            }
            when 'wav'
            {
                return 'audio/wav';
            }
            when 'wmv'
            {
                return 'video/x-ms-wmv';
            }
            when 'mp3'
            {
                return 'audio/mpeg';
            }
            when 'mp4'
            {
                return 'video/mp4';
            }
            when 'png'
            {
                return 'image/png';
                
            }
            when 'pdf'
            {
                return 'application/pdf';
                
            }
            when else {
                return 'image/jpeg';
            }
        }
    }    
    
    public  void UploadDocuments(string recordId) {
        
        Lead ref = [select id, mrn__c,Admit_Date__c, referral_account__r.name,Hosp_Admit_Date_new_formula__c, facility__r.name from lead where id = : recordId];
        string referralid;
        string mrn;
        string hosp;
        string admitdate;
        string facility;
        if (ref.MRN__c != null){
            mrn = ref.MRN__c;
        }
        else{
            mrn = 'noMrnListed';
        }
        
        if (ref.Referral_Account__c != null){
            hosp = ref.Referral_Account__r.name.replaceAll( '', '').replaceAll( ' ', '');
        }
        else{
            hosp = 'noHospitalListed';
        }
        if (ref.Admit_Date__c != null){
            admitdate = ref.Hosp_Admit_Date_new_formula__c;
        }
        else{
            admitdate = 'admitDateMissing';
        }

        List<ContentDocumentLink> links=[SELECT ContentDocumentId,LinkedEntityId FROM ContentDocumentLink where LinkedEntityId=:recordId];
        Set<Id> ids=new Set<Id>();
        for(ContentDocumentLink link:links)
        {
            ids.add(link.ContentDocumentId);
        }
        List<ContentVersion> versions=[SELECT VersionData,Title,ContentDocumentId,FileExtension FROM ContentVersion WHERE ContentDocumentId = :ids AND IsLatest = true];
        
        for(ContentVersion attach:versions)
        {

                String attachmentBody = EncodingUtil.base64Encode(attach.VersionData);
                String formattedDateString = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
                String filename = attach.Title;
                string contentType=ContentType(attach.FileExtension);
                HttpRequest req = new HttpRequest();
                req.setMethod('PUT');
               req.setEndpoint('callout:Profility/'+  filename.replaceAll( '\\s+', '')+'.'+attach.FileExtension.toLowerCase()  +'~'+ref.id + '~' 
                                + mrn + '~' + hosp + '~'+ admitdate   + '~' + ref.Facility__r.name.replaceAll( '', '').replaceAll( ' ', '')
                                + '.'+attach.FileExtension.toLowerCase()); 
                Blob pdfBlob = EncodingUtil.base64Decode(attachmentBody);
                req.setBodyAsBlob(pdfBlob);
                Http http = new Http();
                HTTPResponse res = http.send(req);
                    system.debug(versions.size() + 'FILES ATTACHED');
                    system.debug('>>>> The Request');
                    system.debug(req);
                    system.debug('>>>> The response');
                    system.debug(res);
                    system.debug('>>>> the body');
                    system.debug(res.getbody());
                    system.debug('>>>> status code');
                    system.debug(res.getstatuscode());

            
        }
    }
    
}
Why am I getting this error (error is on the bold line of code below)-- 
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

public  class S3Controller {
    
    public static void UploadDocToS3Server(string recordId)
    {
        UploadDocument(recordId);
    }
    
    @future(callout=true)
    public static void UploadDocument(string recordId)
    {
        //S3 Key 
        String key = '123'; 
        //S3 Secret Key 
        String secret = '123/123/123';
        String bucket = '123'; 
        String host = 's3-us-east-1.amazonaws.com';
        String method = 'PUT';
        ProfilityCallout service=new ProfilityCallout(key,secret,bucket,method,host);
            ProfilityCallout.UploadDocuments(recordId,key,secret,bucket,method,host);
    
    }

}

public class ProfilityCallout {
 
   
    public  string awsKey {get;set;}
    public   string awsSecret {get;set;}
    public   string bucketName {get;set;}
    public   string methodName {get;set;}
    public static  string hostName {get;set;}
    public  static string statusCode {get;set;}
    public static string bucketNameStatic {get;set;}
    public static string methodNameStatic {get;set;}
    public static string hostNameStatic {get;set;}
    
    public static string awsKeyStatic {get;set;}
    public  static string awsSecretStatic {get;set;}
    
    public  ProfilityCallout(string key, string secret, string bucket, string method, string host){
        awsKey=key;
        awsSecret=secret;
        bucketName=bucket;
        methodName=method;
        hostName=host;
        bucketNameStatic = bucket;
        methodNameStatic = method;
        hostNameStatic = host;
    }
    
    public  string ContentType(string fileType) {
        switch on fileType.toLowerCase()
        {
            when 'docx'
            {
                return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
            }
            when 'csv'
            {
                return 'application/vnd.ms-excel';
            }
            when 'wav'
            { 
                return 'audio/wav';
            }
            when 'wmv'
            {
                return 'video/x-ms-wmv';
            }
            when 'mp3'
            {
                return 'audio/mpeg';
            }
            when 'mp4'
            {
                return 'video/mp4';
            }
            when 'png'
            {
                return 'image/png';
                
            }
            when 'pdf'
            {
                return 'application/pdf';
                
            }
            when else {
                return 'image/jpeg';
            }
        }
    }
    
    public  string CreateAuthHeader(String contentType,
                                   String filename, String formattedDateString,string fileExtension){
                                       string auth;
                                       String stringToSign = this.methodName+'\n\n'+contentType+'\n'+formattedDateString+'\n/'+this.bucketName+'/'+filename.toLowerCase()+ '.'+fileExtension.toLowerCase();
                                       Blob mac = Crypto.generateMac('HMACSHA1', blob.valueof(stringToSign),blob.valueof(this.awsSecret));
                                       String sig = EncodingUtil.base64Encode(mac);
                                       auth = 'AWS' + ' ' + this.awsKey + ':' + sig;
                                       return auth;
                                   }
    
  //  @future(callout=true)
    public static void UploadDocuments(string recordId,string key, string secret, string bucket, string method, string host){
        
        bucketNameStatic = bucket;
        methodNameStatic = method;
        hostNameStatic = host;
        awsKeyStatic=key;
        awsSecretStatic=secret;
            
      //  if(awsSecret.isBlank(this.awsSecret) || string.isBlank(this.awsKey) || string.isBlank(this.bucketName) || string.isBlank(this.hostName))
      //  {
         //   throw new BaseException('Set AWS credential');
      //  }
        List<ContentDocumentLink> links=[SELECT ContentDocumentId,LinkedEntityId FROM ContentDocumentLink where LinkedEntityId=:recordId];
        Set<Id> ids=new Set<Id>();
        for(ContentDocumentLink link:links)
        {
            ids.add(link.ContentDocumentId);
        }
        List<ContentVersion> versions=[SELECT VersionData,Title,ContentDocumentId,FileExtension FROM ContentVersion WHERE ContentDocumentId = :ids AND IsLatest = true];
        
        for(ContentVersion attach:versions) {
         //   try
         //   {
                //File Content
                String attachmentBody = EncodingUtil.base64Encode(attach.VersionData);
                String formattedDateString = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
                
                String filename = attach.Title;
       //////FIX LATER         string contentType=ContentType(attach.FileExtension);
         /////       system.debug('contentType:'+contentType);
                
                string fileUrl='https://' + bucketNameStatic + '.' + hostNameStatic + '/' + filename.toLowerCase().remove(' ')+ '.'+attach.FileExtension.toLowerCase();
                HttpRequest req = new HttpRequest();
                req.setMethod(methodNameStatic);
                req.setEndpoint('callout:Seek/'+ filename.toLowerCase()+ '.'+attach.FileExtension.toLowerCase());
                req.setHeader('Host', bucketNameStatic + '.' + hostNameStatic);
                req.setHeader('Content-Length', String.valueOf(attachmentBody.length()));
                req.setHeader('Content-Encoding', 'UTF-8');
         /////       req.setHeader('Content-type', contentType);
                req.setHeader('Connection', 'keep-alive');
                req.setHeader('Date', formattedDateString);
                req.setHeader('ACL', 'public-read');
                Blob pdfBlob = EncodingUtil.base64Decode(attachmentBody);
                req.setBodyAsBlob(pdfBlob);
                   
       //////FIX LATER          req.setHeader('Authorization',CreateAuthHeader(contentType, filename, formattedDateString,attach.FileExtension));
                
                Http http = new Http();
                HTTPResponse res = http.send(req);
               statusCode = string.valueof(res.getStatusCode());
                if (res.getStatusCode() == 200 || res.getStatusCode()==201) {
                     Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
                        message.setSubject('Profility S3 PUT succesful!');
                        message.setPlainTextBody('Profility S3 PUT succesful!');
                        message.setToAddresses( new String[] { '123@123.org' } );
                        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } ); 
                 
                }
            
         //   catch(Exception ex)
         else   {
                
                     Messaging.SingleEmailMessage message2 = new Messaging.SingleEmailMessage();
                        message2.setSubject('issue with Profility callout');
                        message2.setPlainTextBody('issue with Profility callout '+statusCode );
                        message2.setToAddresses( new String[] { '123@123.org' } );
                        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message2 } ); 
            //   throw new BaseException(ex);
            }
        }
    }
}
Why am I getting this erorr: "Static method cannot be referenced from a non static context: void ProfilityCallout.UploadDocuments(String)"

This error appears when I try to save this class (the bold line) :
public  class S3Controller {
    
    public static void UploadDocToS3Server(string recordId)
    {
        UploadDocument(recordId);
    }
    
    @future(callout=true)
    public static void UploadDocument(string recordId)
    {
        //S3 Key 
        String key = '124'; 
        //S3 Secret Key 
        String secret = '1234';
        String bucket = '1234'; 
        String host = 's3-us-east-1.amazonaws.com';
        String method = 'PUT';
        ProfilityCallout service=new ProfilityCallout(key,secret,bucket,method,host);
            service.UploadDocuments(recordId);
    
    }

}


And here is my other class:
public class ProfilityCallout {
 
   
    public  string awsKey {get;set;}
    public   string awsSecret {get;set;}
    public   string bucketName {get;set;}
    public   string methodName {get;set;}
    public static  string hostName {get;set;}
    public  static string statusCode {get;set;}
    public static string bucketNameStatic {get;set;}
    public static string methodNameStatic {get;set;}
    public static string hostNameStatic {get;set;}
    
    public  ProfilityCallout(string key, string secret, string bucket, string method, string host)
    {
        awsKey=key;
        awsSecret=secret;
        bucketName=bucket;
        methodName=method;
        hostName=host;
        bucketNameStatic = bucket;
        methodNameStatic = method;
        hostNameStatic = host;
    }
    
    public  string ContentType(string fileType) {
        switch on fileType.toLowerCase()
        {
            when 'docx'
            {
                return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
            }
            when 'csv'
            {
                return 'application/vnd.ms-excel';
            }
            when 'wav'
            { 
                return 'audio/wav';
            }
            when 'wmv'
            {
                return 'video/x-ms-wmv';
            }
            when 'mp3'
            {
                return 'audio/mpeg';
            }
            when 'mp4'
            {
                return 'video/mp4';
            }
            when 'png'
            {
                return 'image/png';
                
            }
            when 'pdf'
            {
                return 'application/pdf';
                
            }
            when else {
                return 'image/jpeg';
            }
        }
    }
    
    public  string CreateAuthHeader(String contentType,
                                   String filename, String formattedDateString,string fileExtension){
                                       string auth;
                                       String stringToSign = this.methodName+'\n\n'+contentType+'\n'+formattedDateString+'\n/'+this.bucketName+'/'+filename.toLowerCase()+ '.'+fileExtension.toLowerCase();
                                       Blob mac = Crypto.generateMac('HMACSHA1', blob.valueof(stringToSign),blob.valueof(this.awsSecret));
                                       String sig = EncodingUtil.base64Encode(mac);
                                       auth = 'AWS' + ' ' + this.awsKey + ':' + sig;
                                       return auth;
                                   }
    
    @future(callout=true)
    public static void UploadDocuments(string recordId){
      //  if(awsSecret.isBlank(this.awsSecret) || string.isBlank(this.awsKey) || string.isBlank(this.bucketName) || string.isBlank(this.hostName))
      //  {
         //   throw new BaseException('Set AWS credential');
      //  }
        List<ContentDocumentLink> links=[SELECT ContentDocumentId,LinkedEntityId FROM ContentDocumentLink where LinkedEntityId=:recordId];
        Set<Id> ids=new Set<Id>();
        for(ContentDocumentLink link:links)
        {
            ids.add(link.ContentDocumentId);
        }
        List<ContentVersion> versions=[SELECT VersionData,Title,ContentDocumentId,FileExtension FROM ContentVersion WHERE ContentDocumentId = :ids AND IsLatest = true];
        
        for(ContentVersion attach:versions) {
         //   try
         //   {
                //File Content
                String attachmentBody = EncodingUtil.base64Encode(attach.VersionData);
                String formattedDateString = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
                
                String filename = attach.Title;
       //////FIX LATER         string contentType=ContentType(attach.FileExtension);
         /////       system.debug('contentType:'+contentType);
                
                string fileUrl='https://' + bucketNameStatic + '.' + hostName + '/' + filename.toLowerCase().remove(' ')+ '.'+attach.FileExtension.toLowerCase();
                HttpRequest req = new HttpRequest();
                req.setMethod(methodNameStatic);
                req.setEndpoint('callout:Seek/'+ filename.toLowerCase()+ '.'+attach.FileExtension.toLowerCase());
                req.setHeader('Host', bucketNameStatic + '.' + hostNameStatic);
                req.setHeader('Content-Length', String.valueOf(attachmentBody.length()));
                req.setHeader('Content-Encoding', 'UTF-8');
         /////       req.setHeader('Content-type', contentType);
                req.setHeader('Connection', 'keep-alive');
                req.setHeader('Date', formattedDateString);
                req.setHeader('ACL', 'public-read');
                Blob pdfBlob = EncodingUtil.base64Decode(attachmentBody);
                req.setBodyAsBlob(pdfBlob);
                   
       //////FIX LATER          req.setHeader('Authorization',CreateAuthHeader(contentType, filename, formattedDateString,attach.FileExtension));
                
                Http http = new Http();
                HTTPResponse res = http.send(req);
               statusCode = string.valueof(res.getStatusCode());
                if (res.getStatusCode() == 200 || res.getStatusCode()==201) {
                     Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
                        message.setSubject('Profility S3 PUT succesful!');
                        message.setPlainTextBody('Profility S3 PUT succesful!');
                        message.setToAddresses( new String[] { '123@123.org' } );
                        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message } ); 
                 
                }
            
         //   catch(Exception ex)
         else   {
                
                     Messaging.SingleEmailMessage message2 = new Messaging.SingleEmailMessage();
                        message2.setSubject('issue with Profility callout');
                        message2.setPlainTextBody('issue with Profility callout '+statusCode );
                        message2.setToAddresses( new String[] { '123@123.org' } );
                        Messaging.sendEmail( new Messaging.SingleEmailMessage[] { message2 } ); 
            //   throw new BaseException(ex);
            }
        }
    }
}
 
Hello, i need to set up a process where I can both SEND and RECEIVE FILES (ContentVersion/ContentDocument) between Salesforce and an Aws S3 bucket. I am trying to find an example of code to do such a thing. To send files I will be using apex, but to receive files, other (non salesforce) developers will need to be able to access our salesforce api and send files from the s3 bucket to salesforce. Is there any examples of code for how to do each 1 of the above steps?
Hello, is there any way to make calls from Salesforce, and record those calls and save the recordings and call details as a record?
Hello, we want to create a connected app to allow api access to our Salesforce org. However we only want to be able to give the connected app access to very specific records (e.g. where the accountid = a specific account id). Is that possible?
Hi, I have tested my trigger, but the coverage of the code reached 66% even if the test of the class was successfully, how can I reach 75%? test 1ithis was the class:

@isTest
private class ErrorMessagetestclass {
    
    Static testmethod void myTest(){
        Opportunity opp = new Opportunity ();
        opp.Name = 'Test';
        opp.StageName = 'Qualification';
        opp.CloseDate = Date.parse('12/10/2021');
        opp.Type = 'Supplier';
                insert opp;
}
    }
Thanks 
Hello, I sometimes get this error with my below trigger/class. Is there something I can change in my code that will allow me to avoid this error? Thank you so much. 

This is the error message:
RehospitalizationTrigger: maximum trigger depth exceeded Rehospitalization 
trigger event AfterInsert Rehospitalization trigger event AfterUpdate Rehospitalization trigger event AfterUpdate Rehospitalization trigger event 
AfterUpdate Rehospitalization trigger event AfterUpdate Rehospitalization trigger event 
AfterUpdate Rehospitalization trigger event AfterUpdate Rehospitalization trigger event 
AfterUpdate Rehospitalization trigger event AfterUpdate Rehospitalization trigger event 
AfterUpdate Rehospitalization trigger event AfterUpdate Rehospitalization trigger event 
AfterUpdate Rehospitalization trigger event AfterUpdate Rehospitalization trigger event 
AfterUpdate Rehospitalization trigger event AfterUpdate Rehospitalization trigger event AfterUpdate: [] Class.RehospLookupHospital.hospitalLookup: line 20, col    




This is the TRIGGER:
trigger RehospitalizationTrigger on Rehospitalization__c (after insert, after update) {
               for (rehospitalization__c r : trigger.new){
            if (r.discharge_location__c != null && r.Referral_Account__c == null){
                RehospLookupHospital.hospitalLookup(r.id, r.discharge_location__c);
            }
        }}

And here is the CLASS:
public class RehospLookupHospital {
    public static void hospitalLookup(id rehospId, string hospName){
        List<Rehospitalization__c> rehospToUpdate = new list<Rehospitalization__c>();
        cube_hospital__c ch;
        
         try{
         ch  = [select Id, Name, SF_Account_Id__c from cube_hospital__c where name = : hospName];
           }
        catch(exception e){
            system.debug(e.getMessage());
        }
        
        if (ch != null){
          id sfId = ch.SF_Account_Id__c;
            rehospitalization__c rehosp = [select id, referral_account__c from rehospitalization__c where id = :rehospId];
            rehosp.Referral_Account__c = sfId;
            update rehosp;
        }
        
    }
}
Hello, I need to create a custom button that serves the EXACT functionality of the standard clone button (long story why...). What is the easiest way to do this? Is there a simple url hack?
Hello, I am trying to create a custom button using a URL hack, which prepopulates values. I am starting with a few values, but it does not seem to be working. When i click my button, the name fields and ownerid field do not follow the  Lead from which I am pressing the button. Can anybody show me what I need to change in my code to make this work?

Here is the url code I am using for the custom button:

/lightning/o/Lead/new?recordTypeId=0121N0000012oypQAA&
defaultFieldValues=
name='{!Lead.Name}',
firstname={!Lead.FirstName},
lastname={!Lead.LastName},
OwnerId={!Lead.OwnerId}

 
Hello, if i have a decimal like
decimal dec = 1.234234235345

i ONLY want to display the number with the first 2 digits after the decimal, meaning 1.23. How can I do this in apex?
Hello, I have a List<Map<Date,DataWrapper>>. The DataWrapper class looks like this: 
Public Class DataWrapper{
String toDate;
String NPI;
String locationType;    
}

I need to be able to do the following:
1) sort the items in the list in order of Date (the key values of each map), then 
2) extract the String values from each datawrapper class
3) save ALL values (date, string, string, string) from ALL list-items to fields on my custom object. Can someone assist in how to accomplish all of these steps? Thank you so much i really appreciate any help with writing this code.
Hello, I am working on a VF page, on which users can upload files. After clicking save, I am getting shown a screen with this message: 

Maximum view state size limit (170KB) exceeded. Actual view state size for this page was 1,006.033KB

Any idea how I can stop this error message? The strange thing is that the file seems to be getting uploaded anyways, so I'm not sure what to do with that message.
I have a pdf form, with blank spaces for name, address, etc. Is there a way I can save it (perhaps as a static resource?) and have it autopopulate with fields from my lead object?
Hello, I am setting up my first einstein bot... We have a dialogue that presents a menu. When the user clicks on one of the menu items (also a dialogue) we want it to automatically redirect the user to a new webpage. How can I build this into the bot/dialogue?

hi-

 

i need a custom button that appears at the top of lead records.  the button is a clone button that clones the leqad.  the thing is, the action needs to be that the newly created lead has a different record type than the original.

 

here's my current button code:

 

/{!Lead.Id}/e?clone=1

 

That is the clone functionality.  I need something like "&RecordType="xyz"" but nothign is working.  Any ideas?

 

Thanks