-
ChatterFeed
-
1Best Answers
-
5Likes Received
-
0Likes Given
-
229Questions
-
420Replies
How create case when you create contact?
trigger CreateCase on Contact (before insert) {
List<Case> listCase = new List<Case>();
for(Contact a : Trigger.New) {
listCase.add(new Case(
AccountID=a.AccountID,
ContactID = a.Name,
Priority ='High',
Origin = 'Phone',
Status = 'Working'));
}
if(listCase.size() > 0)
{
insert listCase;
}
}
-
- Vadzim Dzenisenka
- August 04, 2020
- Like
- 0
- Continue reading or reply
How to create new version of contentversion instead of brand new separate contentversion?
Hello, we have an integration where files (contentversions) are being inserted and the contentdocumentlink is to Lead records. My task is that sometimes a new version of the file gets inserted. When that happens, I need to create a trigger that makes it create a new VERSION of the existing document, instead of creating a brand new content version. What would such a trigger look like?
Thank you!
-
- Michael M
- August 10, 2021
- Like
- 0
- Continue reading or reply
How to adjust margins of VF page
<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> <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>
-
- Michael M
- August 02, 2021
- Like
- 0
- Continue reading or reply
How to get around System.LimitException: Query of LOB fields caused heap usage to exceed limit. (in Apex)
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.
-
- Michael M
- July 29, 2021
- Like
- 0
- Continue reading or reply
Apex 400 error: XAmzContentSHA256Mismatch, The provided 'x-amz-content-sha256' header does not match what was computed [closed]
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());
}
}
}
-
- Michael M
- July 19, 2021
- Like
- 0
- Continue reading or reply
Error when trying to send http callout: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
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);
}
}
}
}
-
- Michael M
- July 08, 2021
- Like
- 0
- Continue reading or reply
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);
}
}
}
}
-
- Michael M
- July 07, 2021
- Like
- 0
- Continue reading or reply
Send pdf files to SF through api (connected app), and attach to Leads
-
- Michael M
- June 16, 2021
- Like
- 0
- Continue reading or reply
Making (and recording) phone calls from within SF
-
- Michael M
- June 14, 2021
- Like
- 0
- Continue reading or reply
Connected app-- limit access to only certain records
-
- Michael M
- June 08, 2021
- Like
- 0
- Continue reading or reply
maximum trigger depth exceeded- how to fix
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;
}
}
}
-
- Michael M
- June 07, 2021
- Like
- 0
- Continue reading or reply
URL hack that exactly copies functionality of "clone"
-
- Michael M
- June 02, 2021
- Like
- 0
- Continue reading or reply
Help with URL hack in lightning
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}
-
- Michael M
- May 27, 2021
- Like
- 0
- Continue reading or reply
how to display only first 2 digits after decimal in apex
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?
-
- Michael M
- May 20, 2021
- Like
- 0
- Continue reading or reply
How to loop through List<Map<Date,DataWrapper>> masterList
Here is the data wrapper:
Public Class DataWrapper{
public String toDate;
public String NPI;
public String locationType;
}
And here is where I am trying to sort my list and extract the data:
public class SeekPartAStays {
public static void savePartAStaysDetails2(id EligibilityRecordid, List<Map<Date,SeekExtension.DataWrapper>> masterList){
system.debug('MASTER LIST: ' + masterList);
Eligibility__c eligRec = [select id from eligibility__c where id = :EligibilityRecordid];
List<date> fromDates = new list<date>();
Map<Date, SeekExtension.DataWrapper> dw1 = masterList[0];
Map<Date, SeekExtension.DataWrapper> dw2;
Map<Date, SeekExtension.DataWrapper> dw3;
Map<Date, SeekExtension.DataWrapper> dw4;
Map<Date, SeekExtension.DataWrapper> dw5;
Map<Date, SeekExtension.DataWrapper> dw6;
Map<Date, SeekExtension.DataWrapper> dw7;
Map<Date, SeekExtension.DataWrapper> dw8;
Map<Date, SeekExtension.DataWrapper> dw9;
Map<Date, SeekExtension.DataWrapper> dw10;
Map<Date, SeekExtension.DataWrapper> dw11;
Map<Date, SeekExtension.DataWrapper> dw12;
fromDates.addall(dw1.keyset());
if (masterList.size() > 1){
dw2 = masterList[1];
fromDates.addall(dw2.keyset());
}
if (masterList.size() > 2){
dw3 = masterList[2];
fromDates.addall(dw3.keyset());
}
if (masterList.size() > 3){
dw4 = masterList[3];
fromDates.addall(dw4.keyset());
}
if (masterList.size() > 4){
dw5 = masterList[4];
fromDates.addall(dw5.keyset());
}
if (masterList.size() > 5){
dw6 = masterList[5];
fromDates.addall(dw6.keyset());
}
if (masterList.size() > 6){
dw7 = masterList[6];
fromDates.addall(dw7.keyset());
}
if (masterList.size() > 7){
dw8 = masterList[7];
fromDates.addall(dw8.keyset());
}
if (masterList.size() > 8){
dw9 = masterList[8];
fromDates.addall(dw9.keyset());
}
if (masterList.size() > 9){
dw10 = masterList[9];
fromDates.addall(dw10.keyset());
}
if (masterList.size() > 10){
dw11 = masterList[10];
fromDates.addall(dw11.keyset());
}
if (masterList.size() > 11){
dw12 = masterList[11];
fromDates.addall(dw12.keyset());
}
system.debug('MAP 1: ' + dw1);
system.debug('MAP 2: ' + dw2);
system.debug('MAP 3: ' + dw3);
system.debug('MAP 4: ' + dw4);
system.debug('MAP 5: ' + dw5);
system.debug('MAP 6: ' + dw6);
system.debug('MAP 7: ' + dw7);
system.debug('MAP 8: ' + dw8);
fromDates.sort();
system.debug('FROM DATES FIRST LIST: ' + fromDates) ;
List<date> reversedFromDatesList = new List<date>();
for(Integer i = fromDates.size() - 1; i >= 0; i--){
reversedFromDatesList.add(fromDates[i]);
}
system.debug('REVERSED DATES LIST: ' + reversedFromDatesList) ;
date d = date.today();
reversedFromDatesList.add(d);
system.debug('reversed list item 1: ' + reversedFromDatesList[0]);
system.debug('reversed list item 2: ' + reversedFromDatesList[1]);
system.debug('reversed list item 3: ' + reversedFromDatesList[2]);
system.debug('reversed list item 4: ' + reversedFromDatesList[3]);
system.debug('reversed list item 5: ' + reversedFromDatesList[4]);
system.debug('reversed list item 6: ' + reversedFromDatesList[5]);
system.debug('reversed list item 7: ' + reversedFromDatesList[6]);
system.debug('reversed list item 8: ' + reversedFromDatesList[7]);
SeekExtension.DataWrapper wrapper1;
system.debug('WRAPPER1: ' + wrapper1) ;
SeekExtension.DataWrapper wrapper2;
SeekExtension.DataWrapper wrapper3;
SeekExtension.DataWrapper wrapper4;
SeekExtension.DataWrapper wrapper5;
SeekExtension.DataWrapper wrapper6;
SeekExtension.DataWrapper wrapper7;
SeekExtension.DataWrapper wrapper8;
SeekExtension.DataWrapper wrapper9;
SeekExtension.DataWrapper wrapper10;
SeekExtension.DataWrapper wrapper11;
SeekExtension.DataWrapper wrapper12;
for (date ddd : reversedFromDatesList){
for (Map<Date,SeekExtension.DataWrapper> dddd : masterList){
wrapper1 = dddd.get(ddd);
wrapper2 = dddd.get(ddd);
wrapper3 = dddd.get(ddd);
wrapper4 = dddd.get(ddd);
wrapper5 = dddd.get(ddd);
wrapper6 = dddd.get(ddd);
wrapper7 = dddd.get(ddd);
wrapper8 = dddd.get(ddd);
wrapper9 = dddd.get(ddd);
wrapper10 = dddd.get(ddd);
wrapper11 = dddd.get(ddd);
wrapper12 = dddd.get(ddd);
system.debug('wrapper1: ' +wrapper1 );
system.debug('wrapper2: ' +wrapper2);
system.debug('wrapper3: ' +wrapper3 );
system.debug('wrapper4: ' +wrapper4 );
system.debug('wrapper5: ' +wrapper5 );
system.debug('wrapper6: ' +wrapper6 );
system.debug('wrapper7: ' +wrapper7 );
system.debug('wrapper8: ' +wrapper8 );
}}
string fromDate1 = string.valueof(reversedFromDatesList[0]);
string fromDate2;
string fromDate3;
string fromDate4;
string fromDate5;
string fromDate6;
string fromDate7;
string fromDate8;
string fromDate9;
string fromDate10;
string fromDate11;
string fromDate12;
string toDate1= wrapper1.toDate;
string toDate2;
string toDate3;
string toDate4;
string toDate5;
string toDate6;
string toDate7;
string toDate8;
string toDate9;
string toDate10;
string toDate11;
string toDate12;
string npi1= wrapper1.NPI;
string npi2;
string npi3;
string npi4;
string npi5;
string npi6;
string npi7;
string npi8;
string npi9;
string npi10;
string npi11;
string npi12;
string locationType1= wrapper1.locationType;
string locationType2;
string locationType3;
string locationType4;
string locationType5;
string locationType6;
string locationType7;
string locationType8;
string locationType9;
string locationType10;
string locationType11;
string locationType12;
system.debug('AND AGAIN. REVERSED DATES LIST: ' + reversedFromDatesList) ;
eligRec.seek_Hospital_from_date_1__c = fromDate1;
eligRec.seek_Hospital_to_date_1__c = toDate1;
eligRec.seek_Hospital_NPI_1__c = npi1;
eligRec.CS_Description1__c = locationType1;
system.debug('wrapper1: '+ wrapper1);
system.debug('DW2: '+ dw2);
for (Map<Date,SeekExtension.DataWrapper> dd : masterList){
if (dd.get( reversedFromDatesList[0]) != null){
wrapper2 = dw2.get(reversedFromDatesList[0]);
system.debug('TRIAL wrapper2: ' + wrapper2);
fromDate2 = string.valueof(reversedFromDatesList[1]);
if (wrapper2 != null){
toDate2= wrapper2.toDate;
npi2= wrapper2.NPI;
locationType2= wrapper2.locationType;
eligRec.seek_Hospital_from_date_2__c = fromDate2;
eligRec.seek_Hospital_to_date_2__c = toDate2;
eligRec.seek_Hospital_NPI_2__c = npi2;
eligRec.CS_Description2__c = locationType2;
}
}
if (reversedFromDatesList.size() >= 2){
wrapper3 = dw3.get(reversedFromDatesList[3]);
system.debug('wrapper3: ' + wrapper3);
fromDate3 = string.valueof(reversedFromDatesList[2]);
toDate3= wrapper3.toDate;
npi3= wrapper3.NPI;
locationType3= wrapper3.locationType;
eligRec.seek_Hospital_from_date_3__c = fromDate3;
eligRec.seek_Hospital_to_date_3__c = toDate3;
eligRec.seek_Hospital_NPI_3__c = npi3;
eligRec.CS_Description3__c = locationType3;
}
if (reversedFromDatesList.size() > 3){
wrapper4 = dw4.get(reversedFromDatesList[3]);
system.debug('wrapper4: ' + wrapper4);
fromDate4 = string.valueof(reversedFromDatesList[3]);
toDate4= wrapper4.toDate;
npi4= wrapper4.NPI;
locationType4= wrapper4.locationType;
eligRec.seek_Hospital_from_date_4__c = fromDate4;
eligRec.seek_Hospital_to_date_4__c = toDate4;
eligRec.seek_Hospital_NPI_4__c = npi4;
eligRec.CS_Description4__c = locationType4;
}
if (reversedFromDatesList.size() > 4){
wrapper5 = dw5.get(reversedFromDatesList[4]);
fromDate5 = string.valueof(reversedFromDatesList[4]);
toDate5= wrapper5.toDate;
npi5= wrapper5.NPI;
locationType5= wrapper5.locationType;
eligRec.seek_Hospital_from_date_5__c = fromDate5;
eligRec.seek_Hospital_to_date_5__c = toDate5;
eligRec.seek_Hospital_NPI_5__c = npi5;
eligRec.CS_Description5__c = locationType5;
}
if (reversedFromDatesList.size() > 5){
wrapper6 = dw6.get(reversedFromDatesList[5]);
fromDate6 = string.valueof(reversedFromDatesList[5]);
toDate6= wrapper6.toDate;
npi6= wrapper6.NPI;
locationType6= wrapper6.locationType;
eligRec.seek_Hospital_from_date_6__c = fromDate6;
eligRec.seek_Hospital_to_date_6__c = toDate6;
eligRec.seek_Hospital_NPI_6__c = npi6;
eligRec.CS_Description6__c = locationType6;
}
if (reversedFromDatesList.size() > 6){
wrapper7 = dw7.get(reversedFromDatesList[6]);
fromDate7 = string.valueof(reversedFromDatesList[7]);
toDate7= wrapper7.toDate;
npi7= wrapper7.NPI;
locationType7= wrapper7.locationType;
eligRec.seek_SNF_from_date_1__c = fromDate7;
eligRec.seek_SNF_to_date_1__c = toDate7;
eligRec.seek_SNF_NPI_1__c = npi7;
eligRec.CS_Description7__c = locationType7;
}
if (reversedFromDatesList.size() > 7){
wrapper8 = dw8.get(reversedFromDatesList[7]);
fromDate8 = string.valueof(reversedFromDatesList[7]);
toDate8= wrapper8.toDate;
npi8= wrapper8.NPI;
locationType8= wrapper8.locationType;
eligRec.seek_SNF_from_date_2__c = fromDate8;
eligRec.seek_SNF_to_date_2__c = toDate8;
eligRec.seek_SNF_NPI_2__c = npi8;
eligRec.CS_Description8__c = locationType8;
}
if (reversedFromDatesList.size() > 8){
wrapper9 = dw9.get(reversedFromDatesList[8]);
fromDate9 = string.valueof(reversedFromDatesList[8]);
toDate9= wrapper9.toDate;
npi9= wrapper9.NPI;
locationType9= wrapper9.locationType;
eligRec.seek_SNF_from_date_3__c = fromDate9;
eligRec.seek_SNF_to_date_3__c = toDate9;
eligRec.seek_SNF_NPI_3__c = npi9;
eligRec.CS_Description9__c = locationType9;
}
if (reversedFromDatesList.size() > 9){
wrapper10 = dw10.get(reversedFromDatesList[9]);
fromDate10 = string.valueof(reversedFromDatesList[9]);
toDate10= wrapper10.toDate;
npi10= wrapper10.NPI;
locationType10= wrapper10.locationType;
eligRec.seek_SNF_from_date_4__c = fromDate10;
eligRec.seek_SNF_to_date_4__c = toDate10;
eligRec.seek_SNF_NPI_4__c = npi10;
eligRec.CS_Description10__c = locationType10;
}
if (reversedFromDatesList.size() > 10){
wrapper11 = dw11.get(reversedFromDatesList[10]);
fromDate11 = string.valueof(reversedFromDatesList[10]);
toDate11= wrapper11.toDate;
npi11= wrapper11.NPI;
locationType11= wrapper11.locationType;
eligRec.seek_SNF_from_date_5__c = fromDate11;
eligRec.seek_SNF_to_date_5__c = toDate11;
eligRec.seek_SNF_NPI_5__c = npi11;
eligRec.CS_Description11__c = locationType11;
}
if (reversedFromDatesList.size() > 11){
wrapper12 = dw12.get(reversedFromDatesList[11]);
fromDate12 = string.valueof(reversedFromDatesList[11]);
toDate12= wrapper12.toDate;
npi12= wrapper12.NPI;
locationType12= wrapper12.locationType;
eligRec.seek_SNF_from_date_6__c = fromDate12;
eligRec.seek_SNF_to_date_6__c = toDate12;
eligRec.seek_SNF_NPI_6__c = npi12;
eligRec.CS_Description12__c = locationType12;
}
}
update EligRec;
}}
-
- Michael M
- April 26, 2021
- Like
- 0
- Continue reading or reply
How to fetch items from Map<Date, SeekExtension.DataWrapper>
String toDate;
String NPI;
String locationType;
}
In that class, I have instantiated some DataWrapper class instances and added to a map like this: Map<Date, DataWrapper>.
Now, I have a second class in which I am calling those maps. My questoin is, how can I fetch the details of the DataWrapper class from those Maps? E.g. I want to see the toDate string and the NPI string. How can I get those when my map is my starting point?
-
- Michael M
- April 20, 2021
- Like
- 0
- Continue reading or reply
Sorting List<Map<Date,DataWrapper>> in order of date (key) values
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.
-
- Michael M
- April 20, 2021
- Like
- 0
- Continue reading or reply
Maximum view state size limit (170KB) exceeded error
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.
-
- Michael M
- April 13, 2021
- Like
- 0
- Continue reading or reply
Automate filling in PDF?
-
- Michael M
- March 18, 2021
- Like
- 0
- Continue reading or reply
How to query the record that was created right before and right after the current record?
-
- Michael M
- March 11, 2021
- Like
- 0
- Continue reading or reply
Einstein bots- redirect to webpage
-
- Michael M
- October 13, 2020
- Like
- 1
- Continue reading or reply
How to get values from objects in List from JSON
"dates": [
{
"name": "Service",
"qualifier": "472",
"date": "2020-09-29"
},
{
"name": "Plan Begin",
"qualifier": "346",
"date": "2020-09-01"
},
{
"name": "Issue",
"qualifier": "102",
"date": "2020-06-01"
}
],
I need to be able to get the values from each "object" individually.
I am getting the list like this:
Map<String, Object> wholeResponse = (Map<String, Object>) JSON.deserializeUntyped(response2.getBody());
Map<String, Object> result = (Map<String, Object>) wholeResponse.get('result');
List<Object> lstdates = (List<Object>) result.get('dates');
But after that I am getting stuck. How would I be able to get the name, qualifier, and date from each object contained in this list? (This may be a basic question, but I am a newbie to json parsing:))
-
- Michael M
- September 30, 2020
- Like
- 1
- Continue reading or reply
Help with JSON.deserialzeuntyped parsing
Here is the snippet of the JSON I am parsing:
"result": {
"first_name": "JOHN",
"last_name": "SMITH",
"id_type": "MI",
"subscriber_id": "1234567",
"gender": "M",
"birthdate": "19601119",
"address": {
"info": "123 Main St.",
"city": "New York",
"state": "NY",
"zip_code": "100000"
},
"county:": {
"value": "14"
},
"office": {
"value": "H78"
},
"recert_month": {
"value": "12",
"name": "December"
},
"dates": [
{
"name": "Service",
"qualifier": "472",
"date": "2020-09-29"
},
{
"name": "Plan Begin",
"qualifier": "346",
"date": "2020-09-01"
},
{
"name": "Issue",
"qualifier": "102",
"date": "2020-06-01"
}
],
Here is how I am parsing it (bold part is causing error):
Map<String, Object> wholeResponse = (Map<String, Object>) JSON.deserializeUntyped(response2.getBody());
Map<String, Object> result = (Map<String, Object>) wholeResponse.get('result');
Map<String, Object> residentAddress = (Map<String, Object>) result.get('address');
Map<String, Object> county = (Map<String, Object>) result.get('county');
Map<String, Object> office = (Map<String, Object>) result.get('office');
Map<String, Object> recert_month = (Map<String, Object>) result.get('recert_month');
Eligibility__c newEligRec = new Eligibility__c();
newEligRec.Referral_Name__c = ref.id;
newEligRec.First_Name__c = string.valueof(result.get('first_name'));
newEligRec.Last_Name__c = string.valueof(result.get('last_name'));
newEligRec.Name_Id_Type__c = string.valueof(result.get('id_type'));
newEligRec.Client_ID__c = string.valueOf(result.get('subscriber_id'));
newEligRec.Gender__c = string.valueOf(result.get('gender'));
string birthdate;
if (string.valueof(result.get('birthdate')) != null){
birthdate = string.valueof(result.get('birthdate')).remove('-');
string year = birthdate.substring(0,4);
string month = birthdate.substring(4,6);
string day = birthdate.substring(6,8);
birthdate = month + '/' + day + '/' + year;
}
newEligRec.Date_of_Birth__c = birthdate;
newEligRec.Address_Number_and_Street__c = string.valueOf(residentAddress.get('info'));
newEligRec.City__c = string.valueOf(residentAddress.get('city'));
newEligRec.State__c = string.valueOf(residentAddress.get('state'));
newEligRec.Zip_Code__c = string.valueOf(residentAddress.get('zip_code'));
newEligRec.County__c = string.valueOf(county.get('value'));
newEligRec.Office__c = string.valueOf(office.get('value'));
newEligRec.Recertification_Month_value__c = string.valueOf(recert_month.get('value'));
newEligRec.Recertification_Month__c = string.valueOf(recert_month.get('name'));
-
- Michael M
- September 30, 2020
- Like
- 1
- Continue reading or reply
Test class for apex schedulable class__
global class purgeFiles implements Schedulable{
global void execute(SchedulableContext SC) {
List<ContentDocumentLink > docs;
docs = [SELECT Id, Linkedentity.name, Linkedentity.id,ContentDocument.CreatedDate
FROM contentDocumentLink
WHERE Linkedentityid
IN (SELECT Id FROM lead where createddate < Last_N_Days:7 and isconverted = false) ];
//may want to change to include ALL leads
//AND ContentDocument.CreatedDate < Last_N_Days:7];
if(!docs.isEmpty())
delete docs;
}
}
Thank you very much
-
- Michael M
- March 24, 2020
- Like
- 1
- Continue reading or reply
Error: Component 'Visualforce' has an invalid value for property 'Visualforce Page Name'.
-
- Michael M
- March 04, 2020
- Like
- 1
- Continue reading or reply
How to adjust margins of VF page
<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> <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>
- Michael M
- August 02, 2021
- Like
- 0
- Continue reading or reply
How to get around System.LimitException: Query of LOB fields caused heap usage to exceed limit. (in Apex)
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.
- Michael M
- July 29, 2021
- Like
- 0
- Continue reading or reply
Apex 400 error: XAmzContentSHA256Mismatch, The provided 'x-amz-content-sha256' header does not match what was computed [closed]
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());
}
}
}
- Michael M
- July 19, 2021
- Like
- 0
- Continue reading or reply
Error when trying to send http callout: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
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);
}
}
}
}
- Michael M
- July 08, 2021
- Like
- 0
- Continue reading or reply
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);
}
}
}
}
- Michael M
- July 07, 2021
- Like
- 0
- Continue reading or reply
Send pdf files to SF through api (connected app), and attach to Leads
- Michael M
- June 16, 2021
- Like
- 0
- Continue reading or reply
Making (and recording) phone calls from within SF
- Michael M
- June 14, 2021
- Like
- 0
- Continue reading or reply
Connected app-- limit access to only certain records
- Michael M
- June 08, 2021
- Like
- 0
- Continue reading or reply
test class 66% coverage
@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
- Marco Pollastri 1
- June 08, 2021
- Like
- 0
- Continue reading or reply
maximum trigger depth exceeded- how to fix
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;
}
}
}
- Michael M
- June 07, 2021
- Like
- 0
- Continue reading or reply
URL hack that exactly copies functionality of "clone"
- Michael M
- June 02, 2021
- Like
- 0
- Continue reading or reply
Help with URL hack in lightning
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}
- Michael M
- May 27, 2021
- Like
- 0
- Continue reading or reply
how to display only first 2 digits after decimal in apex
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?
- Michael M
- May 20, 2021
- Like
- 0
- Continue reading or reply
Sorting List<Map<Date,DataWrapper>> in order of date (key) values
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.
- Michael M
- April 20, 2021
- Like
- 0
- Continue reading or reply
Maximum view state size limit (170KB) exceeded error
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.
- Michael M
- April 13, 2021
- Like
- 0
- Continue reading or reply
Automate filling in PDF?
- Michael M
- March 18, 2021
- Like
- 0
- Continue reading or reply
Einstein bots- redirect to webpage
- Michael M
- October 13, 2020
- Like
- 1
- Continue reading or reply
clone lead but change record type
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
- SFAdmin5
- September 26, 2011
- Like
- 0
- Continue reading or reply