• Abby Stocker
  • NEWBIE
  • 70 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 28
    Replies
Hello! I have a screen flow launched from a custom button. In the URL, I am try to pass in the recordId and CaseNumber. See URL below...nothing is being passed in? THank you!

/flow/Delivery_Completed_Successfully?varCaseNumber={!Case.CaseNumber}&&recordId={!Case.Id}
I am hoping someone can help me :(

I have a test class that just keeps failing and I do now know what is wrong? When I run the test class, this is the error I get:
"System.AuraHandledException: Script-thrown exception" and the stack trace: Class.CaseFileFormServerController.insertCasesFile: line 56, column 1
Class.CaseFileFormServerControllerTest.insertCasesFileTest: line 55, column 1

Any help is GREATLY appreciated. Thank you!!!
@IsTest
public class CaseFileFormServerControllerTest {
	@TestSetup
    private static void setupTestData() {
        Case mockCase = new Case();
        insert MockCase;
        
        Case_File__c mockCaseFile = new Case_File__c(
        	Case__c = mockCase.Id,
        	Department__c = 'Logistics');
        insert mockCaseFile;
        
        ContentDocumentSelectorTest.createMockContentDocument();
    }
    
    private static testmethod void linkFileToCaseFile_success() {
        Id mockDocumentId = fetchContentDocumentId();
        Id mockCaseFileId = fetchMockCaseFileId();
        Id caseId = fetchCaseId();
        
        String result = CaseFileFormServerController.linkFileToCaseFile(mockDocumentId, mockCaseFileId);
        System.assertEquals('SUCCESS', result, 'An exception was caught: ' + result);
    }
    
    private static testmethod void linkFileToCaseFile_exceptionWasCaught() {
        Id mockAccountId = Id.valueOf('0014B00000WUh5tQAD');
        Id mockCaseFileId = fetchMockCaseFileId();
        Id caseId = fetchCaseId();
        
        String result = CaseFileFormServerController.linkFileToCaseFile(mockAccountId, mockCaseFileId);
        System.assert(result.contains('Exception:'), 'No exception was caught');
    }
    
   
    private static testmethod void insertCasesFileTest() {
        test.startTest();
        PricebookTestDataGenerator.generatePriceBookData();
        Id priceBookEntryId = [SELECT Id FROM PricebookEntry LIMIT 1].Id;
        Id product2Id = [SELECT Id FROM Product2].Id;
        Account account = new Account(Name = 'Test Account');
        INSERT account;
        Order__c order1 = new Order__c(AccountId__c = account.Id);
		INSERT order1;
        
        Order_Line__c orderLine1 = new Order_Line__c();
        orderLine1.Order__c = order1.Id;
        orderLine1.Quantity__c = 1;
        orderLine1.Salesperson__c = UserInfo.getUserId();
        orderLine1.Product2Id__c = product2Id;
        INSERT orderLine1;
        Id mockDocumentId = fetchContentDocumentId();
        Id mockCaseFileId = fetchMockCaseFileId();
        Id caseId = fetchCaseId();
        List<ContentDocument> mockDocument = [SELECT Id, Title FROM ContentDocument LIMIT 1];
        CaseFileFormServerController.insertCasesFile('Test',String.valueOf(caseId),'00022334','Driver',orderLine1.Id,'Product Damage','','Stone Cracked/Chipped','Test',mockDocument);
       	test.stopTest();
        // System.assertEquals('SUCCESS', result, 'An exception was caught: ' + result);
    }
    public static Id fetchContentDocumentId() {
        ContentDocument mockDocument = [SELECT Id, Title FROM ContentDocument LIMIT 1];
        System.assertNotEquals(null, mockDocument, 'Mock document came in as null');
        return mockDocument.Id;
    }
    
    public static Id fetchMockCaseFileId() {
        Case_File__c mockCaseFile = [SELECT Id, Case__c, Department__c FROM Case_File__c LIMIT 1];
        System.assertNotEquals(null, mockCaseFile, 'Mock case file came in as null');
        return mockCaseFile.Id;
    }
    
    public static Id fetchCaseId() {
        Case mockCase = [SELECT Id, CaseNumber FROM Case LIMIT 1];
        System.assertNotEquals(null, mockCase, 'Mock case came in as null');
        return mockCase.Id;
    }
}



 
Hello! 
There is code (that I did not originally write) that I have been digging through to try to find out how to make a field required. What this code is doing: On a case, the user can select an option to "Tag Images". This will take them to a component and they can fill out specified fields. After the select "Submit", this will create a Case File record and it will be linked to the case. On the component screen, there are about 6 fields. Two of them need to be required to move forward. One is currently required and I will provide screenshots below.
They select a photo to tag:
User-added image
They then get taken to a screen to fill out information about the image(s). Primary Reason (Return_Reason__c) and Secondary Reason (Return_Reason_Secondary__c) need to be required just like Order Line (Order_Line__c) is. I was able to add the asterisks in the code but I cannot get it to error on null. Here is the screen:
User-added image
When you leave Order Line blank, here is the error:
User-added imageI need this to happen when Primary Reason and Secondary Reason are left blank as well. After looking through all of the code, I found the component screen and added the highlighted text to show the asterisks on the two fields:
User-added imageThe only other thing I could find was in the Helper, I believe this is where the error message comes from for the Null Order Line:
} else if(state === "ERROR"){
                var errors = action.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        //alert(errors[0].message);
                        var toastEvent = $A.get("e.force:showToast");
                        toastEvent.setParams({
                            title : 'Error',
                            message:'There is an error '+errors[0].message+'',
                            mode: 'sticky',
                            key: 'info_alt',
                            type: 'error'
                        });
                        toastEvent.fire();

But what I cannot find is the middle piece here. Where would it state in the code that IF Order Line is null - Display this error? Full Component in comments.
Thank you very much!!!!


 
We are trying to create a validation rule. We have one profile, "Service with Live Agent" that should not be able to change the record type of a case to "Purged Info" (They shouldnt be able to create a record of that record type either). This is the validation rule we have right now but it is throwing email to case errors on existing cases. Any ideas? Thank you!!

(ISNEW() || ISCHANGED(RecordTypeId)) && RunningUser.Profile.Name = 'Service With Live Agent' && RecordType.DeveloperName = 'Purged_Info'
Hello! Here is the problem:

The process is the representaive will email the client asking for photos of damage. The client will then email back including 3 photos. Those 3 photos (and the email signature photo..ugh) will attach to the case as 3 related files
Now the representative will forward that email to the appropriate person (not always a SF user) but those three photos will attach again to the case as files. So now there are 6 photos (duplicates). When I delete one, it will delete its duplicate as well. 
Is there a way to stop this? Is there a trigger I can use that will not save the file to the record if a file of the same name and size already exists?? Thank you! 
Hello! We have custom email functionality built for a custom object, "Delivery Exceptions". This email functionality replicates that of email to case as in you send an email out with the exception reference number and the replies will attach to the approriate record and each has an email message related list to store them. I have an ask that these emails ALSO come into the exception chatter feed just like they do for email to case. Here is what the emails look like now in the chatter feed:
User-added imageHere is what they look like in Case:
User-added imageHow can I make fix the code to accomplish this? They also want the ability to reply/forward from the chatter post as well like you can with email to case. Any help is GREATLY appreciated. Thank you! 

Here is the code as it stands:

global class DeliveryEmailHandler implements Messaging.InboundEmailHandler {
    
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
        try{
            id deliveryexceptionId;
            string emailBody = email.plainTextBody;        
            string deliveryexceptionName ='';
            string emailSubject= email.subject;
            system.debug('email subject'+emailSubject);
            pattern regEx = Pattern.compile('(E[0-9]{8})');
            matcher deliveryexceptionMatcherSubject = regEx.matcher(emailSubject);
            //deliveryexceptionMatcherSubject.find();
            if(deliveryexceptionMatcherSubject.find() && deliveryexceptionMatcherSubject.group(1) != null){
                deliveryexceptionName = deliveryexceptionMatcherSubject.group(1);
                system.debug('Delivery Exception name found in subject');
            } else {
                // try body of email if not in subject
                matcher deliveryexceptionMatcherBody = regEx.matcher(emailBody);
                //deliveryexceptionMatcherBody.find();
                if(deliveryexceptionMatcherBody.find() && deliveryexceptionMatcherBody.group(1) != null){
                    deliveryexceptionName = deliveryexceptionMatcherBody.group(1);
                    system.debug('Delivery Exception name found in body');
                } 
            }
            // if matcher matches find delivery exception record
            If (deliveryexceptionName != ''){
                list<Delivery_Exception__c> deliveryexceptionList = [select id,name,account__c from Delivery_Exception__c where name = :deliveryexceptionName];
                if(!deliveryexceptionList.isEmpty() && deliveryexceptionList.size() == 1){
                    deliveryexceptionId = deliveryexceptionList[0].id;
                }
            }
            // attach to error delivery exception if no delivery exception record is found
            if(deliveryexceptionId == null){
                deliveryexceptionId = [select id from Delivery_Exception__c where external_id__c = 'ERROR' limit 1].Id;
            }
            EmailMessage cEmailMessage = new EmailMessage();
            cEmailMessage.ToAddress =  String.join(email.toAddresses, ',');
            cEmailMessage.FromAddress = email.FromAddress;
            cEmailMessage.FromName = email.FromName;
            cEmailMessage.Subject = email.subject;
            cEmailMessage.status = '0';
            cEmailMessage.HtmlBody = email.htmlBody;
            //System.debug('htmlBody:>>>> ' + email.htmlBody );
            cEmailMessage.Incoming= True;
            cEmailMessage.TextBody = email.plainTextBody;
            cEmailMessage.relatedToId = deliveryexceptionId;
            cEmailMessage.Delivery_Exception__c = deliveryexceptionId;
            //cEmailMessage.validatedFromAddress = 'deliverytest@Arhaus.com';
            //System.debug('TextBody:>>>>> ' + email.plainTextBody);
            insert cEmailMessage;
            FeedItem item = new FeedItem();
            item.parentId = cEmailMessage.relatedToId = deliveryexceptionId;
            item.Body = cEmailMessage.relatedToId = deliveryexceptionId;
            insert item;
            System.debug('Reply Email: ' + cEmailMessage ); 
            //Add Email Message Relation the from address
            list<emailMessageRelation> emailMessageRelations = new list<emailMessageRelation>();
            emailMessageRelations.add(new EmailMessageRelation(
                EmailMessageId = cEmailMessage.id,
                RelationAddress = email.FromAddress,
                RelationType = 'FromAddress'));
            // as of 10-24-19 Salesforce required a relationship to be able to reply.
            // this code section can be removed when Salesforce support Org Wide Email Addresses to be used on custom objects
            // with the functionality supported on the case object.
            // 
            for(user u : [select id,email from user where Exception_Email_Functionality__c = true and isactive = true]){
                emailMessageRelations.add(new EmailMessageRelation(EmailMessageId = cEmailMessage.id, RelationId = u.id, RelationType = 'BccAddress'));    
            }
            insert emailMessageRelations;
            // if email attachments are not null create files
            if(email.binaryAttachments != null) createContentDocumentLinks(email.binaryAttachments, cEmailMessage.id, deliveryexceptionId);
        } catch(exception e){
            system.debug('exception processing delivery exception inbound email:'+e.getMessage());
        }
        result.success = true;
        return result;
    }
    public boolean createContentDocumentLinks(Messaging.InboundEmail.BinaryAttachment[] binAttachList, Id insertedEmailMessageId, Id deliveryexceptionId) {
        List<ContentVersion>cvList = new List<ContentVersion>();
        List<ContentDocumentLink> cdlList = new List<ContentDocumentLink>();
        for (Messaging.InboundEmail.BinaryAttachment binAttach : binAttachList) {
            ContentVersion testContentInsert = new ContentVersion();
            testContentInsert.Title = binAttach.fileName;
            testContentInsert.VersionData = binAttach.body;
            testContentInsert.PathOnClient = '/' + binAttach.fileName ;
            cvList.add(testContentInsert);
            
        }
        insert cvList;
        cvList = [select id, ContentDocumentId from ContentVersion WHERE Id in :cvList];
        for (ContentVersion cv : cvList) {
            ContentDocumentLink cl = new ContentDocumentLink();
            cl.ContentDocumentId = cv.ContentDocumentId;
            cl.LinkedEntityId = insertedEmailMessageId;
            cl.ShareType = 'V';
            cl.Visibility = 'AllUsers';
            cdlList.add(cl);
            // add link to delivery exception also
            ContentDocumentLink clc = new ContentDocumentLink();
            clc.ContentDocumentId = cv.ContentDocumentId;
            clc.LinkedEntityId = deliveryexceptionId;
            clc.ShareType = 'V';
            clc.Visibility = 'AllUsers';
            cdlList.add(clc);
        }
        insert cdlList;
        return true;
    }
}
Hello! We have created custom email functionality on a custom object that acts almost exactly like email to case. The problem I am facing is that the email comes in and connects to the correct Delivery Exception record (custom object) but doesnt create a feed item like email to case does. The users would like to see the emails in the chatter feed of the record as well as the email message related list (email message related list is created) would the code look something like the following (I am still in the beginning stages of learning to code)?
{
FeedItem item = new Feeditem();
FeedItem post = new FeedItem();
post.ParentId = deliveryexceptionId;
post.Body = email.plainTextBody;
Insert Post;
}

Here is the class as it stands now:

global class DeliveryEmailHandler implements Messaging.InboundEmailHandler {
    
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
        try{
            id deliveryexceptionId;
            string emailBody = email.plainTextBody;        
            string deliveryexceptionName ='';
            string emailSubject= email.subject;
            system.debug('email subject'+emailSubject);
            pattern regEx = Pattern.compile('(E[0-9]{8})');
            matcher deliveryexceptionMatcherSubject = regEx.matcher(emailSubject);
            //deliveryexceptionMatcherSubject.find();
            if(deliveryexceptionMatcherSubject.find() && deliveryexceptionMatcherSubject.group(1) != null){
                deliveryexceptionName = deliveryexceptionMatcherSubject.group(1);
                system.debug('Delivery Exception name found in subject');
            } else {
                // try body of email if not in subject
                matcher deliveryexceptionMatcherBody = regEx.matcher(emailBody);
                //deliveryexceptionMatcherBody.find();
                if(deliveryexceptionMatcherBody.find() && deliveryexceptionMatcherBody.group(1) != null){
                    deliveryexceptionName = deliveryexceptionMatcherBody.group(1);
                    system.debug('Delivery Exception name found in body');
                } 
            }
            // if matcher matches find delivery exception record
            If (deliveryexceptionName != ''){
                list<Delivery_Exception__c> deliveryexceptionList = [select id,name,account__c from Delivery_Exception__c where name = :deliveryexceptionName];
                if(!deliveryexceptionList.isEmpty() && deliveryexceptionList.size() == 1){
                    deliveryexceptionId = deliveryexceptionList[0].id;
                }
            }
            // attach to error delivery exception if no delivery exception record is found
            if(deliveryexceptionId == null){
                deliveryexceptionId = [select id from Delivery_Exception__c where external_id__c = 'ERROR' limit 1].Id;
            }
            EmailMessage cEmailMessage = new EmailMessage();
            cEmailMessage.ToAddress =  String.join(email.toAddresses, ',');
            cEmailMessage.FromAddress = email.FromAddress;
            cEmailMessage.FromName = email.FromName;
            cEmailMessage.Subject = email.subject;
            cEmailMessage.status = '0';
            cEmailMessage.HtmlBody = email.htmlBody;
            //System.debug('htmlBody:>>>> ' + email.htmlBody );
            cEmailMessage.Incoming= True;
            cEmailMessage.TextBody = email.plainTextBody;
            cEmailMessage.relatedToId = deliveryexceptionId;
            cEmailMessage.Delivery_Exception__c = deliveryexceptionId;
            //cEmailMessage.validatedFromAddress = 'deliverytest@Arhaus.com';
            //System.debug('TextBody:>>>>> ' + email.plainTextBody);
            insert cEmailMessage;
            System.debug('Reply Email: ' + cEmailMessage ); 
            //Add Email Message Relation the from address
            list<emailMessageRelation> emailMessageRelations = new list<emailMessageRelation>();
            emailMessageRelations.add(new EmailMessageRelation(
                EmailMessageId = cEmailMessage.id,
                RelationAddress = email.FromAddress,
                RelationType = 'FromAddress'));
            // as of 10-24-19 Salesforce required a relationship to be able to reply.
            // this code section can be removed when Salesforce support Org Wide Email Addresses to be used on custom objects
            // with the functionality supported on the case object.
            // 
            for(user u : [select id,email from user where Exception_Email_Functionality__c = true and isactive = true]){
                emailMessageRelations.add(new EmailMessageRelation(EmailMessageId = cEmailMessage.id, RelationId = u.id, RelationType = 'BccAddress'));    
            }
            insert emailMessageRelations;
            // if email attachments are not null create files
            if(email.binaryAttachments != null) createContentDocumentLinks(email.binaryAttachments, cEmailMessage.id, deliveryexceptionId);
        } catch(exception e){
            system.debug('exception processing delivery exception inbound email:'+e.getMessage());
        }
        result.success = true;
        return result;
    }
    public boolean createContentDocumentLinks(Messaging.InboundEmail.BinaryAttachment[] binAttachList, Id insertedEmailMessageId, Id deliveryexceptionId) {
        List<ContentVersion>cvList = new List<ContentVersion>();
        List<ContentDocumentLink> cdlList = new List<ContentDocumentLink>();
        for (Messaging.InboundEmail.BinaryAttachment binAttach : binAttachList) {
            ContentVersion testContentInsert = new ContentVersion();
            testContentInsert.Title = binAttach.fileName;
            testContentInsert.VersionData = binAttach.body;
            testContentInsert.PathOnClient = '/' + binAttach.fileName ;
            cvList.add(testContentInsert);
            
        }
        insert cvList;
        cvList = [select id, ContentDocumentId from ContentVersion WHERE Id in :cvList];
        for (ContentVersion cv : cvList) {
            ContentDocumentLink cl = new ContentDocumentLink();
            cl.ContentDocumentId = cv.ContentDocumentId;
            cl.LinkedEntityId = insertedEmailMessageId;
            cl.ShareType = 'V';
            cl.Visibility = 'AllUsers';
            cdlList.add(cl);
            // add link to delivery exception also
            ContentDocumentLink clc = new ContentDocumentLink();
            clc.ContentDocumentId = cv.ContentDocumentId;
            clc.LinkedEntityId = deliveryexceptionId;
            clc.ShareType = 'V';
            clc.Visibility = 'AllUsers';
            cdlList.add(clc);
        }
        insert cdlList;
        return true;
    }
}


THANK YOU SO MUCH FOR ANY ASSISTANCE!!!!
Please help with the following error, Thank you so much.
ERROR:
Error while creating component for lightning component quick action [Unable to find action 'PhysicalInventoryClaimPDF' on the controller of c:PhysicalInventoryClaimPDF]

COMPONENT:
<aura:component description="PhysicalInventoryClaimPDF" controller="PhysicalInventoryPDFController" implements="force:lightningQuickAction,force:hasRecordId">

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <aura:attribute name="recordId" type="Id"/>
    <aura:attribute name="documentId" type="Id"/>
    <aura:attribute name="documentCreated" type="Boolean"/>

    <div>
        <lightning:fileCard fileId="{!v.documentId}" description="{!'Loss and Damage Claim Form'}"/>
    </div>
</aura:component>

CONTROLLER:
({
    doInit: function (component, event, helper) {
        helper.getPdfToDownload(component);
    },

    savePdf: function (component, event, helper) {
        console.log('SAVING');
    },
});

HELPER:
({
 
    getPdfToDownload: function (component) {
        var getPdfAction = component.get("c.PhysicalInventoryClaimPDF");
        getPdfAction.setParams({
            claimId: component.get("v.recordId")
        });
        getPdfAction.setCallback(this, function (response) {
            var responseState = response.getState();
            if (responseState === "SUCCESS") {
                component.set("v.documentId", response.getReturnValue());
                component.set("v.documentCreated", true);
            } else {
                alert("Error message: " + JSON.stringify(response.getError()));
            }
        });
        $A.enqueueAction(getPdfAction);
    }
});
Please help with the following error. Thank you! 
User-added imageUser-added image
This is strange and must be something simple. I have a lightning quick action on the Claim custom object that should initiate the download of the "HomeDamage" visualforce page but when you click on the button it takes you to the "deliverynew" visualforce page instead?????? Any help is appreciated. Here is what I have provided below: Screenshot of quick action button, screenshot of quick action settings, screenshot of debug log and then the VF page code. 
THANK YOU! 

User-added image
User-added imageUser-added image<apex:page standardController="Claim__c" renderAs="pdf" standardStylesheets="false" sideBar="false" showHeader="false" applyBodyTag="false">
    <head>
        <title>Claim PDF</title>
        <style type="text/css">
            @page {
                margin-top: 10%;
                margin-bottom: 10%;
                margin-left: 5%;
                margin-right: 5%;
            }
            * {
                font-family: Arial;
            }
            div {
                padding-bottom: 1em;
            }
            table {
                text-align: Left;
                margin-left: auto;
                margin-right: auto;
            }
            th {
                font-weight: bold;
            }
            .arhausTitle {
                
                font-size: 12px;
                line-height: 0px;
                text-align: center;
            }
            .formTitle {
                font-size: 11px;
                text-align: center;
                margin-top: 5%;
            }
            .formFooter {
                position: static;
                bottom: 0;
                font-size: 14px;
                text-align: left;
                align-content: left;
                line-height: 24px;
            }
            .contactColumn {
                width: 50%;
                float: left;
                text-align: left;
            }
            .formBlanks {
                
                margin-left: 10%;
                margin-right: auto;
                margin-top: 5%;
                font-size: 14px;
                empty-cells: hide;
                text-align: left; 
            }
            .formBlanks td {
                width: 37%;
                text-align: left;               
            }
            #emptyCell {
                width: 5%;
                border-bottom: none;
            }
            .formTable * {
                font-size: 11px;
                border: 1px solid black;
                border-collapse: collapse;
                empty-cells: show;
                padding: 5px;
            }
            .formTable th {
                text-transform: uppercase;                
            }
            .formTable td {
                text-transform: none;
            }
            .formtext {
                margin-left: 10%;
                margin-right: 10%;
                font-size: 14px;
                empty-cells: hide;
                text-align: left; 
            }  
              .footer {
                margin-top: 20%;
                margin-left: auto;
                margin-right: auto%;
                font-size: 14px; 
                text-align: left;
                               
            }   
        </style>
    </head>
    <body>
        <div class="arhausTitle">
            <div>
                <apex:image url="{!$Resource.QuoteLogo}" width="300px"/>
                <p>51 E. Hines Hill Rd Boston Heights, OH 44236</p>
                
                <p></p>
                
                <p>Phone: (440) 439-7700 Fax: (440) 449-7073</p>
            </div>
        </div>
      
        <div class="formBlanks">
            <table>
                <tr>
                  <td>Claim #: {!Claim__c.Name}</td>                
                </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                 <td>Order #: {!Claim__c.Order_Number__r.Name}</td>
                   </tr>  
                <tr>
                  <td></td>                
                </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                 <td>Client Name: {!Claim__c.Account__r.Name}</td>
                   </tr>  
                <tr>
                  <td></td>                
                </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                  <td>Date of Failed Delivery:
                        <apex:outputText value="{0, date, MMMM d','  yyyy}">
                            <apex:param value="{!Claim__c.Date_of_Occurence__c}" />
                        </apex:outputText>
                    </td>
                 </tr> 
                <tr>
                  <td></td>                
                </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                 <td>Carrier: {!Claim__c.Carrier__c}</td>
                 </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                 <td>Hub Location: {!Claim__c.Hub_Location_DC__c}</td>
                                  </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                  <td></td>                
                </tr>
                
                <tr>
                  <td>Delivery Charge:
                        <apex:outputText value="{0, number, ###,##0.00}">
                            $<apex:param value="{!Claim__c.Additional_Delivery_Charge__c}"/>
                        </apex:outputText>
                    </td>
                </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                  <td></td>                
                </tr>
                <tr>
                 <td>Notes: {!Claim__c.Notes__c}</td>
                                  </tr>
                <div class="footer">
                 Thank you,
                <p>TEXT</p>
                    <p><a style="text-align: left" href="TEXT"> TEXT</a></p>
                  <p>   P: 440.439.7700 x 3226</p>

        </div>
                                                                               
    </table>        
    </div>
    </body>
    </apex:page>
I am a beginner here. I have started to self teach myself Apex and have received great help from this community so I figured I would try again. Here is the request: I have a custom "Claim" object. When an order is selected, a flow takes the user through adding order line items that are related to the selected order. Now I am starting a project for a new type of "Claim" and they want to take this a step further. From the claim record, users should get a flow to take them through the following: Be able to select MULTIPLE orders and then loop through each specific order line for each selected order and relate those to the claim as well. Please let me know if this makes absolutely zero sense. Thank you!!!!!
Hello, Our accounts are brought in from our data warehouse. In there, all account names are written in all uppercase (JOHN SMITH) I created a formula field that makes it proper case for email templates (John Smith). The problem is if someone entered the customer's first name as "JOHN & JANE" their name appears like this, "John & jane Smith" (j in Jane not being capitalized) Is there a way to fix this? Here is the code as it stands:

UPPER(MID(Order_Number__r.AccountId__r.FirstName, 1, 1))&LOWER( MID(Order_Number__r.AccountId__r.FirstName, 2,255)) &" "& UPPER(MID( Order_Number__r.AccountId__r.LastName, 1, 1))&LOWER( MID(Order_Number__r.AccountId__r.LastName, 2,255))

Thank you for any assistance! 
I have tried and tried but I keep getting a ton of errors so I am reaching out to you all for help again! I need to write a trigger that will not allow a user to create a task on a case when the case status is "closed". Thank you!!!!
What would I do without the community!? 
Please assist with the error for the trigger. Thank you! 

CLASS------->
public class RelatedTasks { 
    public static boolean taskmethod(){
        List<Task> tasks = [SELECT id, status from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id') and status = 'Open'];
        boolean isOpen = false;
        for(Task t : tasks){        
            if(t.Status =='Open'){
                isOpen = true;           
            }
        } 
        return isOpen;
    }
}


TRIGGER------------>
trigger getOpenTasks on Case (before update) {
    for(Case c : Trigger.New){        
        If(RelatedTasks.taskmethod().isOpen==true){
            c.adderror('You cannot close a case with an open task');
        }
    }
}
ERROR---------> Variable does not exist: isOpen

THANK YOU!!!
Hello! Can someone help me figure out what is wrong with my Apex class? Thank you! 
public class RelatedTasks { 
    
    Public static void taskmethod(){List<Task> tasks = [SELECT id, status from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id') and status = 'Open'];}
  
    for(Task t : tasks){        
        If(t.Status =='Open'){
            boolean isOpen = true;           
        }
        return isOpen;
    }                    
    }

and the error is the following:
Expecting '}' but was: 'for'


Thank you! 
I have received some pretty awesome help from here correcting my code so I figured I would try to see if anyone can help me write a test class. My training (newbie) on test classes so far only include validating if statements, creating accounts with field values populated etc.. Help! Thank you!!! The 2 classes are for this purpose : Code 1 is looking for the id of the current case record. Code 2 is looking for the task id's associated with that current case record. 
Code 1
public class currentCaseRecord {
        Case currentRecord;
    public currentCaseRecord (ApexPages.StandardController controller){
        currentRecord = [Select Id FROM Case Where Id =:ApexPages.CurrentPage().getparameters().get('id')];
        }
    public case getcurrentRecord(){
        return currentRecord;
    }
}

Code 2
public class RelatedTasks {                
    List<Task> tasks = [SELECT id, subject from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id')];                             
    }
Hello! I have created an apex class (below) that will get the current case Id. Now I need another class on Task that will get all tasks related to that current case record and store them in something (a list?). That way, I can use both of those apex classes in a trigger. Any idea on how to write the class on Task (get a list of all tasks related to the current case record Id)? I know i need to use Id and Whatid but I am just not sure how to format it out. Thank you!!! (getcurrentrecord code below).
public class currentCaseRecord {
        Case currentRecord;
    public currentCaseRecord (ApexPages.StandardController controller){
        currentRecord = [Select Id FROM Case Where Id =:ApexPages.CurrentPage().getparameters().get('id')];
        }
    public case getcurrentRecord(){
        return currentRecord;
    }
}
I am trying to get the current case record Id. I will be using this class in a trigger. Thank you!!!

public class currentCaseRecord {
    Case currentRecord;
    public currentCaseRecord (Apex Pages.StandardController controller){
        currentRecord = [Select Id FROM Case Where Id =:ApexPages.currentPage().
                getParameters().get('id')];
        }
    public case getcurrentRecord(){
        return currentRecord;
    }
}


Here are the errors I am receiving:
1) Unexpected token '.'.
2)Invalid character in identifier: Pages.StandardController
3)Invalid type: Apex
Hello! I have looked online for this and found 2 answers but neither truly make sense to me as to what the triggers are actually doing. I was wondering if someone could help me accomplish and understand an apex trigger. The requirement is that a case cannot be closed if it has an associated task that is still open. Thank you!!!!
I am having a lot of trouble making my visualforce page a lightning component action on my custom object. Any help is greatly appreciated! My visualforce page is called DeliveryNew
​​​​​​​User-added image
User-added image


























 
Hello! 
There is code (that I did not originally write) that I have been digging through to try to find out how to make a field required. What this code is doing: On a case, the user can select an option to "Tag Images". This will take them to a component and they can fill out specified fields. After the select "Submit", this will create a Case File record and it will be linked to the case. On the component screen, there are about 6 fields. Two of them need to be required to move forward. One is currently required and I will provide screenshots below.
They select a photo to tag:
User-added image
They then get taken to a screen to fill out information about the image(s). Primary Reason (Return_Reason__c) and Secondary Reason (Return_Reason_Secondary__c) need to be required just like Order Line (Order_Line__c) is. I was able to add the asterisks in the code but I cannot get it to error on null. Here is the screen:
User-added image
When you leave Order Line blank, here is the error:
User-added imageI need this to happen when Primary Reason and Secondary Reason are left blank as well. After looking through all of the code, I found the component screen and added the highlighted text to show the asterisks on the two fields:
User-added imageThe only other thing I could find was in the Helper, I believe this is where the error message comes from for the Null Order Line:
} else if(state === "ERROR"){
                var errors = action.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        //alert(errors[0].message);
                        var toastEvent = $A.get("e.force:showToast");
                        toastEvent.setParams({
                            title : 'Error',
                            message:'There is an error '+errors[0].message+'',
                            mode: 'sticky',
                            key: 'info_alt',
                            type: 'error'
                        });
                        toastEvent.fire();

But what I cannot find is the middle piece here. Where would it state in the code that IF Order Line is null - Display this error? Full Component in comments.
Thank you very much!!!!


 
Hello! 
There is code (that I did not originally write) that I have been digging through to try to find out how to make a field required. What this code is doing: On a case, the user can select an option to "Tag Images". This will take them to a component and they can fill out specified fields. After the select "Submit", this will create a Case File record and it will be linked to the case. On the component screen, there are about 6 fields. Two of them need to be required to move forward. One is currently required and I will provide screenshots below.
They select a photo to tag:
User-added image
They then get taken to a screen to fill out information about the image(s). Primary Reason (Return_Reason__c) and Secondary Reason (Return_Reason_Secondary__c) need to be required just like Order Line (Order_Line__c) is. I was able to add the asterisks in the code but I cannot get it to error on null. Here is the screen:
User-added image
When you leave Order Line blank, here is the error:
User-added imageI need this to happen when Primary Reason and Secondary Reason are left blank as well. After looking through all of the code, I found the component screen and added the highlighted text to show the asterisks on the two fields:
User-added imageThe only other thing I could find was in the Helper, I believe this is where the error message comes from for the Null Order Line:
} else if(state === "ERROR"){
                var errors = action.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        //alert(errors[0].message);
                        var toastEvent = $A.get("e.force:showToast");
                        toastEvent.setParams({
                            title : 'Error',
                            message:'There is an error '+errors[0].message+'',
                            mode: 'sticky',
                            key: 'info_alt',
                            type: 'error'
                        });
                        toastEvent.fire();

But what I cannot find is the middle piece here. Where would it state in the code that IF Order Line is null - Display this error? Full Component in comments.
Thank you very much!!!!


 
Please help with the following error. Thank you! 
User-added imageUser-added image
I am a beginner here. I have started to self teach myself Apex and have received great help from this community so I figured I would try again. Here is the request: I have a custom "Claim" object. When an order is selected, a flow takes the user through adding order line items that are related to the selected order. Now I am starting a project for a new type of "Claim" and they want to take this a step further. From the claim record, users should get a flow to take them through the following: Be able to select MULTIPLE orders and then loop through each specific order line for each selected order and relate those to the claim as well. Please let me know if this makes absolutely zero sense. Thank you!!!!!
Hello, Our accounts are brought in from our data warehouse. In there, all account names are written in all uppercase (JOHN SMITH) I created a formula field that makes it proper case for email templates (John Smith). The problem is if someone entered the customer's first name as "JOHN & JANE" their name appears like this, "John & jane Smith" (j in Jane not being capitalized) Is there a way to fix this? Here is the code as it stands:

UPPER(MID(Order_Number__r.AccountId__r.FirstName, 1, 1))&LOWER( MID(Order_Number__r.AccountId__r.FirstName, 2,255)) &" "& UPPER(MID( Order_Number__r.AccountId__r.LastName, 1, 1))&LOWER( MID(Order_Number__r.AccountId__r.LastName, 2,255))

Thank you for any assistance! 
I have tried and tried but I keep getting a ton of errors so I am reaching out to you all for help again! I need to write a trigger that will not allow a user to create a task on a case when the case status is "closed". Thank you!!!!
What would I do without the community!? 
Please assist with the error for the trigger. Thank you! 

CLASS------->
public class RelatedTasks { 
    public static boolean taskmethod(){
        List<Task> tasks = [SELECT id, status from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id') and status = 'Open'];
        boolean isOpen = false;
        for(Task t : tasks){        
            if(t.Status =='Open'){
                isOpen = true;           
            }
        } 
        return isOpen;
    }
}


TRIGGER------------>
trigger getOpenTasks on Case (before update) {
    for(Case c : Trigger.New){        
        If(RelatedTasks.taskmethod().isOpen==true){
            c.adderror('You cannot close a case with an open task');
        }
    }
}
ERROR---------> Variable does not exist: isOpen

THANK YOU!!!
Hello! Can someone help me figure out what is wrong with my Apex class? Thank you! 
public class RelatedTasks { 
    
    Public static void taskmethod(){List<Task> tasks = [SELECT id, status from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id') and status = 'Open'];}
  
    for(Task t : tasks){        
        If(t.Status =='Open'){
            boolean isOpen = true;           
        }
        return isOpen;
    }                    
    }

and the error is the following:
Expecting '}' but was: 'for'


Thank you! 
I have received some pretty awesome help from here correcting my code so I figured I would try to see if anyone can help me write a test class. My training (newbie) on test classes so far only include validating if statements, creating accounts with field values populated etc.. Help! Thank you!!! The 2 classes are for this purpose : Code 1 is looking for the id of the current case record. Code 2 is looking for the task id's associated with that current case record. 
Code 1
public class currentCaseRecord {
        Case currentRecord;
    public currentCaseRecord (ApexPages.StandardController controller){
        currentRecord = [Select Id FROM Case Where Id =:ApexPages.CurrentPage().getparameters().get('id')];
        }
    public case getcurrentRecord(){
        return currentRecord;
    }
}

Code 2
public class RelatedTasks {                
    List<Task> tasks = [SELECT id, subject from Task WHERE WhatId =:ApexPages.CurrentPage().getparameters().get('id')];                             
    }