-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
19Questions
-
20Replies
Testing Metadata and Web Services
Hi, I am trying to test one of my Apex Methods but get a Cannot test web service callouts and am counfused out how to implement the test script to handle this.
Here is my Apex Method im trying to test.
Any constructive guidance would be great, Kinda confused on how to use Salesforce Test webservice callout https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_testing.htm
Here is my Apex Method im trying to test.
public PageReference initialiveFields() { List<Fields__c> newListFields = new List<Fields__c>(); Master_Workbook__c selectObj = [SELECT Id, Object_API_Name__c FROM Master_Workbook__c WHERE Id =: selectedObject]; Master_Workbook_Settings__mdt doNotCreateFields = queryMasterWorkbookSettings(DONOTCREATEFIELDCATEGORY); Master_Workbook_Settings__mdt objectBasedFields = queryMasterWorkbookSettings(selectObj.Object_API_Name__c); List<Fields__c> objExistingFields = [SELECT Field_API_Name__c FROM Fields__c WHERE Object_Name__c =: selectObj.Id]; Map<String, Schema.SObjectField> fields = schemaMap.get(selectObj.Object_API_Name__c).getDescribe().fields.getMap(); for (SObjectField sobField : fields.values()) { DescribeFieldResult sobFieldDescribe = sobField.getDescribe(); String metadataHere = selectObj.Object_API_Name__c + PERIOD + sobFieldDescribe.getName(); if (testCreation(sobFieldDescribe, doNotCreateFields, objectBasedFields, objExistingFields)) { MetadataServices.CustomField customField = (MetadataServices.CustomField) service.readMetadata(CUSTOMFIELDTEXT, new String[] { metadataHere }).getRecords()[0]; newListFields.add(generateFieldRecord(sobFieldDescribe, selectObj.Id, customField.description, customField.fullName, objectBasedFields)); } } insert newListFields; selectObj.IsInitialized__c = true; update selectObj; return start(); }
Any constructive guidance would be great, Kinda confused on how to use Salesforce Test webservice callout https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_testing.htm
- Christopher Pezza
- January 12, 2016
- Like
- 0
Create a multi Tiered Lists
So i am trying to build a 3 level list. to look something like this. This will also be an aggregation function to Count the total number of records. Any advice on how to build this?
Product Line1
Stage1
Open - 20
Hold - 10
Stage2
Open - 10
Hold - 12
Product Line2
Stage1
Open - 3
Hold - 2
Stage2
Open - 1
Hold - 9
Thanks!
Product Line1
Stage1
Open - 20
Hold - 10
Stage2
Open - 10
Hold - 12
Product Line2
Stage1
Open - 3
Hold - 2
Stage2
Open - 1
Hold - 9
Thanks!
- Christopher Pezza
- August 28, 2015
- Like
- 0
Dependant Picklist Does Not Render Class Attribute
I am trying to add a Class to a Input Field in Visual Force but when the page is rendered it removes the styleClass Attribute. This inputField is a dependant Picklist.
Below is my VF Code
<apex:inputField value="{!configTaskToUpdate.Config_Category__c}" styleClass="form-control" id="thecategory"/>
i have tried adding the the code to a div tag around it but it comes out akward
I have also tried adding it to the the field by jQuery as below but that doesnt work either
Anyone have this issue and or found a workaround or is SF working on it?
Below is my VF Code
<apex:inputField value="{!configTaskToUpdate.Config_Category__c}" styleClass="form-control" id="thecategory"/>
i have tried adding the the code to a div tag around it but it comes out akward
I have also tried adding it to the the field by jQuery as below but that doesnt work either
$(document).ready(function() { $(function() { $("#{!$Component.theform.thecategory}").addClass("form-control"); console.log('added the form-control class'); }); });
Anyone have this issue and or found a workaround or is SF working on it?
- Christopher Pezza
- January 28, 2015
- Like
- 0
SelectList passing null everytime onchange
My selectList is continuously passing null as the value to my controller and i dont know why. What am i missing! Thanks! Code Below
VisualForce Page
Apex Class
VisualForce Page
<div class="form-group"> <label><apex:outputText value="{!$Label.Fee_Select_Default_Fee}"></apex:outputText></label> <apex:selectList styleClass="form-control" value="{!RemoveFeeSelected}" size="1"> <apex:selectOptions value="{!RemoveFeeList}"/> <apex:actionSupport event="onchange" action="{!NULL}" reRender="TheRemoveListPanel,messages" status="removeselectstatus"/> </apex:selectList> <apex:actionStatus id="removeselectstatus"> <apex:facet name="start"> <img src="/img/loading.gif"/> </apex:facet> </apex:actionStatus> </div><!-- /.form-group --> <div class="form-group"> <label><apex:outputText value="{!$Label.Fee_Select_Join}"></apex:outputText></label> <apex:outputPanel id="TheRemoveListPanel"> <apex:selectList styleClass="form-control" value="{!TodeletePFT}" multiselect="true" size="6"> <apex:selectOptions value="{!RemoveJoinList}" id="theremovelist"/> </apex:selectList> </apex:outputPanel> </div><!-- /.form-group -->
Apex Class
Public Id RemoveFeeSelected {get;set;} Public String[] TodeletePFT {get;set;} public FeeManagementController() {} //Used for Picklist for Removal Fee Modal public List<SelectOption> getRemoveFeeList() { List<SelectOption> FeeList = new List<SelectOption>(); List<Template_Records__c> TempateFees = [SELECT Id, Text_Field_1__c FROM Template_Records__c]; FeeList.add(new SelectOption('null','-- None Selected --')); for (Template_Records__c t: TempateFees) { FeeList.add(new SelectOption(t.Id,t.Text_Field_1__c)); } return FeeList; } //Used for Picklist for Removal Fee Modal Public List<SelectOption> getRemoveJoinList() { System.debug('**' + RemoveFeeSelected); List<SelectOption> RemoveList = new List<SelectOption>(); List<PFT_Join__c> JoinList = [SELECT Id, Name, Template_Records__r.Text_Field_1__c, Product_Feature__r.Name FROM PFT_Join__c WHERE Template_Records__c = :RemoveFeeSelected]; for (PFT_Join__c pft: JoinList) { RemoveList.add(new SelectOption(pft.Id, pft.Name + ' - ([' + pft.Template_Records__r.Text_Field_1__c + '] - [' + pft.Product_Feature__r.Name + '])')); } return RemoveList; }
- Christopher Pezza
- December 16, 2014
- Like
- 0
How to generate a Confirmation Token
I am trying to use a url from the Subscriber tab that the Liscense Management Application uses i want to utilize that url, but it requires a confirmation token so every day it changes. How do I generate that URL in visualforce so that this can work normally.
- Christopher Pezza
- December 04, 2014
- Like
- 0
Grouping in Repeats
I am looking to repeat a list with groups so that the result looks like this
Category Name
Feature Name Feature Status
Category Name
Feature Name Feature Status
How would i write my code for this i have this as my example but it produces no results when i know there are 100+
Class
Page
Category Name
Feature Name Feature Status
Category Name
Feature Name Feature Status
How would i write my code for this i have this as my example but it produces no results when i know there are 100+
Class
public Id CHid {get;set;} public class FCHArea { public List<FCH_Joins__c> lichjoins {get; set;} public string strAreaName {get; set;} public FCHArea(FCH_Joins__c sJoins) { strAreaName = sJoins.nCino_Feature__r.nCino_Feature_Category__r.Name; lichjoins = new List<FCH_Joins__c>{sJoins}; } } public List<FCHArea> liAreas {get; set;} private Map<string, FCHArea> mapAreas = new Map<string, FCHArea>(); Public nCino_CHIndividualController() { Chid = Apexpages.currentPage().getParameters().get('ID'); for(FCH_Joins__c sJoins : [SELECT Id, Name, Status__c, nCino_Feature__r.Name FROM FCH_Joins__c WHERE Customer_Health__c = :CHid]) { if(mapAreas.get(sJoins.nCino_Feature__r.nCino_Feature_Category__r.Name) == null) { mapAreas.put(sJoins.nCino_Feature__r.nCino_Feature_Category__r.Name, new FCHArea(sJoins)); liAreas.add(mapAreas.get(sJoins.nCino_Feature__r.nCino_Feature_Category__r.Name)); } else { mapAreas.get(sJoins.nCino_Feature__r.nCino_Feature_Category__r.Name).lichjoins.add(sJoins); } } }
Page
<apex:repeat value="{!liAreas}" var="a"> <div class="col-lg-6"> <table class="table table-hover"> <thead> <tr> <th colspan="2" class="text-center">The Name</th> </tr> </thead> <tbody> <apex:repeat value="{!a.lichjoins}" var="c"> <tr> <th>{!c.nCino_Feature__r.Name}</th> <apex:outputPanel rendered="{!c.Status__c == 'Yes - Successfully'}"> <td class="bg-green">{!c.Status__c}</td> </apex:outputPanel> <apex:outputPanel rendered="{!c.Status__c == 'Yes - Needs Improvement' || c.Status__c == 'Yes - Piloting' || c.Status__c == 'No - Implementing'}"> <td class="bg-yellow">{!c.Status__c}</td> </apex:outputPanel> <apex:outputPanel rendered="{!c.Status__c == 'No - Needs Revisiting'}"> <td class="bg-red">{!c.Status__c}</td> </apex:outputPanel> <apex:outputPanel rendered="{!c.Status__c == 'No - Not Applicable'}"> <td>{!c.Status__c}</td> </apex:outputPanel> </tr> </apex:repeat> </tbody> </table> </div> </apex:repeat>
- Christopher Pezza
- November 26, 2014
- Like
- 0
Edit List of Related Children of Parent
I have a parent that has a children records and i want to create a list of just the children related to the parent to edit all at one time.
I have in the url the id for the parent that i pass through my extension when i click save it doesn't save what am i missing.
Extension
VisualForce Page
The Component
I have in the url the id for the parent that i pass through my extension when i click save it doesn't save what am i missing.
Extension
Public with sharing class nCino_CHEditFeatureJoinsController { Public Id CHid {get;set;} Public List<FCH_Joins__c> TheJoinsList {get;set;} public nCino_CHEditFeatureJoinsController(ApexPages.StandardController stdController) { CHid = ApexPages.currentPage().getParameters().get('ch'); TheJoinsList = [SELECT Name, Id, nCino_Feature__r.Name, Status__c FROM FCH_Joins__c WHERE Customer_Health__c = :CHid]; } }
VisualForce Page
<apex:page standardController="FCH_Joins__c" extensions="nCino_CHEditFeatureJoinsController" sidebar="false" > <c:Edit_List_of_Features Joins="{!TheJoinsList}"/> </apex:page>
The Component
<apex:component> <apex:attribute name="Joins" type="FCH_Joins__c[]" description="List of Joins to be edited" required="true"/> <apex:form > <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Joins}" var="a"> <apex:column value="{!a.nCino_Feature__r.Name}" /> <apex:column headerValue="Status"> <apex:inputField value="{!a.Status__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:component>
- Christopher Pezza
- November 18, 2014
- Like
- 0
Passing Variable of null when its not
It wont pass the Id to the Variable any reason why or that i am missing
public void AttachLoan() { System.debug('** in Add'); System.debug('**' + AddLoanID); LLC_BI__Loan__c ul = [SELECT Id, Name, LLC_CDS__Deal_Facility__c FROM LLC_BI__Loan__c WHERE Id = :AddLoanID LIMIT 1]; system.debug('** ' + ul); ul.LLC_CDS__Deal_Facility__c = ObjId; system.debug('**2 ' + ul); update(ul); }
<apex:repeat value="{!AddLoans}" var="fa"> <tr> <td> <apex:form > <apex:commandButton value="Add" action="{!AttachLoan}" styleClass="btn btn-xs btn-success"> <apex:param value="{!fa.Id}" AssignTo="{!AddLoanID}"/> </apex:commandButton> </apex:form> </td> <td><a href="/{!fa.Id}" target="_Blank">{!fa.Name}</a></td> <td>{!fa.LLC_BI__lookupKey__c}</td> <td><a href="/{!fa.LLC_BI__Account__c}" target="_Blank">{!fa.LLC_BI__Account__r.Name}</a></td> </tr> </apex:repeat>
- Christopher Pezza
- October 25, 2014
- Like
- 0
How to rerender a outputPanel once data is submitted
So I want to perform a search and then return the results on that same screen with rerender on an outputpanel but it never returns results heres my code what am i missing.
Public List<LLC_BI__Loan__c> AddLoans {get;set;} public String LoanSearch {get;set;} Public Boolean SearchStatus {get;set;} public void SeachLoans() { String BuildSearch; system.debug('**' + LoanSearch); BuildSearch = '\'%' + LoanSearch + '%\''; system.debug('**' + BuildSearch ); AddLoans = [SELECT Id, Name, LLC_BI__Account__c, LLC_BI__Account__r.Name, LLC_BI__lookupKey__c FROM LLC_BI__Loan__c WHERE Name LIKE :BuildSearch]; system.debug('**' + AddLoans ); this.SearchStatus = true; system.debug('**' + SearchStatus ); }
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="LoanModal"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title" id="myModalLabel">Attach A Loan to this Deal Facility</h4> </div><!-- /.modal-header --> <div class="modal-body"> <div class="row"> <div class="col-md-offset-2 col-md-8"> <apex:form> <div class="input-group"> <span class="input-group-addon"> Loan Name: </span> <apex:inputText value="{!LoanSearch}" styleClass="form-control"/> <span class="input-group-btn"> <apex:commandButton value="Search" action="{!SeachLoans}" styleClass="btn btn-success" reRender="LoansList"> <apex:param value="{!LoanSearch}"/> </apex:commandButton> </span> </div><!-- /input-group --> </apex:form> <br/> <br/> </div><!-- /.col --> </div><!-- /.row --> <div class="row"> <div class="col-md-12"> <table class="table table-responsive table-hover" id="AddLoanTable"> <thead> <tr> <th></th> <th>Loan Name</th> <th>Loan Number</th> <th>Relationship Name</th> </tr> </thead> <tbody> <apex:form> <apex:outputPanel id="LoansList" rendered="{!SearchStatus}"> <apex:repeat value="{!AddLoans}" var="fa"> <tr> <td> <apex:commandButton value="Add" StyleClass="btn btn-xs btn-success"> <apex:param value="{!fa.Id}"/> </apex:commandButton> </td> <td><a href="/{!fa.Id}" target="_Blank">{!fa.Name}</a></td> <td>{!fa.LLC_BI__lookupKey__c}</td> <td><a href="/{!fa.LLC_BI__Account__c}" target="_Blank">{!fa.LLC_BI__Account__r.Name}</a></td> </tr> </apex:repeat> </apex:outputPanel> </apex:form> </tbody> </table> </div><!-- /.col --> </div><!-- /.row --> </div><!-- /.modal-body --> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal -->
- Christopher Pezza
- October 25, 2014
- Like
- 0
Can't Perform save Function in Apex
So i'm trying to save a record on a visual force page but it won't perform the save function. It gets into the method but never actually grabs the information from the page. NAy Ideas? Here is my Code
Class
Page
Class
public with sharing class nCino_CustomerHealthIndividual{ public string CHidNum = Apexpages.currentPage().getParameters().get('id'); public Customer_Health__c CustomerHealth {get;set;} public nCino_CustomerHealthIndividual(){ this.CustomerHealth = getCustHealth(); } public PageReference save() { update this.CustomerHealth; return null; } //Customer Health Fields public List<Schema.FieldSetMember> getCHFields() { return SObjectType.Customer_Health__c.FieldSets.Main.getFields(); } public Customer_Health__c getCustHealth() { String query = 'SELECT '; for(Schema.FieldSetMember f : this.getCHFields()) { query += f.getFieldPath() + ', '; } query += 'Id, Name FROM Customer_Health__c WHERE Id = :CHidNum LIMIT 1'; return Database.query(query); }
Page
<apex:form> <!-- Edit System Information --> <div class="modal modal-flex fade" id="editsysteminfomodal" tabindex="-1" role="dialog" aria-labelledby="editsysteminfomodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="editsysteminfomodallabel">Edit System Information Section</h4> </div> <div class="modal-body"> <form class="form-horizontal" role="form"> <div class="form-group"> <label class=" col-md-5 control-label">nCino Sandbox Version</label> <div class="col-md-7"> <apex:inputField value="{!CustomerHealth.Sandbox_Version__c}"/> </div> </div> </form> </div> <div class="modal-footer"> <apex:commandButton value="Save" action="{!save}"></apex:commandButton> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> </apex:form>
- Christopher Pezza
- September 14, 2014
- Like
- 0
Error with Field Sets and Objects
So I'm building a configurable visualforce page that in an object you type the name of field sets and sech to then display a tabbed view but i get this error when i do so what am i missing
Error: Could not resolve field '0IX' from <apex:outputField> value binding '{!LLC_BI__Loan__c[f]}' in page ncino_checklist
Apex Class
Visualforce Page
Error: Could not resolve field '0IX' from <apex:outputField> value binding '{!LLC_BI__Loan__c[f]}' in page ncino_checklist
Apex Class
public with sharing class nCino_ChecklistExt{ public ApexPages.StandardController stdCtrl {get; set;} public Boolean refreshPage {get; set;} List<nCino_Config__c> configvalues {get;set;} public nCino_ChecklistExt(ApexPages.StandardController controller) { stdCtrl=controller; refreshPage=true; } public List<nCino_Config__c> getConfigValues() { configvalues = [SELECT Id, Name, Tab_Name__c, Tab_Display_Order__c, Tab_Color__c, Tabbed_Content_Name__c, Icon_for_Tab__c, Field_Set__c FROM nCino_Config__c WHERE App_Name__c = 'Checklist' ORDER BY Tab_Display_Order__c DESC]; return configvalues; } public PageReference save(){ LLC_BI__Loan__c loan=(LLC_BI__Loan__c) stdCtrl.getRecord(); stdCtrl.save(); return null; } public PageReference cancel(){ LLC_BI__Loan__c loan=(LLC_BI__Loan__c) stdCtrl.getRecord(); stdCtrl.save(); return null; } }
Visualforce Page
<apex:page showHeader="false" sidebar="false" standardController="LLC_BI__Loan__c" extensions="nCino_ChecklistExt" standardStylesheets="true"> <head> <apex:stylesheet value="{!URLFOR($Resource.bootstrap, '/css/bootstrap.css')}"/> <style type="text/css"> .thebox{ margin: 15px; width:auto; height:400px; background-color:#F0F0F0; border-radius:15px; } .left-side{ float:left; width:16.66666667%; background-color:#FFF; height:400px; } .right-side{ float:left; width:83.33333333%; height:400px; } .border-green{border-left-color:#88C240;border-left-width:5px;} .border-blue{border-left-color: #2D79D7;border-left-width:5px;} .border-red{border-left-color: #BA202F;border-left-width:5px;} .border-yellow{border-left-color: #F5AB3F;border-left-width:5px;} .border-gray{border-left-color: #666;border-left-width:5px;} .top-border-blue{border-top-color:#88C240;border-top-width:5px;} </style> <title>Untitled Document</title> </head> <div class="thebox"> <div class="left-side"> <div class="list-group" role="tablist" id="myTab"> <apex:repeat value="{!ConfigValues}" var="cv"> <a href="#tab{!cv.Tab_Display_Order__c}" class="list-group-item border-{!cv.Tab_Color__c}" role="tab" data-toggle="tab"><i class="gyphicon glyphicon-{!cv.Icon_for_Tab__c}"></i> {!cv.Tab_Name__c}</a> </apex:repeat> </div> </div> <apex:form> <div class="right-side tab-content" id="myTabcontent"> <div class="tab-pane active"> Main Page :) </div> <apex:repeat value="{!ConfigValues}" var="ncv"> <div class="tab-pane" id="tab{!ncv.Tab_Display_Order__c}"> <apex:pageBlock title="{!ncv.Tabbed_Content_Name__c}"> <apex:pageBlockSection> <apex:variable value="{!ncv.Field_Set__c}" var="fieldset"/> <apex:repeat value="{!$ObjectType.fieldset}" var="f"> <apex:outputField value="{!LLC_BI__Loan__c[f]}"> <apex:inlineEditSupport event="ondblclick"/> </apex:outputField> </apex:repeat> </apex:pageBlockSection> <apex:pageBlockButtons location="bottom"> <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> </apex:pageBlock> </div> </apex:repeat> </div> </apex:form> </div> <apex:includeScript value="{!URLFOR($Resource.bootstrap, '/js/jquery-2.1.1.min.js')}"/> <apex:includeScript value="{!URLFOR($Resource.bootstrap, '/js/bootstrap.min.js')}"/> <script> $('#myTab a').click(function (e) { e.preventDefault() $(this).tab('show') }) </script> </apex:page>
- Christopher Pezza
- September 01, 2014
- Like
- 0
Test Coverage on a function
public void deleteAttachment(){ Attachment attc = [SELECT Id, Name from Attachment WHERE Id = :attachId]; delete(attc); }How would I write test coverage for this function?
- Christopher Pezza
- August 17, 2014
- Like
- 0
Test Coverage Help
Heres my Class
Here is my Test Class so far
It seems to not like the asserts when they worked before. Any Ideas?
public with sharing class nCino_CustomerHealth{ //Declare Public Variables List<Customer_Health__c> myCHList; public Set<String> cmSet {get; set;} public Set<String> amset {get; set;} public Set<String> seset {get; set;} public String CSMFilter {get;set;} public String SEFilter {get;set;} public String AMFilter {get;set;} public nCino_CustomerHealth() { cmSet = new Set<String>(); for(Customer_Health__c chc : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(chc.Customer_Success_Manager__c); } amset = new Set<String>(); for(Customer_Health__c cha : [SELECT Account_Manager__c FROM Customer_Health__c WHERE Account_Manager__c <> ' ']){ amset.add(cha.Account_Manager__c); } seset = new Set<String>(); for(Customer_Health__c chs : [SELECT Support_Engineer__c FROM Customer_Health__c WHERE Support_Engineer__c <> ' ']){ seset.add(chs.Support_Engineer__c); } myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes']; } public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions = new List<SelectOption>(); csmoptions.add(new SelectOption('No Filter', 'Customer Success Manager')); csmoptions.add(new SelectOption(' ', 'No CSM')); for (String s : cmSet) { csmoptions.add(new SelectOption(s, s)); } system.debug('***' + csmoptions); return csmoptions; } public List<SelectOption> getSEItems() { List<SelectOption> seoptions = new List<SelectOption>(); seoptions.add(new SelectOption('No Filter', 'Support Engineer')); seoptions.add(new SelectOption(' ', 'No SE')); for (String a : seset) { seoptions.add(new SelectOption(a, a)); } system.debug('***' + seoptions); return seoptions; } public List<SelectOption> getAMItems() { List<SelectOption> amoptions = new List<SelectOption>(); amoptions.add(new SelectOption('No Filter', 'Account Manager')); for (String d : amset) { amoptions.add(new SelectOption(d, d)); } system.debug('***' + amoptions); return amoptions; } public void RefreshTable() { system.debug('*** RefreshTable1'); if(CSMFilter == 'No Filter' && SEFilter == 'No Filter' && AMFilter == 'No Filter') { myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes']; system.debug('*** All No Filter: ' + CSMFilter + ' | ' + SEFilter + ' | ' + AMFilter); } else if (CSMFilter != 'No Filter') { myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND Customer_Success_Manager__c = :CSMFilter]; system.debug('*** CSMFilter ' + CSMFilter); } else if (SEFilter != 'No Filter') { myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND Support_Engineer__c = :SEFilter]; system.debug('*** SEFilter ' + SEFilter); } else if (AMFilter != 'No Filter') { myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND Account_Manager__c= :AMFilter]; system.debug('*** AMFilter ' + AMFilter); } } public List<Customer_Health__c> getCHList(){ return myCHList; } public Decimal getNewRelease() { AggregateResult[] groupedResults = [SELECT COUNT(ID)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True AND (nCino_Version__c LIKE '%1.6%')]; Decimal totalACV = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalAcc FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalAcc'); return (totalACV/totalNum)*100; } public Decimal getAvgScore() { AggregateResult[] groupedResults = [SELECT SUM(Master_Scorecard__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalN'); return (totalAmount/totalNum); } public Decimal getAvgSat() { AggregateResult[] groupedResults = [SELECT SUM(Survey_Score__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalN'); return (totalAmount/totalNum); } public Decimal getInformatica() { AggregateResult[] groupedResults = [SELECT COUNT(Data_Integration__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True AND Data_Integration__c='Informatica']; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); return totalAmount; } public Decimal getAvgPTR() { AggregateResult[] groupedResults = [SELECT SUM(Pass_Through_Rate2__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalN'); return (totalAmount/totalNum); } public Decimal getDocMan() { AggregateResult[] groupedResults = [SELECT COUNT(HTML_DocMan__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True AND (HTML_DocMan__c='Yes - Successfully' OR HTML_DocMan__c = 'Yes - Piloting')]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); return totalAmount; } public Decimal getSpreads() { AggregateResult[] groupedResults = [SELECT COUNT(Spr__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True AND (Spr__c='Yes - Successfully' OR Spr__c = 'Yes - Piloting')]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); return totalAmount; } public Decimal getLogin() { AggregateResult[] groupedResults = [SELECT SUM(of_Login__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalN'); return (totalAmount/totalNum); } public Decimal getNumRecords() { AggregateResult[] groupedResults = [SELECT COUNT(Id)total FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes']; Decimal totalValue = (Decimal)groupedResults[0].get('total'); return totalValue; } public Decimal getAVGTotalLoans() { AggregateResult[] groupedResults = [SELECT COUNT(Id)Total FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Loans' AND nBIA__Start_Date__c = YESTERDAY]; Decimal totalCount = (Decimal)groupedResults[0].get('Total'); AggregateResult[] groupedResults1 = [SELECT SUM(nBIA__Count__c)summ FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Loans' AND nBIA__Start_Date__c = YESTERDAY]; Decimal totalSum = (Decimal)groupedResults1[0].get('summ'); Decimal avgloans; if (totalCount != 0) { avgloans = totalSum / totalCount; } else { avgloans = 0; } return avgloans; } public Decimal getAVGTotalAccounts() { AggregateResult[] groupedResults = [SELECT COUNT(Id)Total FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Accounts' AND nBIA__Start_Date__c = YESTERDAY]; Decimal totalCount = (Decimal)groupedResults[0].get('Total'); AggregateResult[] groupedResults1 = [SELECT SUM(nBIA__Count__c)summ FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Accounts' AND nBIA__Start_Date__c = YESTERDAY]; Decimal totalSum = (Decimal)groupedResults1[0].get('summ'); Decimal avgaccounts; if (totalCount != 0) { avgaccounts = totalSum / totalCount; } else { avgaccounts = 0; } return avgaccounts; } public Decimal getAVGReportsRun() { AggregateResult[] groupedResults = [SELECT nBIA__Data_Source_Name__c, SUM(nBIA__Count__c)TheSUM FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Reports Run' AND nBIA__Start_Date__c = LAST_N_DAYS:7 GROUP BY nBIA__Data_Source_Name__c]; Decimal TotalCount = 0; Decimal TotalSum = 0; Integer i; for (i = 0; i < groupedResults.size(); i++) { TotalCount++; TotalSum += (Decimal)groupedResults[i].get('TheSUM'); } Decimal avgreportrun; if (TotalCount != 0) { avgreportrun = TotalSum / TotalCount; } else { avgreportrun = 0; } return avgreportrun; } public Decimal getAVGDaysToClose() { AggregateResult[] groupedResults = [SELECT nBIA__Data_Source_Name__c, SUM(nBIA__Count__c)TheSUM, COUNT(Id)NumOfLoans FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Loans Days To Close' AND nBIA__Count__c <> 0 GROUP BY nBIA__Data_Source_Name__c]; Decimal TotalCount = 0; Decimal TotalLoans = 0; Decimal TotalSum = 0; Decimal TotalAvgDays = 0; Integer i; for (i = 0; i < groupedResults.size(); i++) { TotalCount++; TotalSum = (Decimal)groupedResults[i].get('TheSUM'); TotalLoans = (Decimal)groupedResults[i].get('NumOfLoans'); TotalAvgDays += TotalSum / TotalLoans; } Decimal avgdays = TotalAvgDays / TotalCount; if (TotalCount != 0) { avgdays = TotalAvgDays / TotalCount; } else { avgdays = 0; } return avgdays; } }
Here is my Test Class so far
@isTest(SeeAllData=true) private class nCino_CustomerHealthTest { @isTest static void test_method_one() { // Implement test code CHANNEL_ORDERS__Customer__c customer = new CHANNEL_ORDERS__Customer__c(CHANNEL_ORDERS__Customer_City__c = 'Wilmington', CHANNEL_ORDERS__Customer_Company_Name__c = 'The New Bank', CHANNEL_ORDERS__Customer_Country__c = 'US', CHANNEL_ORDERS__Customer_Org_ID__c = '00DG0000000jN8k', CHANNEL_ORDERS__Customer_State__c = 'NC', CHANNEL_ORDERS__Customer_Street__c = '11 Main Street', CHANNEL_ORDERS__Customer_ZIP_Postal_Code__c = '28411'); insert(customer); Account a = new Account(Name='The New Bank', Type='Customer', Industry='Bank', BillingState='NC', Customer__c = customer.Id, nCino_Version__c='1.64.4', Customer_Success_Manager__c = '005a0000007l9zJ', Primary_Product_Specialist__c = '005a000000AIahS', OwnerId = '005a0000009B00f'); insert(a); sfLma__License__c license = new sfLma__License__c(sfLma__Account__c = a.Id, sfLma__Install_Date__c = system.today(), sfLma__License_Type__c = 'Editable', sfLma__Package_Version__c = 'a0Ra000000Ib1Vx', sfLma__Status__c = 'Active', sfLma__Subscriber_Org_ID__c = '00DG0000000jN8k', sfLma__Used_Licenses__c = 2); insert(license); Customer_Health__c c = new Customer_Health__c(Account__c=a.Id); insert(c); nCino_CustomerHealth theTest = new nCino_CustomerHealth(); System.assert(theTest.cmSet.contains(c.Customer_Success_Manager__c)); System.assert(theTest.amSet.contains(c.Account_Manager__c)); System.assert(theTest.seSet.contains(c.Support_Engineer__c)); } }
It seems to not like the asserts when they worked before. Any Ideas?
- Christopher Pezza
- August 17, 2014
- Like
- 0
Trigger Update failing but saves
trigger LicenseUpdate on Customer_Health__c (after insert, after update) { Customer_Health__c NewLicenseNumber = new Customer_Health__c(); sfLma__License__c SalesforceLicenses = new sfLma__License__c(); Customer_Health__c updatech = trigger.new[0]; NewLicenseNumber = [SELECT Used_Licenses__c, Licenses_Total__c FROM Customer_Health__c WHERE Id = :updatech.Id]; SalesforceLicenses = [SELECT sfLma__Seats__c,sfLma__Used_Licenses__c,sfLma__Subscriber_Org_ID__c FROM sfLma__License__c WHERE sfLma__Subscriber_Org_ID__c LIKE :updatech.Org_ID__c AND sfLma__Package_Version__r.sfLma__Package__r.Name LIKE '%Bankr%' AND (sfLma__License__c.sfLma__License_Status__c LIKE '%Active%' OR sfLma__License__c.sfLma__License_Status__c LIKE '%Trial%')]; system.debug('**' + NewLicenseNumber); system.debug('**' + SalesforceLicenses); NewLicenseNumber.Used_Licenses__c = SalesforceLicenses.sfLma__Used_Licenses__c; NewLicenseNumber.Licenses_Total__c = SalesforceLicenses.sfLma__Seats__c; system.debug('**' + NewLicenseNumber); update(NewLicenseNumber); }
I'm trying to update a field on a custom object when the record is updated that fills out the two fields debicted above but i get these errors when i try before update/insert and after update/insert
ERROR FOR BEFORE INSERT/UPDATE:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger LicenseUpdate caused an unexpected exception, contact your administrator: LicenseUpdate: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a8Qa0000000CaRbEAK; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a8Qa0000000CaRb) is currently in trigger LicenseUpdate, therefore it cannot recursively update itself: []: Trigger.LicenseUpdate: line 21, column 1
ERROR FOR AFTER INSERT/UPDATE:
Error:Apex trigger LicenseUpdate caused an unexpected exception, contact your administrator: LicenseUpdate: execution of AfterUpdate caused by: System.DmlException: Upsert failed. First exception on row 0 with id a8Qa0000000CaRbEAK; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LicenseUpdate: maximum trigger depth exceeded Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb]: []: Trigger.LicenseUpdate: line 21, column 1
What am i doing wrong???
- Christopher Pezza
- August 16, 2014
- Like
- 0
Using Multiple <SelectOption> in Apex and SelectList SelectOptions
public with sharing class CustomerHealth { Public String CSMFilter {get ; set;} public Set<String> cmSet {get; set;} public CustomerHealth() { cmSet = new Set<String>(); for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(ch.Customer_Success_Manager__c); }//END for }//END public public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions= new List<SelectOption>(); for (String s : cmSet) { csmoptions.add(new SelectOption(s, s)); } return csmoptions; } }I created this an now want to create two more selct list the same as this but i get an error "Argument 1 cannot be null"
What My code looks like with multiple select list:
Controller:
public with sharing class CustomerHealth { public Set<String> cmSet {get; set;} public Set<String> amset {get; set;} public Set<String> seset {get; set;} public CustomerHealth() { cmSet = new Set<String>(); for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(ch.Customer_Success_Manager__c); }//END for amset = new Set<String>(); for(Customer_Health__c cha : [SELECT Account_Manager__c FROM Customer_Health__c]){ amset.add(cha.Account_Manager__c); } seset = new Set<String>(); for(Customer_Health__c chs : [SELECT Support_Engineer__c FROM Customer_Health__c]){ seset.add(chs.Support_Engineer__c); } }//END public public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions= new List<SelectOption>(); for (String s : cmSet) { csmoptions.add(new SelectOption(s, s)); } return csmoptions; } public List<SelectOption> getSEItems() { List<SelectOption> seoptions = new List<SelectOption>(); seoptions.add(new SelectOption('No Filter', 'Support Engineer')); seoptions.add(new SelectOption(' ', 'No SE')); for (String a : seset) { seoptions.add(new SelectOption(a, a)); } system.debug('***' + seoptions); return seoptions; } public List<SelectOption> getAMItems() { List<SelectOption> amoptions = new List<SelectOption>(); amoptions.add(new SelectOption('No Filter', 'Account Manager')); for (String d : amset) { amoptions.add(new SelectOption(d, d)); } system.debug('***' + amoptions); return amoptions; } }
Visual Force Page:
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!CSMFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!CSMItems}"></apex:selectOptions> </apex:selectList> <span class="divider"></span> <apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!SEFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!SEItems}"></apex:selectOptions> </apex:selectList> <span class="divider"></span> <apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!AMFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!AMItems}"></apex:selectOptions> </apex:selectList>
- Christopher Pezza
- August 08, 2014
- Like
- 0
Convert a deduped List to a Select Options in apex
Ok so I am trying to create a Select List in Visualforce of a list that was just deDuped with this code below:
When I do this the public List<SelectOption> won't let me save i get this Error: "Expression must be a list type: SET<String>" The line is: "options.add" line
public with sharing class CustomerHealth{ Set<String> cmSet = new Set<String>(); public CustomerHealth() { for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(ch.Customer_Success_Manager__c); }//END for }//END public public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions= new List<SelectOption>(); Decimal i; for (i=0; i < cmSet.size(); i++) { options.add(new SelectOption(cmSet[i], cmSet[i])); } return csmoptions; } }//END public with sharing
When I do this the public List<SelectOption> won't let me save i get this Error: "Expression must be a list type: SET<String>" The line is: "options.add" line
This is what im trying to output it in in visualforce:
Help please :)
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!CSMFilter}" onchange="RefreshTable1()"> <apex:selectOption value="{!cmSet}"></apex:selectOption> </apex:selectList>Now i have and actiofunction tied to it but its not relevant, This is before i tried adding the for loop. which i did a get of the deduped list to call that list and output it but i get this error when i do that: "Invalid selectOptions found. Use SelectOption type in Apex."
Help please :)
- Christopher Pezza
- August 08, 2014
- Like
- 0
Remove Duplicates from a List for a dropdown
SET<Customer_Health__c> CSMList = [SELECT Customer_Success_Manager__c FROM Customer_Health__c];
List<Customer_Health__c> CSMList2 = new CSMList2();
CSMList2.addAll(CSMList);
get and error for unexpected token where bolded and underlined
Any ideas to fix?
Trying to create a dropdown of athe CSMs where there is only one of each, it is a text field.
List<Customer_Health__c> CSMList2 = new CSMList2();
CSMList2.addAll(CSMList);
get and error for unexpected token where bolded and underlined
Any ideas to fix?
Trying to create a dropdown of athe CSMs where there is only one of each, it is a text field.
- Christopher Pezza
- August 06, 2014
- Like
- 0
Convert String Date to Date in Apex Class to insert to Object Field Type Date
public void SaveTheNewWebinars(){ system.debug('**It Worked**'); Webinar_nRichment_Attendees__c webinars = new Webinar_nRichment_Attendees__c(); Date newestwebDate = Date.parse(newwebDate); String newestwebType = newwebType; webinars.Name__c = newwebName; webinars.Activity_Date__c = newestwebDate; if (newestwebType == 'Webinar') { webinars.Webinar_Attendees__c = newwebAttendees; } else { webinars.nRichment_Attendees__c = newwebAttendees; } insert(webinars); }Ho do i convert "newwebDate" from 12/20/2014 to a Date format to insert to a object with a field with date type?
- Christopher Pezza
- July 24, 2014
- Like
- 0
How to get the User name in a list and display it in visual force in a soql query
I want to out put the Created By Name instead of the ID but don't know how to query the Users Name since __r doesnt work on the CreatedById Field. And then output the Name of the user on the repeated output of code.
VisualForce Page Code:
<apex:repeat value="{!customerHealth.Histories}" var="hh">
<tr>
<td><apex:outputText value="{0, date, EE MMMM dd, YYYY}"><apex:param value="{!hh.CreatedDate}"/></apex:outputText></td>
<td><apex:outputText value="{!hh.CreatedById}"></apex:outputText></td>
<apex:outputPanel rendered = "{!hh.Field = 'created'}">
<td><apex:outputText value="{!hh.Field}"></apex:outputText></td>
</apex:outputPanel>
<apex:outputPanel rendered = "{!hh.Field != 'created'}">
<td>Changed <strong><apex:outputText value="{!hh.Field}"></apex:outputText></strong> to <strong><apex:outputText value="{!hh.NewValue}"></apex:outputText></strong></td>
</apex:outputPanel>
</tr>
</apex:repeat>
Apex Class Code:
List<Customer_Health__c> customerHealths = new List<Customer_Health__c>([SELECT Name, (SELECT NewValue, Field, CreatedById, CreatedDate FROM Histories) FROM Customer_Health__c WHERE Id= :CHidNum]);
customerHealth = customerHealths.get(0);
VisualForce Page Code:
<apex:repeat value="{!customerHealth.Histories}" var="hh">
<tr>
<td><apex:outputText value="{0, date, EE MMMM dd, YYYY}"><apex:param value="{!hh.CreatedDate}"/></apex:outputText></td>
<td><apex:outputText value="{!hh.CreatedById}"></apex:outputText></td>
<apex:outputPanel rendered = "{!hh.Field = 'created'}">
<td><apex:outputText value="{!hh.Field}"></apex:outputText></td>
</apex:outputPanel>
<apex:outputPanel rendered = "{!hh.Field != 'created'}">
<td>Changed <strong><apex:outputText value="{!hh.Field}"></apex:outputText></strong> to <strong><apex:outputText value="{!hh.NewValue}"></apex:outputText></strong></td>
</apex:outputPanel>
</tr>
</apex:repeat>
Apex Class Code:
List<Customer_Health__c> customerHealths = new List<Customer_Health__c>([SELECT Name, (SELECT NewValue, Field, CreatedById, CreatedDate FROM Histories) FROM Customer_Health__c WHERE Id= :CHidNum]);
customerHealth = customerHealths.get(0);
- Christopher Pezza
- July 24, 2014
- Like
- 0
Dependant Picklist Does Not Render Class Attribute
I am trying to add a Class to a Input Field in Visual Force but when the page is rendered it removes the styleClass Attribute. This inputField is a dependant Picklist.
Below is my VF Code
<apex:inputField value="{!configTaskToUpdate.Config_Category__c}" styleClass="form-control" id="thecategory"/>
i have tried adding the the code to a div tag around it but it comes out akward
I have also tried adding it to the the field by jQuery as below but that doesnt work either
Anyone have this issue and or found a workaround or is SF working on it?
Below is my VF Code
<apex:inputField value="{!configTaskToUpdate.Config_Category__c}" styleClass="form-control" id="thecategory"/>
i have tried adding the the code to a div tag around it but it comes out akward
I have also tried adding it to the the field by jQuery as below but that doesnt work either
$(document).ready(function() { $(function() { $("#{!$Component.theform.thecategory}").addClass("form-control"); console.log('added the form-control class'); }); });
Anyone have this issue and or found a workaround or is SF working on it?
- Christopher Pezza
- January 28, 2015
- Like
- 0
Passing Variable of null when its not
It wont pass the Id to the Variable any reason why or that i am missing
public void AttachLoan() { System.debug('** in Add'); System.debug('**' + AddLoanID); LLC_BI__Loan__c ul = [SELECT Id, Name, LLC_CDS__Deal_Facility__c FROM LLC_BI__Loan__c WHERE Id = :AddLoanID LIMIT 1]; system.debug('** ' + ul); ul.LLC_CDS__Deal_Facility__c = ObjId; system.debug('**2 ' + ul); update(ul); }
<apex:repeat value="{!AddLoans}" var="fa"> <tr> <td> <apex:form > <apex:commandButton value="Add" action="{!AttachLoan}" styleClass="btn btn-xs btn-success"> <apex:param value="{!fa.Id}" AssignTo="{!AddLoanID}"/> </apex:commandButton> </apex:form> </td> <td><a href="/{!fa.Id}" target="_Blank">{!fa.Name}</a></td> <td>{!fa.LLC_BI__lookupKey__c}</td> <td><a href="/{!fa.LLC_BI__Account__c}" target="_Blank">{!fa.LLC_BI__Account__r.Name}</a></td> </tr> </apex:repeat>
- Christopher Pezza
- October 25, 2014
- Like
- 0
Can't Perform save Function in Apex
So i'm trying to save a record on a visual force page but it won't perform the save function. It gets into the method but never actually grabs the information from the page. NAy Ideas? Here is my Code
Class
Page
Class
public with sharing class nCino_CustomerHealthIndividual{ public string CHidNum = Apexpages.currentPage().getParameters().get('id'); public Customer_Health__c CustomerHealth {get;set;} public nCino_CustomerHealthIndividual(){ this.CustomerHealth = getCustHealth(); } public PageReference save() { update this.CustomerHealth; return null; } //Customer Health Fields public List<Schema.FieldSetMember> getCHFields() { return SObjectType.Customer_Health__c.FieldSets.Main.getFields(); } public Customer_Health__c getCustHealth() { String query = 'SELECT '; for(Schema.FieldSetMember f : this.getCHFields()) { query += f.getFieldPath() + ', '; } query += 'Id, Name FROM Customer_Health__c WHERE Id = :CHidNum LIMIT 1'; return Database.query(query); }
Page
<apex:form> <!-- Edit System Information --> <div class="modal modal-flex fade" id="editsysteminfomodal" tabindex="-1" role="dialog" aria-labelledby="editsysteminfomodallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title" id="editsysteminfomodallabel">Edit System Information Section</h4> </div> <div class="modal-body"> <form class="form-horizontal" role="form"> <div class="form-group"> <label class=" col-md-5 control-label">nCino Sandbox Version</label> <div class="col-md-7"> <apex:inputField value="{!CustomerHealth.Sandbox_Version__c}"/> </div> </div> </form> </div> <div class="modal-footer"> <apex:commandButton value="Save" action="{!save}"></apex:commandButton> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> </apex:form>
- Christopher Pezza
- September 14, 2014
- Like
- 0
Error with Field Sets and Objects
So I'm building a configurable visualforce page that in an object you type the name of field sets and sech to then display a tabbed view but i get this error when i do so what am i missing
Error: Could not resolve field '0IX' from <apex:outputField> value binding '{!LLC_BI__Loan__c[f]}' in page ncino_checklist
Apex Class
Visualforce Page
Error: Could not resolve field '0IX' from <apex:outputField> value binding '{!LLC_BI__Loan__c[f]}' in page ncino_checklist
Apex Class
public with sharing class nCino_ChecklistExt{ public ApexPages.StandardController stdCtrl {get; set;} public Boolean refreshPage {get; set;} List<nCino_Config__c> configvalues {get;set;} public nCino_ChecklistExt(ApexPages.StandardController controller) { stdCtrl=controller; refreshPage=true; } public List<nCino_Config__c> getConfigValues() { configvalues = [SELECT Id, Name, Tab_Name__c, Tab_Display_Order__c, Tab_Color__c, Tabbed_Content_Name__c, Icon_for_Tab__c, Field_Set__c FROM nCino_Config__c WHERE App_Name__c = 'Checklist' ORDER BY Tab_Display_Order__c DESC]; return configvalues; } public PageReference save(){ LLC_BI__Loan__c loan=(LLC_BI__Loan__c) stdCtrl.getRecord(); stdCtrl.save(); return null; } public PageReference cancel(){ LLC_BI__Loan__c loan=(LLC_BI__Loan__c) stdCtrl.getRecord(); stdCtrl.save(); return null; } }
Visualforce Page
<apex:page showHeader="false" sidebar="false" standardController="LLC_BI__Loan__c" extensions="nCino_ChecklistExt" standardStylesheets="true"> <head> <apex:stylesheet value="{!URLFOR($Resource.bootstrap, '/css/bootstrap.css')}"/> <style type="text/css"> .thebox{ margin: 15px; width:auto; height:400px; background-color:#F0F0F0; border-radius:15px; } .left-side{ float:left; width:16.66666667%; background-color:#FFF; height:400px; } .right-side{ float:left; width:83.33333333%; height:400px; } .border-green{border-left-color:#88C240;border-left-width:5px;} .border-blue{border-left-color: #2D79D7;border-left-width:5px;} .border-red{border-left-color: #BA202F;border-left-width:5px;} .border-yellow{border-left-color: #F5AB3F;border-left-width:5px;} .border-gray{border-left-color: #666;border-left-width:5px;} .top-border-blue{border-top-color:#88C240;border-top-width:5px;} </style> <title>Untitled Document</title> </head> <div class="thebox"> <div class="left-side"> <div class="list-group" role="tablist" id="myTab"> <apex:repeat value="{!ConfigValues}" var="cv"> <a href="#tab{!cv.Tab_Display_Order__c}" class="list-group-item border-{!cv.Tab_Color__c}" role="tab" data-toggle="tab"><i class="gyphicon glyphicon-{!cv.Icon_for_Tab__c}"></i> {!cv.Tab_Name__c}</a> </apex:repeat> </div> </div> <apex:form> <div class="right-side tab-content" id="myTabcontent"> <div class="tab-pane active"> Main Page :) </div> <apex:repeat value="{!ConfigValues}" var="ncv"> <div class="tab-pane" id="tab{!ncv.Tab_Display_Order__c}"> <apex:pageBlock title="{!ncv.Tabbed_Content_Name__c}"> <apex:pageBlockSection> <apex:variable value="{!ncv.Field_Set__c}" var="fieldset"/> <apex:repeat value="{!$ObjectType.fieldset}" var="f"> <apex:outputField value="{!LLC_BI__Loan__c[f]}"> <apex:inlineEditSupport event="ondblclick"/> </apex:outputField> </apex:repeat> </apex:pageBlockSection> <apex:pageBlockButtons location="bottom"> <apex:commandButton action="{!save}" value="Save"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> </apex:pageBlock> </div> </apex:repeat> </div> </apex:form> </div> <apex:includeScript value="{!URLFOR($Resource.bootstrap, '/js/jquery-2.1.1.min.js')}"/> <apex:includeScript value="{!URLFOR($Resource.bootstrap, '/js/bootstrap.min.js')}"/> <script> $('#myTab a').click(function (e) { e.preventDefault() $(this).tab('show') }) </script> </apex:page>
- Christopher Pezza
- September 01, 2014
- Like
- 0
Test Coverage on a function
public void deleteAttachment(){ Attachment attc = [SELECT Id, Name from Attachment WHERE Id = :attachId]; delete(attc); }How would I write test coverage for this function?
- Christopher Pezza
- August 17, 2014
- Like
- 0
Test Coverage Help
Heres my Class
Here is my Test Class so far
It seems to not like the asserts when they worked before. Any Ideas?
public with sharing class nCino_CustomerHealth{ //Declare Public Variables List<Customer_Health__c> myCHList; public Set<String> cmSet {get; set;} public Set<String> amset {get; set;} public Set<String> seset {get; set;} public String CSMFilter {get;set;} public String SEFilter {get;set;} public String AMFilter {get;set;} public nCino_CustomerHealth() { cmSet = new Set<String>(); for(Customer_Health__c chc : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(chc.Customer_Success_Manager__c); } amset = new Set<String>(); for(Customer_Health__c cha : [SELECT Account_Manager__c FROM Customer_Health__c WHERE Account_Manager__c <> ' ']){ amset.add(cha.Account_Manager__c); } seset = new Set<String>(); for(Customer_Health__c chs : [SELECT Support_Engineer__c FROM Customer_Health__c WHERE Support_Engineer__c <> ' ']){ seset.add(chs.Support_Engineer__c); } myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes']; } public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions = new List<SelectOption>(); csmoptions.add(new SelectOption('No Filter', 'Customer Success Manager')); csmoptions.add(new SelectOption(' ', 'No CSM')); for (String s : cmSet) { csmoptions.add(new SelectOption(s, s)); } system.debug('***' + csmoptions); return csmoptions; } public List<SelectOption> getSEItems() { List<SelectOption> seoptions = new List<SelectOption>(); seoptions.add(new SelectOption('No Filter', 'Support Engineer')); seoptions.add(new SelectOption(' ', 'No SE')); for (String a : seset) { seoptions.add(new SelectOption(a, a)); } system.debug('***' + seoptions); return seoptions; } public List<SelectOption> getAMItems() { List<SelectOption> amoptions = new List<SelectOption>(); amoptions.add(new SelectOption('No Filter', 'Account Manager')); for (String d : amset) { amoptions.add(new SelectOption(d, d)); } system.debug('***' + amoptions); return amoptions; } public void RefreshTable() { system.debug('*** RefreshTable1'); if(CSMFilter == 'No Filter' && SEFilter == 'No Filter' && AMFilter == 'No Filter') { myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes']; system.debug('*** All No Filter: ' + CSMFilter + ' | ' + SEFilter + ' | ' + AMFilter); } else if (CSMFilter != 'No Filter') { myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND Customer_Success_Manager__c = :CSMFilter]; system.debug('*** CSMFilter ' + CSMFilter); } else if (SEFilter != 'No Filter') { myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND Support_Engineer__c = :SEFilter]; system.debug('*** SEFilter ' + SEFilter); } else if (AMFilter != 'No Filter') { myCHList = [SELECT Id, Name, Account__r.Name, Account__c, Master_Scorecard__c, Survey_Score__c, Data_Storage__c, File_Storage__c, Avg_Stage_Duration__c, Days_to_Close1__c, Days_to_close2__c, Pass_Through_Rate2__c, Pass_Through_Rate1__c, Account__r.Handed_over_to_support__c FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes' AND Account_Manager__c= :AMFilter]; system.debug('*** AMFilter ' + AMFilter); } } public List<Customer_Health__c> getCHList(){ return myCHList; } public Decimal getNewRelease() { AggregateResult[] groupedResults = [SELECT COUNT(ID)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True AND (nCino_Version__c LIKE '%1.6%')]; Decimal totalACV = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalAcc FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalAcc'); return (totalACV/totalNum)*100; } public Decimal getAvgScore() { AggregateResult[] groupedResults = [SELECT SUM(Master_Scorecard__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalN'); return (totalAmount/totalNum); } public Decimal getAvgSat() { AggregateResult[] groupedResults = [SELECT SUM(Survey_Score__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalN'); return (totalAmount/totalNum); } public Decimal getInformatica() { AggregateResult[] groupedResults = [SELECT COUNT(Data_Integration__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True AND Data_Integration__c='Informatica']; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); return totalAmount; } public Decimal getAvgPTR() { AggregateResult[] groupedResults = [SELECT SUM(Pass_Through_Rate2__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalN'); return (totalAmount/totalNum); } public Decimal getDocMan() { AggregateResult[] groupedResults = [SELECT COUNT(HTML_DocMan__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True AND (HTML_DocMan__c='Yes - Successfully' OR HTML_DocMan__c = 'Yes - Piloting')]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); return totalAmount; } public Decimal getSpreads() { AggregateResult[] groupedResults = [SELECT COUNT(Spr__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True AND (Spr__c='Yes - Successfully' OR Spr__c = 'Yes - Piloting')]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); return totalAmount; } public Decimal getLogin() { AggregateResult[] groupedResults = [SELECT SUM(of_Login__c)totalSum FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalAmount = (Decimal)groupedResults[0].get('totalSum'); AggregateResult[] groupedResults2 = [SELECT COUNT(ID)totalN FROM Customer_Health__c WHERE Account__r.Handed_over_to_Support__c=True]; Decimal totalNum = (Decimal)groupedResults2[0].get('totalN'); return (totalAmount/totalNum); } public Decimal getNumRecords() { AggregateResult[] groupedResults = [SELECT COUNT(Id)total FROM Customer_Health__c WHERE Account__r.Current_Customer__c='Yes']; Decimal totalValue = (Decimal)groupedResults[0].get('total'); return totalValue; } public Decimal getAVGTotalLoans() { AggregateResult[] groupedResults = [SELECT COUNT(Id)Total FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Loans' AND nBIA__Start_Date__c = YESTERDAY]; Decimal totalCount = (Decimal)groupedResults[0].get('Total'); AggregateResult[] groupedResults1 = [SELECT SUM(nBIA__Count__c)summ FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Loans' AND nBIA__Start_Date__c = YESTERDAY]; Decimal totalSum = (Decimal)groupedResults1[0].get('summ'); Decimal avgloans; if (totalCount != 0) { avgloans = totalSum / totalCount; } else { avgloans = 0; } return avgloans; } public Decimal getAVGTotalAccounts() { AggregateResult[] groupedResults = [SELECT COUNT(Id)Total FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Accounts' AND nBIA__Start_Date__c = YESTERDAY]; Decimal totalCount = (Decimal)groupedResults[0].get('Total'); AggregateResult[] groupedResults1 = [SELECT SUM(nBIA__Count__c)summ FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Accounts' AND nBIA__Start_Date__c = YESTERDAY]; Decimal totalSum = (Decimal)groupedResults1[0].get('summ'); Decimal avgaccounts; if (totalCount != 0) { avgaccounts = totalSum / totalCount; } else { avgaccounts = 0; } return avgaccounts; } public Decimal getAVGReportsRun() { AggregateResult[] groupedResults = [SELECT nBIA__Data_Source_Name__c, SUM(nBIA__Count__c)TheSUM FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Reports Run' AND nBIA__Start_Date__c = LAST_N_DAYS:7 GROUP BY nBIA__Data_Source_Name__c]; Decimal TotalCount = 0; Decimal TotalSum = 0; Integer i; for (i = 0; i < groupedResults.size(); i++) { TotalCount++; TotalSum += (Decimal)groupedResults[i].get('TheSUM'); } Decimal avgreportrun; if (TotalCount != 0) { avgreportrun = TotalSum / TotalCount; } else { avgreportrun = 0; } return avgreportrun; } public Decimal getAVGDaysToClose() { AggregateResult[] groupedResults = [SELECT nBIA__Data_Source_Name__c, SUM(nBIA__Count__c)TheSUM, COUNT(Id)NumOfLoans FROM nBIA__BI_Data__c WHERE nBIA__Unique_Name__c = 'AS: Loans Days To Close' AND nBIA__Count__c <> 0 GROUP BY nBIA__Data_Source_Name__c]; Decimal TotalCount = 0; Decimal TotalLoans = 0; Decimal TotalSum = 0; Decimal TotalAvgDays = 0; Integer i; for (i = 0; i < groupedResults.size(); i++) { TotalCount++; TotalSum = (Decimal)groupedResults[i].get('TheSUM'); TotalLoans = (Decimal)groupedResults[i].get('NumOfLoans'); TotalAvgDays += TotalSum / TotalLoans; } Decimal avgdays = TotalAvgDays / TotalCount; if (TotalCount != 0) { avgdays = TotalAvgDays / TotalCount; } else { avgdays = 0; } return avgdays; } }
Here is my Test Class so far
@isTest(SeeAllData=true) private class nCino_CustomerHealthTest { @isTest static void test_method_one() { // Implement test code CHANNEL_ORDERS__Customer__c customer = new CHANNEL_ORDERS__Customer__c(CHANNEL_ORDERS__Customer_City__c = 'Wilmington', CHANNEL_ORDERS__Customer_Company_Name__c = 'The New Bank', CHANNEL_ORDERS__Customer_Country__c = 'US', CHANNEL_ORDERS__Customer_Org_ID__c = '00DG0000000jN8k', CHANNEL_ORDERS__Customer_State__c = 'NC', CHANNEL_ORDERS__Customer_Street__c = '11 Main Street', CHANNEL_ORDERS__Customer_ZIP_Postal_Code__c = '28411'); insert(customer); Account a = new Account(Name='The New Bank', Type='Customer', Industry='Bank', BillingState='NC', Customer__c = customer.Id, nCino_Version__c='1.64.4', Customer_Success_Manager__c = '005a0000007l9zJ', Primary_Product_Specialist__c = '005a000000AIahS', OwnerId = '005a0000009B00f'); insert(a); sfLma__License__c license = new sfLma__License__c(sfLma__Account__c = a.Id, sfLma__Install_Date__c = system.today(), sfLma__License_Type__c = 'Editable', sfLma__Package_Version__c = 'a0Ra000000Ib1Vx', sfLma__Status__c = 'Active', sfLma__Subscriber_Org_ID__c = '00DG0000000jN8k', sfLma__Used_Licenses__c = 2); insert(license); Customer_Health__c c = new Customer_Health__c(Account__c=a.Id); insert(c); nCino_CustomerHealth theTest = new nCino_CustomerHealth(); System.assert(theTest.cmSet.contains(c.Customer_Success_Manager__c)); System.assert(theTest.amSet.contains(c.Account_Manager__c)); System.assert(theTest.seSet.contains(c.Support_Engineer__c)); } }
It seems to not like the asserts when they worked before. Any Ideas?
- Christopher Pezza
- August 17, 2014
- Like
- 0
Trigger Update failing but saves
trigger LicenseUpdate on Customer_Health__c (after insert, after update) { Customer_Health__c NewLicenseNumber = new Customer_Health__c(); sfLma__License__c SalesforceLicenses = new sfLma__License__c(); Customer_Health__c updatech = trigger.new[0]; NewLicenseNumber = [SELECT Used_Licenses__c, Licenses_Total__c FROM Customer_Health__c WHERE Id = :updatech.Id]; SalesforceLicenses = [SELECT sfLma__Seats__c,sfLma__Used_Licenses__c,sfLma__Subscriber_Org_ID__c FROM sfLma__License__c WHERE sfLma__Subscriber_Org_ID__c LIKE :updatech.Org_ID__c AND sfLma__Package_Version__r.sfLma__Package__r.Name LIKE '%Bankr%' AND (sfLma__License__c.sfLma__License_Status__c LIKE '%Active%' OR sfLma__License__c.sfLma__License_Status__c LIKE '%Trial%')]; system.debug('**' + NewLicenseNumber); system.debug('**' + SalesforceLicenses); NewLicenseNumber.Used_Licenses__c = SalesforceLicenses.sfLma__Used_Licenses__c; NewLicenseNumber.Licenses_Total__c = SalesforceLicenses.sfLma__Seats__c; system.debug('**' + NewLicenseNumber); update(NewLicenseNumber); }
I'm trying to update a field on a custom object when the record is updated that fills out the two fields debicted above but i get these errors when i try before update/insert and after update/insert
ERROR FOR BEFORE INSERT/UPDATE:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger LicenseUpdate caused an unexpected exception, contact your administrator: LicenseUpdate: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a8Qa0000000CaRbEAK; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = a8Qa0000000CaRb) is currently in trigger LicenseUpdate, therefore it cannot recursively update itself: []: Trigger.LicenseUpdate: line 21, column 1
ERROR FOR AFTER INSERT/UPDATE:
Error:Apex trigger LicenseUpdate caused an unexpected exception, contact your administrator: LicenseUpdate: execution of AfterUpdate caused by: System.DmlException: Upsert failed. First exception on row 0 with id a8Qa0000000CaRbEAK; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LicenseUpdate: maximum trigger depth exceeded Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb] Customer_Health trigger event AfterUpdate for [a8Qa0000000CaRb]: []: Trigger.LicenseUpdate: line 21, column 1
What am i doing wrong???
- Christopher Pezza
- August 16, 2014
- Like
- 0
Using Multiple <SelectOption> in Apex and SelectList SelectOptions
public with sharing class CustomerHealth { Public String CSMFilter {get ; set;} public Set<String> cmSet {get; set;} public CustomerHealth() { cmSet = new Set<String>(); for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(ch.Customer_Success_Manager__c); }//END for }//END public public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions= new List<SelectOption>(); for (String s : cmSet) { csmoptions.add(new SelectOption(s, s)); } return csmoptions; } }I created this an now want to create two more selct list the same as this but i get an error "Argument 1 cannot be null"
What My code looks like with multiple select list:
Controller:
public with sharing class CustomerHealth { public Set<String> cmSet {get; set;} public Set<String> amset {get; set;} public Set<String> seset {get; set;} public CustomerHealth() { cmSet = new Set<String>(); for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(ch.Customer_Success_Manager__c); }//END for amset = new Set<String>(); for(Customer_Health__c cha : [SELECT Account_Manager__c FROM Customer_Health__c]){ amset.add(cha.Account_Manager__c); } seset = new Set<String>(); for(Customer_Health__c chs : [SELECT Support_Engineer__c FROM Customer_Health__c]){ seset.add(chs.Support_Engineer__c); } }//END public public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions= new List<SelectOption>(); for (String s : cmSet) { csmoptions.add(new SelectOption(s, s)); } return csmoptions; } public List<SelectOption> getSEItems() { List<SelectOption> seoptions = new List<SelectOption>(); seoptions.add(new SelectOption('No Filter', 'Support Engineer')); seoptions.add(new SelectOption(' ', 'No SE')); for (String a : seset) { seoptions.add(new SelectOption(a, a)); } system.debug('***' + seoptions); return seoptions; } public List<SelectOption> getAMItems() { List<SelectOption> amoptions = new List<SelectOption>(); amoptions.add(new SelectOption('No Filter', 'Account Manager')); for (String d : amset) { amoptions.add(new SelectOption(d, d)); } system.debug('***' + amoptions); return amoptions; } }
Visual Force Page:
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!CSMFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!CSMItems}"></apex:selectOptions> </apex:selectList> <span class="divider"></span> <apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!SEFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!SEItems}"></apex:selectOptions> </apex:selectList> <span class="divider"></span> <apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!AMFilter}" onchange="RefreshTable1()"> <apex:selectOptions value="{!AMItems}"></apex:selectOptions> </apex:selectList>
- Christopher Pezza
- August 08, 2014
- Like
- 0
Convert a deduped List to a Select Options in apex
Ok so I am trying to create a Select List in Visualforce of a list that was just deDuped with this code below:
When I do this the public List<SelectOption> won't let me save i get this Error: "Expression must be a list type: SET<String>" The line is: "options.add" line
public with sharing class CustomerHealth{ Set<String> cmSet = new Set<String>(); public CustomerHealth() { for(Customer_Health__c ch : [SELECT Customer_Success_Manager__c FROM Customer_Health__c WHERE Customer_Success_Manager__c <> ' ']){ cmSet.add(ch.Customer_Success_Manager__c); }//END for }//END public public List<SelectOption> getCSMItems() { List<SelectOption> csmoptions= new List<SelectOption>(); Decimal i; for (i=0; i < cmSet.size(); i++) { options.add(new SelectOption(cmSet[i], cmSet[i])); } return csmoptions; } }//END public with sharing
When I do this the public List<SelectOption> won't let me save i get this Error: "Expression must be a list type: SET<String>" The line is: "options.add" line
This is what im trying to output it in in visualforce:
Help please :)
<apex:selectList size="1" styleClass="btn btn-green btn-xs" value="{!CSMFilter}" onchange="RefreshTable1()"> <apex:selectOption value="{!cmSet}"></apex:selectOption> </apex:selectList>Now i have and actiofunction tied to it but its not relevant, This is before i tried adding the for loop. which i did a get of the deduped list to call that list and output it but i get this error when i do that: "Invalid selectOptions found. Use SelectOption type in Apex."
Help please :)
- Christopher Pezza
- August 08, 2014
- Like
- 0
Remove Duplicates from a List for a dropdown
SET<Customer_Health__c> CSMList = [SELECT Customer_Success_Manager__c FROM Customer_Health__c];
List<Customer_Health__c> CSMList2 = new CSMList2();
CSMList2.addAll(CSMList);
get and error for unexpected token where bolded and underlined
Any ideas to fix?
Trying to create a dropdown of athe CSMs where there is only one of each, it is a text field.
List<Customer_Health__c> CSMList2 = new CSMList2();
CSMList2.addAll(CSMList);
get and error for unexpected token where bolded and underlined
Any ideas to fix?
Trying to create a dropdown of athe CSMs where there is only one of each, it is a text field.
- Christopher Pezza
- August 06, 2014
- Like
- 0
Convert String Date to Date in Apex Class to insert to Object Field Type Date
public void SaveTheNewWebinars(){ system.debug('**It Worked**'); Webinar_nRichment_Attendees__c webinars = new Webinar_nRichment_Attendees__c(); Date newestwebDate = Date.parse(newwebDate); String newestwebType = newwebType; webinars.Name__c = newwebName; webinars.Activity_Date__c = newestwebDate; if (newestwebType == 'Webinar') { webinars.Webinar_Attendees__c = newwebAttendees; } else { webinars.nRichment_Attendees__c = newwebAttendees; } insert(webinars); }Ho do i convert "newwebDate" from 12/20/2014 to a Date format to insert to a object with a field with date type?
- Christopher Pezza
- July 24, 2014
- Like
- 0