-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
6Questions
-
2Replies
case with attachments will not create record or attachment
I am trying to create an external site that will allow our customers to be able to submit a case with attachments. When I select the submit button it will go to the redirect on the end of Apex and then push to the new visual force page. No record is then created in my org but at the same time, I am not getting any errors. If I remove the attachment feature or wrap the submission prior to the attachments in its own form then it will create the record. Not sure what I might be doing wrong here.
VF:
Apex:
VF:
<apex:page Standardcontroller="Case" extensions="attachController" showheader="false" > <html lang="en"> <head> <link rel="icon" type="image/png" href="{!$Resource.siteLogo}" /> <link href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" rel="stylesheet" media="screen"/> <!-- Bootstrap --> <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/bootstrap.min.css" rel="stylesheet" media="screen"/> <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/now-ui-kit.min.css?v1.2.0" media="screen"/> <title>Submit a Case</title> <style> p, li, .description{ font-weight: 400; line-height: 1.8rem; } .paddingTop{padding-top: 2rem;} } .background-black{background: #2196f3;} .background-black:hover, .background-black:focus{background: #2386d3 !important;} section .section-inner h2{color: #fff;} .round { border-radius: 100px; margin: 0; color: #9a9a9a } .longBox{height: 100px;} @media screen and (max-width: 500px){ .brand .h1-seo{ font-size: 2.2rem; } } </style> </head> <body> <div class="container"> <apex:form styleclass="form-signin"><br/><br/><br/> <br/><h2 class="form-signin-heading">Create a Ticket</h2><br/><br/> <h5 class="form-signin-heading">Email</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Email__c}" required="true"/> <br/><h5 class="form-signin-heading">Subject</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Subject}" required="true"/> <br/><h5 class="form-signin-heading">What are you experiencing?</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.What_are_you_experiencing__c}" required="true"/> <br/><h5 class="form-signin-heading">Where is the location of your issue?</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Location_of_issue__c}" required="true"/> <br/><h5 class="form-signin-heading">Source Type</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Source_Type__c}" required="true"/> <br/><h5 class="form-signin-heading">Description</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control longBox" value="{!case.Description}" required="true"/><br/> <apex:commandButton action="{!submit}" value="Submit" styleClass="btn btn-primary btn-block btn-lg background-black btn-round round"/><br/> <!-- <button class="btn btn-primary btn-block btn-lg background-black btn-round round " action="{!submit}">Submit</button><br/><br/><br/> --> <apex:pageBlock > <apex:pageBlockSection columns="1" > <div id="upload" class="upload"> <h6> If you have more than 1 file to upload please zip file to include all files. </h6> <apex:inputFile title="Choose File" value="{!filebody}" filename="{!filename}" styleClass="btn btn-primary btn-block btn-lg background-black btn-round round"/> </div> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </div> <!-- /container --> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> </body> </html> </apex:page>
Apex:
public class attachController { public case objcase{get;set;} public Attachment myAttachment{get;set;} public string fileName{get;set;} public Blob fileBody{get;set;} public attachController(Apexpages.standardcontroller controller) { objcase = (Case)controller.getRecord(); myAttachment = new Attachment(); } public PageReference submit(){ if (myAttachment.Name != null){ objcase.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Product Case').getRecordTypeId(); insert objcase; } if(myAttachment.Name != null){ objcase.RecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Product Case').getRecordTypeId(); insert objcase; System.debug('@@@@@fileBody'+fileBody); myAttachment = new Attachment(); Integer i=0; myAttachment .clear(); myAttachment.Body = fileBody; myAttachment.Name = fileName ; myAttachment.ParentId = objcase.id; insert myAttachment; } pagereference pr = Page.thankYouForSubmittingYourProductCase; pr.setRedirect(true); return pr; } }
- Josh Anderson 30
- March 02, 2019
- Like
- 0
site.com case with attachment wont insert
I am trying to create a form for public support using the case object and allow for them to add attachments as well. For some reason when I try to submit this nothing is happening. I was wondering if maybe I had my apex incorrect?
VF:
Apex:
VF:
<apex:page Standardcontroller="Case" extensions="attachController" showheader="false" > <html lang="en"> <head> <link href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" rel="stylesheet" media="screen"/> <!-- Bootstrap --> <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/bootstrap.min.css" rel="stylesheet" media="screen"/> <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/now-ui-kit.min.css?v1.2.0" media="screen"/> <title>Submit a Case</title> <style> p, li, .description{ font-weight: 400; line-height: 1.8rem; } .paddingTop{padding-top: 2rem;} } .background-black{background: #2196f3;} .background-black:hover, .background-black:focus{background: #2386d3 !important;} section .section-inner h2{color: #fff;} .round { border-radius: 100px; margin: 0; color: #9a9a9a } .longBox{height: 100px;} @media screen and (max-width: 500px){ .brand .h1-seo{ font-size: 2.2rem; } } </style> </head> <body> <div class="container"> <apex:form > <form class="form-signin"><br/><br/><br/> <br/><h2 class="form-signin-heading">Create a Ticket</h2><br/><br/> <h5 class="form-signin-heading">Email</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Email__c}" required="true"/> <br/><h5 class="form-signin-heading">Subject</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Subject}" required="true"/> <br/><h5 class="form-signin-heading">What are you experiencing?</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.What_are_you_experiencing__c}" required="true"/> <br/><h5 class="form-signin-heading">Where is the location of your issue?</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Location_of_issue__c}" required="true"/> <br/><h5 class="form-signin-heading">Source Type</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control" value="{!case.Source_Type__c}" required="true"/> <br/><h5 class="form-signin-heading">Description</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select form-control longBox" value="{!case.Description}" required="true"/><br/> <button class="btn btn-primary btn-block btn-lg background-black btn-round round " type="save">Submit</button><br/><br/><br/> <apex:pageBlock > <apex:pageBlockSection title="Upload Attachment" collapsible="false" dir="LTR" columns="1"> <div id="upload" class="upload"> <apex:inputFile id="fileToUpload" value="{!fileBody}" filename="{!fileName}" styleClass="input-file"/> </div> </apex:pageBlockSection> </apex:pageBlock> </form> </apex:form> </div> <!-- /container --> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> </body> </html> </apex:page>
Apex:
public class attachController { public case objcase{get;set;} public Attachment myAttachment{get;set;} public string fileName{get;set;} public Blob fileBody{get;set;} public attachController(Apexpages.standardcontroller controller) { objcase = (Case)controller.getRecord(); myAttachment = new Attachment(); } public pagereference save() { if(myAttachment.Name == null) { insert objcase; } if(myAttachment.Name != null) { insert objcase; System.debug('@@@@@fileBody'+fileBody); myAttachment = new Attachment(); Integer i=0; myAttachment .clear(); myAttachment.Body = fileBody; myAttachment.Name = fileName ; myAttachment.ParentId = objcase.id; insert myAttachment; } pagereference pr = Page.thankYouForSubmittingYourProductCase; pr.setRedirect(true); return pr; } }
- Josh Anderson 30
- February 20, 2019
- Like
- 0
Unknown constructor 'attachController.attachController(ApexPages.StandardController controller)'
Trying to build a webpage for teams to be able to submit cases and attachments. For some reason I am getting a "Unknown constructor 'attachController.attachController(ApexPages.StandardController controller)'" error and even though I add the standard set controller I am still getting an error. Am I missing something on this for where I need to be adding this?
VF:
Apex:
VF:
<apex:page Standardcontroller="Case" extensions="attachController" showheader="false" > <html lang="en"> <head> <link href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" rel="stylesheet" media="screen"/> <!-- Bootstrap --> <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/bootstrap.min.css" rel="stylesheet" media="screen"/> <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/now-ui-kit.min.css?v1.2.0" media="screen"/> <title>Submit a Case</title> <style> p, li, .description{ font-weight: 400; line-height: 1.8rem; } .paddingTop{ padding-top: 2rem; } .background-black{ background: #2196f3; } .background-black:hover, .background-black:focus{ background: #2386d3 !important; } section .section-inner h2{ color: #fff; } .round { border-radius: 100px; margin: 0; color: #9a9a9a } .longBox{height: 100px;} @media screen and (max-width: 500px){ .brand .h1-seo{ font-size: 2.2rem; } } </style> </head> <body> <div class="container"> <apex:form > <form class="form-signin"><br/><br/><br/> <br/><h2 class="form-signin-heading">Create a Ticket</h2><br/><br/> <h5 class="form-signin-heading">Email</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Email__c}" required="true"/> <br/><h5 class="form-signin-heading">Subject</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Subject}" required="true"/> <br/><h5 class="form-signin-heading">What are you experiencing?</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.What_are_you_experiencing__c}" required="true"/> <br/><h5 class="form-signin-heading">Where is the location of your issue?</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Location_of_issue__c}" required="true"/> <br/><h5 class="form-signin-heading">Source Type</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Source_Type__c}" required="true"/> <br/><h5 class="form-signin-heading">Description</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control longBox" value="{!case.Description}" required="true"/><br/> <button class="btn btn-primary btn-block btn-lg background-black btn-round round " type="submit">Submit</button> <apex:pageBlock > <apex:pageBlockButtons location="top"> <apex:commandButton id="uploadAttachment" value="Upload" action="{!uploadAttachment}"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel >Attachment</apex:outputLabel> <apex:inputField value="{!cs.Name}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >Attachment</apex:outputLabel> <apex:inputFile value="{!document}" accept="doc, docx, txt, pdf, xlsx" filename="{!fileName}" contentType="{!contentType}" filesize="1000" size="50" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock>> </form> </apex:form> </div> <!-- /container --> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> </body> </html> </apex:page>
Apex:
public class attachController { public List<Attachment> fileList {get; set;} public Case cs {get; set;} public Attachment attach {get; set;} public ApexPages.StandardSetController stdCntrlr {get; set;} public attachController(ApexPages.StandardSetController controller) { stdCntrlr = controller; } public attachController() { cs = new Case(); attach = new Attachment(); fileList = new List<Attachment>(); fileList.add(attach); //AddAttachs(); } public Case getCS(){ if(cs == null) cs = new Case(); return cs; } public List<Attachment> getAttachments(){ if(fileList == null) fileList = new List<Attachment>(); return fileList; } public PageReference AddAttachs() { fileList.add(new Attachment()); return null; } public PageReference uploadAttachment() { insert cs; if(cs != null) { List<Attachment> attachments = new List<Attachment>(); for(Attachment att : fileList) { if(att.name != null && att.body != null) attachments.add(new Attachment(parentId = cs.Id, name = att.name, body = att.body)) ; } if(attachments != null){ upsert attachments; ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.INFO, attachments.size() + ' file(s) uploaded successfully')); }else { ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'Error uploading file')); } } return null; } }
- Josh Anderson 30
- January 31, 2019
- Like
- 0
NullPointerException on Ifelse statement
System.DmlException: Update failed. First exception on row 0 with id 0010m00000Hh4g5AAB; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Account: execution of BeforeUpdate
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.AccountTriggerHandler.updateCustomerJourneyStage: line 102, column 1
Class.AccountTriggerHandler.OnBeforeUpdate: line 12, column 1
Trigger.Account: line 15, column 1: []I am getting an NPE for an if-else statement in my class and I am getting a little confused..
Does anyone see what I might be missing?
Trigger:
Apex:
Test:
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.AccountTriggerHandler.updateCustomerJourneyStage: line 102, column 1
Class.AccountTriggerHandler.OnBeforeUpdate: line 12, column 1
Trigger.Account: line 15, column 1: []I am getting an NPE for an if-else statement in my class and I am getting a little confused..
Does anyone see what I might be missing?
Trigger:
trigger Account on Account (after delete, after insert, after undelete, after update, before delete, before insert, before update) { AccountTriggerHandler handler = new AccountTriggerHandler(); /* Before Insert */ if(Trigger.isInsert && Trigger.isBefore){ AccountTriggerHandler.OnBeforeInsert(Trigger.new); } /* After Insert */ else if(Trigger.isInsert && Trigger.isAfter){ AccountTriggerHandler.OnAfterInsert(Trigger.new); } /* Before Update */ else if(Trigger.isUpdate && Trigger.isBefore){ AccountTriggerHandler.OnBeforeUpdate(Trigger.old, Trigger.new, Trigger.newMap); } /* After Update */ else if(Trigger.isUpdate && Trigger.isAfter){ AccountTriggerHandler.OnAfterUpdate(Trigger.old, Trigger.new, Trigger.newMap); } /* Before Delete else if(Trigger.isDelete && Trigger.isBefore){ AccountTriggerHandler.OnBeforeDelete(Trigger.old, Trigger.oldMap); }*/ /* After Delete else if(Trigger.isDelete && Trigger.isAfter){ AccountTriggerHandler.OnAfterDelete(Trigger.old, Trigger.oldMap); }*/ /* After Undelete else if(Trigger.isUnDelete){ AccountTriggerHandler.OnUndelete(Trigger.new); }*/ }
Apex:
public with sharing class AccountTriggerHandler { public static void OnBeforeInsert(List<Account> accounts) { updateCustomerJourneyStage(accounts); } public static void OnAfterInsert(List<Account> accounts) { } public static void OnBeforeUpdate(List<Account> oldAccounts, List<Account> newAccounts, Map<Id, Account> oldMap) { updateCustomerJourneyStage(newAccounts); } public static void OnAfterUpdate(List<Account> oldAccounts, List<Account> newAccounts, Map<Id, Account> oldMap) { } //Creation of the task if customer journey is changed public static Task createTaskCJS(ID accountId, String stageName, String flightName){ return new Task(RecordTypeId = Schema.SObjectType.Task.getRecordTypeInfosByName().get('Customer Journey').getRecordTypeId(), WhatId=accountId, subject=(UserInfo.getName() + ' changed Customer Journey Stage' + stageName), Activity_Type__c = 'Stage Change', type_detail__c = flightName, status = 'Completed', ActivityDate = date.today(), Description = stageName, Priority = 'Normal', Customer_Journey_Stage_Snapshot__c = StageName); } //method used to run if we need to update the customer journey public static void updateCustomerJourneyStage(List<Account> updatedCJ) { Map<Id, Account> oldMap = new Map<Id,Account>(); for (Account a :updatedCJ){ oldMap.put(a.id, a); } List<Task> newTasks = new List<Task>(); //Loop to check if roll ups have been updated for (Account acc :updatedCJ){ if (acc.CJ_Priority_Opportunity_Roll__c == 17 && acc.Active__c && acc.Customer_Journey_Stage_Text__c != '(17) A - Sales Won') { acc.Customer_Journey_Stage_Text__c = '(17) A - Sales Won'; if(acc.Customer_Journey_Flight_Text__c != '(D) Customer Renewal' ){ acc.Customer_Journey_Flight_Text__c = '(D) Customer Renewal'; } newTasks.add(createTaskCJS(acc.id, '(17) A - Sales Won', '(D) Customer Renewal')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 16 && acc.Active__c && acc.Customer_Journey_Stage_Text__c != '(16) B - Commitment') { acc.Customer_Journey_Stage_Text__c = '(16) B - Commitment'; if(acc.Customer_Journey_Flight_Text__c != '(D) Customer Renewal' ){ acc.Customer_Journey_Flight_Text__c = '(D) Customer Renewal'; } newTasks.add(createTaskCJS(acc.id, '(16) B - Commitment', '(D) Customer Renewal')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 15 && acc.Active__c && acc.Customer_Journey_Stage_Text__c != '(15) C - Decision') { acc.Customer_Journey_Stage_Text__c = '(15) C - Decision'; if(acc.Customer_Journey_Flight_Text__c != '(D) Customer Renewal' ){ acc.Customer_Journey_Flight_Text__c = '(D) Customer Renewal'; } newTasks.add(createTaskCJS(acc.id, '(15) C - Decision', '(D) Customer Renewal')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 14 && acc.Active__c && acc.Customer_Journey_Stage_Text__c != '(14) D - Evaluation') { acc.Customer_Journey_Stage_Text__c = '(14) D - Evaluation'; if(acc.Customer_Journey_Flight_Text__c != '(D) Customer Renewal' ){ acc.Customer_Journey_Flight_Text__c = '(D) Customer Renewal'; } newTasks.add(createTaskCJS(acc.id, '(14) D - Evaluation', '(D) Customer Renewal')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 13 && acc.Active__c && acc.Customer_Journey_Stage_Text__c != '(13) E - Consideration') { acc.Customer_Journey_Stage_Text__c = '(13) E - Consideration'; if(acc.Customer_Journey_Flight_Text__c != '(D) Customer Renewal' ){ acc.Customer_Journey_Flight_Text__c = '(D) Customer Renewal'; } newTasks.add(createTaskCJS(acc.id, '(13) E - Consideration', '(D) Customer Renewal')); } else if ( acc.Active_Marketer__c && date.TODAY().daysBetween(acc.Earliest_Subscription_Start_Date__c) > 90 && acc.Customer_Journey_Stage_Text__c != '(12) Maturity') { acc.Customer_Journey_Stage_Text__c = '(12) Maturity'; if(acc.Customer_Journey_Flight_Text__c != '(C) Active Customer' ){ acc.Customer_Journey_Flight_Text__c = '(C) Active Customer'; } newTasks.add(createTaskCJS(acc.id, '(12) Maturity', '(C) Active Customer')); } else if ( acc.Active_Marketer__c && acc.Active_Subscription_Charge_Names__c.contains('Jumpstart') && date.TODAY().daysBetween(acc.Earliest_Subscription_Start_Date__c) < 91 && date.TODAY().daysBetween(acc.Earliest_Subscription_Start_Date__c) >29 && acc.Customer_Journey_Stage_Text__c != '(11) Adoption') { acc.Customer_Journey_Stage_Text__c = '(11) Adoption'; if(acc.Customer_Journey_Flight_Text__c != '(C) Active Customer' ){ acc.Customer_Journey_Flight_Text__c = '(C) Active Customer'; } newTasks.add(createTaskCJS(acc.id, '(11) Adoption', '(C) Active Customer')); } else if ( acc.Active_Marketer__c && date.TODAY().daysBetween(acc.Earliest_Subscription_Start_Date__c) > 30 && acc.Customer_Journey_Stage_Text__c != '(C) Active Customer') { acc.Customer_Journey_Stage_Text__c = '(C) Active Customer'; if(acc.Customer_Journey_Flight_Text__c != '(C) Active Customer' ){ acc.Customer_Journey_Flight_Text__c = '(C) Active Customer'; } newTasks.add(createTaskCJS(acc.id, '(C) Active Customer', '(C) Active Customer')); } else if ( acc.Active_Marketer__c && date.TODAY().daysBetween(acc.Earliest_Subscription_Start_Date__c) < 31 && acc.Customer_Journey_Stage_Text__c != '(10) Launch') { acc.Customer_Journey_Stage_Text__c = '(10) Launch'; if(acc.Customer_Journey_Flight_Text__c != '(C) Active Customer' ){ acc.Customer_Journey_Flight_Text__c = '(C) Active Customer'; } newTasks.add(createTaskCJS(acc.id, '(10) Launch', '(C) Active Customer')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 9 && acc.Customer_Journey_Stage_Text__c != '(9) A - Sales Won') { acc.Customer_Journey_Stage_Text__c = '(9) A - Sales Won'; if(acc.Customer_Journey_Flight_Text__c != '(B) Opportunity Pipeline' ){ acc.Customer_Journey_Flight_Text__c = '(B) Opportunity Pipeline'; } newTasks.add(createTaskCJS(acc.id, '(9) A - Sales Won', '(B) Opportunity Pipeline')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 8 && acc.Customer_Journey_Stage_Text__c != '(8) B - Commitment') { acc.Customer_Journey_Stage_Text__c = '(8) B - Commitment'; if(acc.Customer_Journey_Flight_Text__c != '(B) Opportunity Pipeline' ){ acc.Customer_Journey_Flight_Text__c = '(B) Opportunity Pipeline'; } newTasks.add(createTaskCJS(acc.id, '(8) B - Commitment', '(B) Opportunity Pipeline')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 7 && acc.Customer_Journey_Stage_Text__c != '(7) C - Decision') { acc.Customer_Journey_Stage_Text__c = '(7) C - Decision'; if(acc.Customer_Journey_Flight_Text__c != '(B) Opportunity Pipeline' ){ acc.Customer_Journey_Flight_Text__c = '(B) Opportunity Pipeline'; } newTasks.add(createTaskCJS(acc.id, '(7) C - Decision', '(B) Opportunity Pipeline')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 6 && acc.Customer_Journey_Stage_Text__c != '(6) D - Evaluation') { acc.Customer_Journey_Stage_Text__c = '(6) D - Evaluation'; if(acc.Customer_Journey_Flight_Text__c != '(B) Opportunity Pipeline' ){ acc.Customer_Journey_Flight_Text__c = '(B) Opportunity Pipeline'; } newTasks.add(createTaskCJS(acc.id, '(6) D - Evaluation', '(B) Opportunity Pipeline')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 5 && acc.Customer_Journey_Stage_Text__c != '(5) E - Consideration') { acc.Customer_Journey_Stage_Text__c = '(5) E - Consideration'; if(acc.Customer_Journey_Flight_Text__c != '(B) Opportunity Pipeline' ){ acc.Customer_Journey_Flight_Text__c = '(B) Opportunity Pipeline'; } newTasks.add(createTaskCJS(acc.id, '(5) E - Consideration', '(B) Opportunity Pipeline')); } else if ( acc.CJ_Priority_Opportunity_Roll__c == 4 && acc.Customer_Journey_Stage_Text__c != '(4) F - Awareness') { acc.Customer_Journey_Stage_Text__c = '(4) F - Awareness'; if(acc.Customer_Journey_Flight_Text__c != '(B) Opportunity Pipeline' ){ acc.Customer_Journey_Flight_Text__c = '(B) Opportunity Pipeline'; } newTasks.add(createTaskCJS(acc.id, '(4) F - Awareness', '(B) Opportunity Pipeline')); } else if ( acc.Active_Marketplace__c && acc.Customer_Journey_Stage_Text__c != 'Marketplace Client') { acc.Customer_Journey_Stage_Text__c = 'Marketplace Client'; if(acc.Customer_Journey_Flight_Text__c != 'Marketplace Client' ){ acc.Customer_Journey_Flight_Text__c = 'Marketplace Client'; } newTasks.add(createTaskCJS(acc.id, 'Marketplace Client', 'Marketplace Client')); } else if ( acc.Active_SDP__c && acc.Customer_Journey_Stage_Text__c != 'Media Partner') { acc.Customer_Journey_Stage_Text__c = 'Media Partner'; if(acc.Customer_Journey_Flight_Text__c != 'Media Partner' ){ acc.Customer_Journey_Flight_Text__c = 'Media Partner'; } newTasks.add(createTaskCJS(acc.id, 'Media Partner', 'Media Partner')); } else if ( acc.CJ_Priority_Contact_Roll__c == 3 && acc.Customer_Journey_Stage_Text__c != '(3) Qualified') { acc.Customer_Journey_Stage_Text__c = '(3) Qualified'; if(acc.Customer_Journey_Flight_Text__c != '(A) Prospect Development' ){ acc.Customer_Journey_Flight_Text__c = '(A) Prospect Development'; } newTasks.add(createTaskCJS(acc.id, '(3) Qualified', '(A) Prospect Development')); } else if ( acc.Churned__c && acc.Customer_Journey_Stage_Text__c != '(F) Churned') { acc.Customer_Journey_Stage_Text__c = '(F) Churned'; if(acc.Customer_Journey_Flight_Text__c != '(F) Churned' ){ acc.Customer_Journey_Flight_Text__c = '(F) Churned'; } newTasks.add(createTaskCJS(acc.id, '(F) Churned', '(F) Churned')); } else if ( acc.CJ_Priority_Contact_Roll__c == 2 && acc.Customer_Journey_Stage_Text__c != '(2) Engaged') { acc.Customer_Journey_Stage_Text__c = '(2) Engaged'; if(acc.Customer_Journey_Flight_Text__c != '(A) Prospect Development' ){ acc.Customer_Journey_Flight_Text__c = '(A) Prospect Development'; } newTasks.add(createTaskCJS(acc.id, '(2) Engaged', '(A) Prospect Development')); } else if ( acc.CJ_Priority_Contact_Roll__c == 1 && acc.Customer_Journey_Stage_Text__c != '(1) Known') { acc.Customer_Journey_Stage_Text__c = '(1) Known'; if(acc.Customer_Journey_Flight_Text__c != '(A) Prospect Development' ){ acc.Customer_Journey_Flight_Text__c = '(A) Prospect Development'; } newTasks.add(createTaskCJS(acc.id, '(1) Known', '(A) Prospect Development' )); } else if ( acc.Customer_Journey_Stage_Text__c != 'Not ICP') { acc.Customer_Journey_Stage_Text__c = 'Not ICP'; if(acc.Customer_Journey_Flight_Text__c != 'Not ICP' ){ acc.Customer_Journey_Flight_Text__c = 'Not ICP'; } newTasks.add(createTaskCJS(acc.id, 'Not ICP', 'Not ICP')); } else { acc.Customer_Journey_Flight_Text__c = null; acc.Customer_Journey_Stage_Text__c = null; } } if(newTasks.size() > 0) { insert newTasks; } } }
Test:
@isTest public class AccountTriggerHandlerTest { public static testmethod void testCustomerJourney() { //Insert Account & Check Journey Account acc = new Account(Name = 'Test1', Type = 'Direct Marketer', Website = 'www.test.com'); insert acc; Account acc1 = new Account(Name = 'Test1', Type = 'Direct Marketer', Website = 'www.test.com'); insert acc1; test.startTest(); //Test for (1) Known acc.CJ_Priority_Contact_Roll__c = 1; update acc; //Test for (2) Engaged acc.CJ_Priority_Contact_Roll__c = 2; update acc; //Test for (3) Qualified acc.CJ_Priority_Contact_Roll__c = 3; update acc; //Test for (4) F - Awareness acc.CJ_Priority_Opportunity_Roll__c = 4; update acc; //Test for (5) E - Consideration acc.CJ_Priority_Opportunity_Roll__c = 5; update acc; //Test for (6) D - Evaluation acc.CJ_Priority_Opportunity_Roll__c = 6; update acc; //Test for (7) C - Decision acc.CJ_Priority_Opportunity_Roll__c = 7; update acc; //Test for (8) B - Commitment acc.CJ_Priority_Opportunity_Roll__c = 8; update acc; //Test for (9)A - Sales Won acc.CJ_Priority_Opportunity_Roll__c = 9; update acc; //Test for (10) Launch acc.Active_Product_Names__c = 'Software - Marketer'; acc.Earliest_Subscription_Start_Date__c = date.today().addDays(25); acc.Max_Mktplace_Won_Contract_End_Date__c = date.today().addDays(365); update acc; //Test for (C)Active Customer *** acc.Earliest_Subscription_Start_Date__c = date.today().addDays(45); acc.Active_Subscription_Charge_Names__c = 'Jumpstart'; update acc; //Test for (11)Adoption //Test for (12)Maturity //Test for (13)E - Consideration acc.CJ_Priority_Opportunity_Roll__c = 13; update acc; //Test for (14)D - Evaluation acc.CJ_Priority_Opportunity_Roll__c = 14; update acc; //Test for (15)C - Decision acc.CJ_Priority_Opportunity_Roll__c = 15; update acc; //Test for (16)B - Commitment acc.CJ_Priority_Opportunity_Roll__c = 16; update acc; //Test for (17)A - Sales Won acc.CJ_Priority_Opportunity_Roll__c = 17; update acc; //Test for Marketplace Client update acc; //Media Partner acc.active_product_Names__c = 'Software - Strategic Demand Partner'; update acc; system.debug('Product Name: ' + acc.Active_Product_Names__c); system.debug('Active SDP: ' + acc.Active_SDP__c); //Test for (F) Churned update acc; test.stopTest(); } }
- Josh Anderson 30
- November 08, 2018
- Like
- 0
Community cannot see visualforce pages
I am trying to create a partner community and then allow them to use the managed package that we have to work for Client Success. Currently, the community is working fine and you can select custom/standard objects, but when you select any of the visual force components from the managed package it will not work. Currently, when you select these in our org it works fine but the only issue is when we are in the community neither system admins nor the partner users can access this.
Does anyone know what might be the issue?
Does anyone know what might be the issue?
- Josh Anderson 30
- October 26, 2018
- Like
- 0
Unknown property 'String.Id'
I am trying to update a VF page and add a new field but am getting an error "Unknown property 'String.Id'". The field that I am trying to add is Description_c, a depending picklist to Task_Type__c. All I was trying to do was add a new column and I added this to the query of the controller. Is anyone seeing anything that would cause this error?
VisualForce
Controller:
VisualForce
<apex:page controller="TimeTrackerTimesheetViewController" sidebar="false"> <script> </script> <apex:form id="formie"> <apex:pageblock id="blockie" title="Timesheet"> <apex:outputPanel id="main_panel"> <div style="margin:20px 0px"> <apex:actionRegion > <apex:selectList value="{!dateSelected}" multiselect="false" size="1" > <apex:actionSupport event="onchange" action="{!changeDate}" rerender="main_panel"/> <apex:selectOptions value="{!availableDates}"/> </apex:selectList> <span style="font-size:14px; margin:0px 10px" >Total: {!totalHours} Hours</span> </apex:actionRegion> </div> <apex:variable value="{!0}" var="xNum"/> <apex:pageBlockSection columns="1" title="Time Entries" id="x_blocks" collapsible="False"> <apex:actionRegion > <apex:pageBlockTable value="{!existingTTList}" var="xt"> <apex:column headerValue="Action" style="width:30px"> <apex:variable var="xNum" value="{!xNum + 1}"/> <apex:commandLink value="Delete" style="color:red" action="{!removeXFromList}" rerender="main_panel" immediate="true"> <apex:param value="{!xt.Id}" name="ttToDelete" assignTo="{!ttToDelete}"/> </apex:commandLink> <apex:commandLink value="Edit" style="color:blue;margin-left:10px;" action="{!editXFromList}" rerender="main_panel" immediate="true"> <apex:param value="{!xt.Id}" name="ttToEdit" assignTo="{!ttToEdit}"/> </apex:commandLink> </apex:column> <apex:column headerValue="Date" style="width:50px"> <apex:outputfield value="{!xt.Date__c}" /> </apex:column> <apex:column headerValue="Account Name" style="width:100px"> <apex:outputfield value="{!xt.Account__c}" /> </apex:column> <apex:column headerValue="Opportunity Name" style="width:100px"> <apex:outputfield value="{!xt.Opportunity__c}" /> </apex:column> <apex:column headerValue="Task Type" style="width:100px"> <apex:outputfield value="{!xt.Task_Type__c}" /> </apex:column> <apex:column headerValue="Description" style="width:100px"> <apex:inputfield value="{!xt.Description__c}" required="true"/> </apex:column> <apex:column headerValue="Product Type" style="width:100px"> <apex:outputfield value="{!xt.Product_Type__c}" /> </apex:column> <apex:column headerValue="Notes" style="width:300px"> <apex:outputfield value="{!xt.Notes__c}" style="width:100%"/> </apex:column> <apex:column headerValue="Hours" style="width:100px"> <apex:outputfield value="{!xt.Time_Hours__c}" /> </apex:column> <apex:inlineEditSupport showOnEdit="" event="ondblclick" changedStyleClass="myBoldClass"/> </apex:pageBlockTable> </apex:actionRegion> </apex:pageBlockSection> <apex:variable value="{!0}" var="rowNum"/> <apex:pageBlockSection columns="1" title="Add Entries" id="p_blocks" collapsible="False"> <apex:pageBlockTable value="{!newTTList}" var="tt"> <apex:column headerValue="Action" style="width:50px"> <apex:commandLink value="Remove" style="color:red" action="{!removeRowFromList}" rendered="{!rowNum > 0}" rerender="main_panel" immediate="true" > <apex:param value="{!rowNum}" name="rowToRemove" assignTo="{!rowToRemove}"/> </apex:commandLink> <apex:variable var="rowNum" value="{!rowNum + 1}"/> </apex:column> <apex:column headerValue="Date" style="width:50px"> <apex:inputfield value="{!tt.Date__c}" required="true"/> </apex:column> <apex:column headerValue="Account Name" style="width:100px"> <apex:inputField value="{!tt.Account__c}" required="true"/> </apex:column> <apex:column headerValue="Opportunity Name" style="width:100px"> <apex:inputField value="{!tt.Opportunity__c}" required="false"/> </apex:column> <apex:column headerValue="Task Type" style="width:100px"> <apex:inputfield value="{!tt.Task_Type__c}" required="true"/> </apex:column> <apex:column headerValue="Description" style="width:100px"> <apex:inputfield value="{!tt.Description__c}" required="true"/> </apex:column> <apex:column headerValue="Product Type" style="width:100px"> <apex:inputField value="{!tt.Product_Type__c}" required="true"/> </apex:column> <apex:column headerValue="Notes" style="width:300px"> <apex:inputfield value="{!tt.Notes__c}" style="width: 95%"/> </apex:column> <apex:column headerValue="Hours" style="width:100px"> <apex:inputfield value="{!tt.Time_Hours__c}" required="true"/> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> <apex:commandButton value="Add More" action="{!addNewRowToList}" rerender="main_panel" Status="status" immediate="true" /> </apex:outputPanel> <apex:pageblockButtons location="bottom"> <apex:commandButton id="savenew" value="Save" action="{!SaveTimeTrackers}"/> </apex:pageblockButtons> </apex:pageblock> </apex:form> </apex:page>
Controller:
public class TimeTrackerTimesheetViewController { public String xt { get; set; } public List<Time_Tracker__c> newTTList {get;set;} public Integer rowToRemove {get;set;} public Id ttToDelete {get;set;} public Id ttToEdit {get;set;} public Date dateSelected {get;set;} public Decimal totalHours {get;set;} public List<Time_Tracker__c> existingTTList {get;set;} public List<SelectOption> availableDates {get;set;} public ID currentUser; public TimeTrackerTimesheetViewController(){ currentUser = UserInfo.getUserId(); dateSelected = date.today(); totalHours = 0.0; rowToRemove = 0; availableDates = new List<SelectOption>(); Date loopDate = date.today(); availableDates.add(new SelectOption(loopDate.format(), 'TODAY ' + loopDate.format())); for(Integer i = 0; i < 7; i++) { loopDate = loopDate.addDays(-1); Datetime dt = loopDate.addDays(1); //if(dt.format('EEEE') != 'Sunday' && dt.format('EEEE') != 'Saturday'){ availableDates.add(new SelectOption(loopDate.format(), dt.format('EEEE') + ' ' + loopDate.format())); //} } newTTList = new List<Time_Tracker__c>(); addNewRowToList(); queryExisting(); } public void addNewRowToList(){ Time_Tracker__c newTT = new Time_Tracker__c(Date__c = dateSelected, User__c = currentUser); newTTList.add(newTT); } public void removeRowFromList(){ newTTList.remove(rowToRemove); } public void changeDate() { queryExisting(); for(Time_Tracker__c t : newTTList) { t.Date__c = dateSelected; } } public void removeXFromList(){ Database.delete(ttToDelete); queryExisting(); } public void editXFromList(){ Time_Tracker__c eTT = [SELECT User__c, Date__c, Account__c, Opportunity__c, Task_Type__c, Description__c, Product_Type__c, Time_Hours__c, Notes__c FROM Time_Tracker__c WHERE Id = :ttToEdit][0]; //newTTList.clear(); Time_Tracker__c newTT = new Time_Tracker__c(User__c = eTT.User__c, Date__c = eTT.Date__c, Account__c = eTT.Account__c, Opportunity__c = eTT.Opportunity__c, Task_Type__c = eTT.Task_Type__c, Description__c = eTT.Description__c, Product_Type__c = eTT.Product_Type__c, Time_Hours__c = eTT.Time_Hours__c, Notes__c = eTT.Notes__c); newTTList.add(0, newTT); Database.delete(ttToEdit); queryExisting(); } public void queryExisting() { existingTTList = [SELECT Id, Date__c, Account__c, Opportunity__c, Task_Type__c, Description__c, Product_Type__c, Time_Hours__c, Notes__c FROM Time_Tracker__c WHERE Date__c = :dateSelected AND User__c = :currentUser]; totalHours = 0.0; for(Time_Tracker__c e : existingTTList) { totalHours += e.Time_Hours__c; } } public PageReference SaveTimeTrackers(){ insert newTTList; newTTList.clear(); addNewRowToList(); queryExisting(); return null; } }
- Josh Anderson 30
- October 10, 2018
- Like
- 0
Unknown constructor 'attachController.attachController(ApexPages.StandardController controller)'
Trying to build a webpage for teams to be able to submit cases and attachments. For some reason I am getting a "Unknown constructor 'attachController.attachController(ApexPages.StandardController controller)'" error and even though I add the standard set controller I am still getting an error. Am I missing something on this for where I need to be adding this?
VF:
Apex:
VF:
<apex:page Standardcontroller="Case" extensions="attachController" showheader="false" > <html lang="en"> <head> <link href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" rel="stylesheet" media="screen"/> <!-- Bootstrap --> <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/bootstrap.min.css" rel="stylesheet" media="screen"/> <link href="https://cdn.rawgit.com/creativetimofficial/now-ui-kit/2e8e665f/assets/css/now-ui-kit.min.css?v1.2.0" media="screen"/> <title>Submit a Case</title> <style> p, li, .description{ font-weight: 400; line-height: 1.8rem; } .paddingTop{ padding-top: 2rem; } .background-black{ background: #2196f3; } .background-black:hover, .background-black:focus{ background: #2386d3 !important; } section .section-inner h2{ color: #fff; } .round { border-radius: 100px; margin: 0; color: #9a9a9a } .longBox{height: 100px;} @media screen and (max-width: 500px){ .brand .h1-seo{ font-size: 2.2rem; } } </style> </head> <body> <div class="container"> <apex:form > <form class="form-signin"><br/><br/><br/> <br/><h2 class="form-signin-heading">Create a Ticket</h2><br/><br/> <h5 class="form-signin-heading">Email</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Email__c}" required="true"/> <br/><h5 class="form-signin-heading">Subject</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Subject}" required="true"/> <br/><h5 class="form-signin-heading">What are you experiencing?</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.What_are_you_experiencing__c}" required="true"/> <br/><h5 class="form-signin-heading">Where is the location of your issue?</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Location_of_issue__c}" required="true"/> <br/><h5 class="form-signin-heading">Source Type</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control" value="{!case.Source_Type__c}" required="true"/> <br/><h5 class="form-signin-heading">Description</h5><br/> <apex:inputfield styleClass="inputGroupSelect01 custom-select round form-control longBox" value="{!case.Description}" required="true"/><br/> <button class="btn btn-primary btn-block btn-lg background-black btn-round round " type="submit">Submit</button> <apex:pageBlock > <apex:pageBlockButtons location="top"> <apex:commandButton id="uploadAttachment" value="Upload" action="{!uploadAttachment}"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel >Attachment</apex:outputLabel> <apex:inputField value="{!cs.Name}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >Attachment</apex:outputLabel> <apex:inputFile value="{!document}" accept="doc, docx, txt, pdf, xlsx" filename="{!fileName}" contentType="{!contentType}" filesize="1000" size="50" /> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock>> </form> </apex:form> </div> <!-- /container --> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> </body> </html> </apex:page>
Apex:
public class attachController { public List<Attachment> fileList {get; set;} public Case cs {get; set;} public Attachment attach {get; set;} public ApexPages.StandardSetController stdCntrlr {get; set;} public attachController(ApexPages.StandardSetController controller) { stdCntrlr = controller; } public attachController() { cs = new Case(); attach = new Attachment(); fileList = new List<Attachment>(); fileList.add(attach); //AddAttachs(); } public Case getCS(){ if(cs == null) cs = new Case(); return cs; } public List<Attachment> getAttachments(){ if(fileList == null) fileList = new List<Attachment>(); return fileList; } public PageReference AddAttachs() { fileList.add(new Attachment()); return null; } public PageReference uploadAttachment() { insert cs; if(cs != null) { List<Attachment> attachments = new List<Attachment>(); for(Attachment att : fileList) { if(att.name != null && att.body != null) attachments.add(new Attachment(parentId = cs.Id, name = att.name, body = att.body)) ; } if(attachments != null){ upsert attachments; ApexPages.addmessage(new ApexPages.message(ApexPages.Severity.INFO, attachments.size() + ' file(s) uploaded successfully')); }else { ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'Error uploading file')); } } return null; } }
- Josh Anderson 30
- January 31, 2019
- Like
- 0
Community cannot see visualforce pages
I am trying to create a partner community and then allow them to use the managed package that we have to work for Client Success. Currently, the community is working fine and you can select custom/standard objects, but when you select any of the visual force components from the managed package it will not work. Currently, when you select these in our org it works fine but the only issue is when we are in the community neither system admins nor the partner users can access this.
Does anyone know what might be the issue?
Does anyone know what might be the issue?
- Josh Anderson 30
- October 26, 2018
- Like
- 0