-
ChatterFeed
-
0Best Answers
-
1Likes Received
-
0Likes Given
-
31Questions
-
24Replies
Formula for splitting field
I have this field that's populated via an API (OrderComments__c)
Here are two examples:
JOHN | CHNL_APPROVED |
JAKE | IP_OVERRIDEN | Test 1
JEFF | MGR_APPROVED |
JOHN | CHNL_APPROVED |
JEFF | MGR_APPROVED |
Now my question is, is it possible to write a formula that would extract JEFF from the first and second example. The second seems pretty straight forward, you would just have to find string between second and third |
But the first example seems to be a lot harder, is there any logic that could be written into a formula to recognize JEFF without also bringing in Test 1?
Thanks!
- Chad Ritchie
- September 30, 2021
- Like
- 0
- Continue reading or reply
Adding Wait/Pause/Delay Clause to Apex Code?
I wrote this code in the Execute Anonymous Window, essentially it finds the first record where Trigger__c is false, and makes it True.
List<Rep_Codes__c> replist = [SELECT Id, Trigger__c FROM Rep_Codes__c Where Trigger__c = False LIMIT 1]; for(Rep_Codes__c rep :replist){ rep.Trigger__c = True; } update repList;I need to make this update for a few hundred records, but the process that's being fired will blow up when it's run on more than a few records at a time.. And unfortunately our DataLoader isn't working right now.. so I'd like to figure out a way to have this code run and once it's finished it finds the next record, or something along those lines. Is this possible in an anonymous window? Not looking to have to write a test class or anything..
Thanks!!
- Chad Ritchie
- July 23, 2021
- Like
- 0
- Continue reading or reply
DataLoader 400 Error
- Chad Ritchie
- December 09, 2020
- Like
- 0
- Continue reading or reply
Sorting Visualforce DataTable
<apex:dataTable value="{!Contact.Positions__r}" var="b" rules="all" columns="3" columnsWidth="250px,250px" align="left" columnClasses="columnBorders" cellpadding="5px" cellspacing="0"> <apex:facet name="header">ACTIVE POSITIONS</apex:facet> <apex:column value="{!b.Product__r.Name}" headerValue="Product" rendered="{!b.isactive__c}"/> <apex:column value="{!b.Name}" headerValue="Account Name" rendered="{!b.isactive__c}"/> <apex:column value="{!b.Balance__c}" headerValue="Balance" rendered="{!b.isactive__c}"/> </apex:dataTable>Thanks!!!
- Chad Ritchie
- May 15, 2020
- Like
- 0
- Continue reading or reply
Basic Visualforce DataTable Filter
Does anyone know how I could add a simple filter to both of these datatables?
For example the first one I'd like to add a filter allowing only balances__c>0 only.
I'm using a standard controller, and would ideally like to avoid using a custom controller to solve this.
<table>
<tr>
<td>
<apex:dataTable value="{!Contact.Positions__r}" var="b" rules="all" columns="3" columnsWidth="250px,250px" align="left"
columnClasses="columnBorders" headerClass="dataTableHeader" cellpadding="5px" cellspacing="0">
<apex:column value="{!b.Product__r.Name}" headerValue="Product" />
<apex:column value="{!b.Name}" headerValue="Account Name"/>
<apex:column value="{!b.Balance__c}" headerValue="Balance"/>
</apex:dataTable>
</td>
<td>
<apex:dataTable value="{!Contact.Transactions__r}" var="b" rules="all" columns="3" columnsWidth="250px,250px" align="left"
columnClasses="columnBorders" headerClass="dataTableHeader" cellpadding="5px" cellspacing="0">
<apex:column value="{!b.Product__r.Name}" headerValue="Product" />
<apex:column value="{!b.Investor_Account_Name__c}" headerValue="Account Name"/>
<apex:column value="{!b.Gross_Amount__c}" headerValue="Gross Amount"/>
</apex:dataTable>
</td>
</tr>
</table>
Thanks!
- Chad Ritchie
- May 14, 2020
- Like
- 0
- Continue reading or reply
Sorting DataTable in Visualforce
I have a pretty simple dataTable in Visualforce (see code below), I'm just trying to figure out how to sort by {!b.Balance__c}
I've tried a number of things, but none of them seem to work.
Thanks!!!
<apex:pageBlock >
<apex:dataTable value="{!Contact.Positions__r}" var="b" width="100%" columns="1" columnsWidth="60%,40%">
sortorder = "{!b.Name}"
<apex:column >
<apex:outputText value="{!b.Product__r.Name}"/>
</apex:column>
<apex:column >
<apex:outputText value="{!b.Name}"/>
</apex:column>
<apex:column style="text-align:right" headerClass="CurrencyElement">
<apex:outputField value="{!b.Balance__c}"/>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
- Chad Ritchie
- May 14, 2020
- Like
- 0
- Continue reading or reply
Visualforce Page for Filtering Reports
I'm trying to embed a Visualforce Page onto my home page that allows users to select a report and filter it right there.
When running I seem to be getting the following error:
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.AnalyticsController.getSelectedFilters: line 69, column 1
Class.AnalyticsController.getChartFilter: line 64, column 1
Can anyone identify what's causing this issue? I notice this code was written for API Ver 29, while I'm on 48.
Visualforce Page:
<apex:page controller="AnalyticsController"> <style> label { font-weight: bold; } #filters { overflow: hidden; width: 100% } #filterBox { float: left; align: center; padding: 5px 5px 5px 0px; } </style> <apex:form > <apex:outputLabel value="Select Report"/> <apex:selectList value="{!reportId}" multiselect="false" size="1"> <apex:selectOptions value="{!availableReports}"/> </apex:selectList> <apex:commandButton action="{!getReportInfo}" value="Get Report Filters" reRender="report"/><br/> <apex:outputPanel id="report" layout="block"> <apex:outputPanel rendered="{!reportId != null}"> <div id="filters"> <apex:repeat value="{!availableColumnFilters}" var="colFilter"> <div id="filterBox"> <apex:outputLabel >{!colFilter.label}</apex:outputLabel><br/> <apex:selectList value="{!colFilter.operator}" size="1" multiselect="false" style="width: 100px;"> <apex:selectOption itemLabel="--None--" itemValue=""/> <apex:selectOptions value="{!availableDataTypeFilterOperators[colFilter.dataType]}"/> </apex:selectList> <apex:inputText value="{!colFilter.value}"/> </div> </apex:repeat> </div> <apex:commandButton value="Get Chart with Filters" reRender="chart"/><br/> <apex:outputPanel layout="block" id="chart"> <analytics:reportChart reportId="{!reportId}" filter="{!chartFilter}"/> </apex:outputPanel> </apex:outputPanel> </apex:outputPanel> </apex:form> </apex:page>
Controller:
public with sharing class AnalyticsController{ public List<SelectOption> availableReports { get; set; } public Id reportId { get; set; } public Map<String, List<SelectOption>> availableDataTypeFilterOperators { get; set; } public List<ColumnFilter> availableColumnFilters { get; set; } public AnalyticsController() { availableReports = retrieveAvailableReports(); availableDataTypeFilterOperators = retrieveAvailableDataTypeFilterOperators(); } public List<SelectOption> retrieveAvailableReports() { List<SelectOption> reptOpts = new List<SelectOption>(); for (Report r : [ Select Id, Name From Report Where Format In ('Summary','Matrix') Order By Name ]) { reptOpts.add(new SelectOption(r.Id, r.Name)); } return reptOpts; } public Map<String, List<SelectOption>> retrieveAvailableDataTypeFilterOperators() { Map<String, List<SelectOption>> dataTypeFilterOpts = new Map<String, List<SelectOption>>(); Map<String, List<Reports.FilterOperator>> filterOperatorMap = Reports.ReportManager.getDataTypeFilterOperatorMap(); for (String dataType : filterOperatorMap.keySet()) { List<SelectOption> operators = new List<SelectOption>(); // Append _DATA to match ColumnDataType from ReportTypeColumn dataTypeFilterOpts.put(dataType.toUpperCase() + '_DATA', operators); for (Reports.FilterOperator fo : filterOperatorMap.get(dataType)) { operators.add(new SelectOption(fo.getName(), fo.getLabel())); } } return dataTypeFilterOpts; } public PageReference getReportInfo() { Reports.ReportDescribeResult descRes = Reports.ReportManager.describeReport(reportId); availableColumnFilters = new List<ColumnFilter>(); for (Reports.ReportTypeColumnCategory category : descRes.getReportTypeMetadata().getCategories()) { for (Reports.ReportTypeColumn col : category.getColumns().values()) { if (col.getFilterable()) { ColumnFilter cf = new ColumnFilter( col.getLabel(), col.getName(), col.getDataType().name() ); availableColumnFilters.add(cf); } } } return null; } public String getChartFilter() { return JSON.serialize(getSelectedFilters()); } private List<ColumnFilter> getSelectedFilters() { List<ColumnFilter> selectedFilters = new List<ColumnFilter>(); for (ColumnFilter cf : availableColumnFilters) { if (String.isNotBlank(cf.operator)) { selectedFilters.add(cf); } } return selectedFilters; } public class ColumnFilter { public ColumnFilter(String lab, String col, String dt) { label = lab; column = col; dataType = dt; } // Values needed for apex:analytics component public String column { get; set; } public String operator { get; set; } public String value { get; set; } // Values need for display and operator select list public String label { get; set; } public String dataType { get; set; } } }
Thanks for the help!!
- Chad Ritchie
- January 29, 2020
- Like
- 0
- Continue reading or reply
Simple Test Class
Looking to write a test class for the following:
trigger OpportunityAmountTrigger on Opportunity (Before Insert, Before Update) {
for(Opportunity o : Trigger.New){
if(trigger.isinsert && o.amount < 5000)
o.addError('Amount can not be less than 5000');
else if (Trigger.isUpdate && o.amount < 3000)
o.adderror('Amount can not be updated to less than 3000');
}
}
Here is what I have so far, but not sure where to go from here:
@isTest
public class OpportunityAmountTriggerTest {
@isTest static void testOpportunity()
{
Integer Opportunity= Opportunity.amount(4000);
System.assertEquals('Amount can not be less than 5000', Opportunity);
}
}
- Chad Ritchie
- January 02, 2020
- Like
- 0
- Continue reading or reply
VISUALFORCE email template question
<messaging:emailTemplate subject="Rejected Kits" recipientType="Contact" relatedToType="Contact">
<messaging:htmlEmailBody >
<html>
<style type="text/css">
body {font-family: calibri; size: 11pt;}
</style>
<body>
Dear {!relatedto.First_Name__c},
<br>
<br>
The following kit request(s) were rejected:
<br>
<br>
<apex:repeat var="OPP" value="{!relatedTo.Opportunities__r}">
<table border="1">
<tr>
<td>{!OPP.name}</td> <td>{!OPP.OrderComments__c}</td>
</tr>
</table>
</apex:repeat>
<br>
<br>
Let me know if there is anything I can do to help.
<br>
<br>
Regards, Chad
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
- Chad Ritchie
- July 15, 2019
- Like
- 0
- Continue reading or reply
Creating Button on Record
Hey guys, I created a junction object, "CU", under a custom object, "Investor". The junction has a button to create a new record, which is just what we want, but how do we get that button to appear at the top of "Investor" record rather than way near the bottom as a Related Object button. Is this possible? It'd really help our users to see this New Record button at the top than at the bottom with other related object buttons.
- Chad Ritchie
- June 21, 2019
- Like
- 0
- Continue reading or reply
Visualforce Merge Field Question
I'd like to have the following formula (which pulls in a heatmap of NY from the Documents Tab)
<apex:page standardcontroller="Contact" showHeader="false">
<apex:image id="NY" value="{!'/servlet/servlet.FileDownload?file=0F01k00000002Wn'}" width="1920" height="940"/>
</apex:page>
use an if statement/merge field to verify that the record's state is actually NY. For example, I'd like in Excel terms to do if(contact.state__c = "NY", <apex:image id="NYJan19" value="{!'/servlet/servlet.FileDownload?file=0F01k00000002Wn'}" width="1920" height="940"/> ,"")
The reason being that I plan on having an image for every state so I need to merge in the record's state field so I can properly match them. Otherwise this would require 50 visualforce pages.
Thanks!!
- Chad Ritchie
- January 08, 2019
- Like
- 0
- Continue reading or reply
Weekday Formula
Here's what I have right now: MONTH( TODAY() ) + 1, 1) - 1) - 8),(IF( MONTH( TODAY() ) = 12,
DATE( YEAR( TODAY() ), 12, 31 ),
DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 1, 1) - 1) - 7))
What would the formula look like if instead of just counting 7 days down from the last day of the month, and instead count down 7 business days from the last day of the month?
Thanks!!
- Chad Ritchie
- December 19, 2018
- Like
- 0
- Continue reading or reply
Need Help with Date Formula
I would like to create a date formula that takes the last day of the current month and subtracts 7 business days from it. This part isn't too complicated to do with the Weekday function, but how would be the best way to deal with holidays. For example Christmas is right around the corner, so how could I tell this formula, without necessarily hardcoding it every year, to not ever count the 25th day of December? Here's kind of the foundation of my formula: (IF( MONTH( TODAY() ) = 12,
DATE( YEAR( TODAY() ), 12, 31 ),
DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 1, 1) - 1) - 7
but I'm not sure where to start on the Holidays issue and I haven't had much luck using the Sobject Holidays..
Thanks!!!
- Chad Ritchie
- December 19, 2018
- Like
- 0
- Continue reading or reply
Running Workflow as Another User
I have a few active workflows that look at an opportunity, if there's been no activity for 21 days, it'll send a follow up email to the Contact who owns the opportunity. In order have the email sent I have to login as another user, make a minor change on the opportunity to trigger it (usually I'll have a checkbox and do a list view so it's quick), and then the email will send from him. The problem is that everyday because there's hundreds of opportunities I have to go in there and trigger all of these opportunities as him in order for the emails to be sent. Is it possible to create a workflow/process/flow (preferrably not apex) that will automatically check each opportunities "Trigger box" as him, so then the emails automatically send as him without me ever having to go in, login as him, and manually check each opportunities "Trigger box" in a list view???
Thanks!!!
- Chad Ritchie
- December 03, 2018
- Like
- 0
- Continue reading or reply
Attaching Salesforce File to Visualforce Email
Is it possible to attach a file, a PDF that appears under the "Files" related object, to an email??? Ideally if I'm using visualforce and the email is being triggering off of a change on the Opportunity object, I'd like to send an email and attach all the files that appear under the "Files" object on that opportunity. Is this possible, and if so how difficult would this be to achieve? Thanks!!
- Chad Ritchie
- November 29, 2018
- Like
- 0
- Continue reading or reply
Visualforce Related Objects - 2 levels
THANKS!!
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<messaging:emailTemplate subject="TEST" recipientType="Contact" relatedToType="Contact" >
<messaging:htmlEmailBody >
<html>
<style type="text/css">
body {font-family: arial; size: 12pt;}
</style>
<body>
Dear {!relatedTo.Name},
<br>
<br>
<apex:repeat var="opp" value="{!relatedTo.Opportunities__r}">
<table border="0">
<tr>
<td>{!opp.Name}</td>
</tr>
</table>
</apex:repeat>
<apex:repeat var="cls" value="{!relatedTo.Opportunities__r.Closings__r}">
<table border="0">
<tr>
<td>{!cls.Name}</td>
</tr>
</table>
</apex:repeat>
- Chad Ritchie
- November 27, 2018
- Like
- 0
- Continue reading or reply
Visualforce Email Questions
So I'm new to creating Visualforce Email Templates. I'm really struggling to understand two things (and my code is below). First, where I mention Opportunity Requests below, what would the code look like to bring in a list from the opportunity object of all of their opportunities, but still have contact as the primary object. For example: Dear John Smith, here's a list of your opportunities: Opp1 Name, Opp2 Name, Opp3 Name.
So how would this work, since it's not as intuitive as merge fields, and second how would the code work so if someone has 20 Opps it looks good, and if someone has just 1 Opp it looks good, meaning not a ton of blank space. I know this is a lot to ask for, but I think if I can get down how to bring in cross-object info, similar to merge fields, and how to make info look good regardless of how many instances there are, than I'll be well on my way. THANKS so much!!!
<messaging:emailTemplate subject="Thanks for your Business" recipientType="Contact" relatedToType="Contact" >
<messaging:htmlEmailBody >
<html>
<style type="text/css">
body {font-family: arial; size: 12pt;}
</style>
<body>
Dear {!RelatedTo.Firstname},
<br>
<br>
Thank you for completing the following Opportunity Requests:
</br>
</br>
</body>
</html>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
- Chad Ritchie
- November 27, 2018
- Like
- 0
- Continue reading or reply
Nested If Not Working
This formula:
IF(AND(ISBLANK( Prospect_First_Name__c ),OR((ISPICKVAL(StageName,'Proposal Sent')),(ISPICKVAL(StageName,'Portfolio Analysis')),(ISPICKVAL(StageName,'Decision Stage')),(ISPICKVAL(StageName,'Account Implementation')))),"I wanted to follow-up and make sure you received and reviewed our proposal outlining how we might be able to provide your prospect with "+ Strategy_2__c +" solutions. Are there any other questions or concerns I can address? What are the next steps? I look forward to hearing from you,",IF(AND(NOT(ISBLANK( Prospect_First_Name__c )),OR((ISPICKVAL(StageName,'Proposal Sent')),(ISPICKVAL(StageName,'Portfolio Analysis')),(ISPICKVAL(StageName,'Decision Stage')),(ISPICKVAL(StageName,'Account Implementation')))),"I wanted to follow-up and make sure you received and reviewed our proposal outlining how we might be able to provide " + Prospect_Full_Name__c + " with "+ Strategy_2__c +" solutions. Are there any other questions or concerns I can address? What are the next steps? I look forward to hearing from you,",IF(OR(ISPICKVAL((StageName,'Open')),(ISPICKVAL(StageName,'OSG New'))),"I wanted to follow-up from our discussion to make sure I had addressed all your questions regarding available OSG solutions. Are there any concerns I can address? What are the next steps? I look forward to hearing from you,","")))
is returning a Missing Parentheses error, and I'm not sure why, it seems like everything lines up. Thanks for the help!!
- Chad Ritchie
- October 30, 2018
- Like
- 0
- Continue reading or reply
Nested If Formula Not Working
I appreciate all the help I can get,
Here's my formula :
IF(ISBLANK(IF(Length_of_Strategy_String__c <50,(LEFT( Strategy_just_used_for_update_email__c , LEN( Strategy_just_used_for_update_email__c ) - 4)),IF(AND( Length_of_Strategy_String__c >50, Length_of_Strategy_String__c <56),(LEFT( Strategy_just_used_for_update_email__c , LEN( Strategy_just_used_for_update_email__c ) - 4)),IF( Length_of_Strategy_String__c >56,(LEFT( Strategy_just_used_for_update_email__c , LEN(Strategy_just_used_for_update_email__c ) - 4)))))),IF(Length_of_Strategy_String__c <50,(LEFT( Strategy_just_used_for_update_email__c , LEN( Strategy_just_used_for_update_email__c ) - 4)),IF(AND( Length_of_Strategy_String__c >50, Length_of_Strategy_String__c <56),(LEFT( Strategy_just_used_for_update_email__c , LEN( Strategy_just_used_for_update_email__c ) - 4)),IF( Length_of_Strategy_String__c >56,(LEFT( Strategy_just_used_for_update_email__c , LEN(Strategy_just_used_for_update_email__c ) - 4))))),GAI)
And here's the error: Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 2
I know it's very close, I just can't figure out where the error's coming from.
Thanks!
- Chad Ritchie
- October 24, 2018
- Like
- 0
- Continue reading or reply
Removing Last Word of String
How could I add some logic into this formula to remove the last "and" of every string. It's a multi-select-picklist. I know how to do this in a new formula using left(len()-4) and referring to the field, but how could this be done all in this same formula field? (trying to save some syntax size) Here's the formula:
IF(INCLUDES(Strategy__c, "A"), "A, and", NULL)+ IF(INCLUDES(Strategy__c, "B"), "B, and ", NULL)+ IF(INCLUDES(Strategy__c, "C"), "C, and", NULL) + IF(INCLUDES(Strategy__c, "D"), "D, and ", NULL) + IF(INCLUDES(Strategy__c, "E"), "E, and ", NULL) + IF(INCLUDES(Strategy__c, "F"), "F, and ", NULL) + IF(INCLUDES(Strategy__c, "G"), "G, and", NULL) + IF(INCLUDES(Strategy__c, "H"), "H, and" NULL) + IF(INCLUDES(Strategy__c, "I"), "I, and ", NULL) + IF(INCLUDES(Strategy__c, "J"), "J, and ", NULL) + IF(INCLUDES(Strategy__c, "K"), "K, and ", NULL) + IF(INCLUDES(Strategy__c, "L"), "L, and ", NULL) + IF(INCLUDES(Strategy__c, "M"), "M, and ", NULL) + IF(INCLUDES(Strategy__c, "N"), "N, and ", NULL) + IF(INCLUDES(Strategy__c, "O"), "O, and ", NULL) + IF(INCLUDES(Strategy__c, "P"), "P, and ", NULL)
Thanks!!
- Chad Ritchie
- October 23, 2018
- Like
- 0
- Continue reading or reply
WritingTestClass
trigger SumPositions on Investor__c (before insert, before update, before delete) {
for (Investor__c record : Trigger.new) {
record.Sum_of_Positions__c = null;
}
for(AggregateResult result: [SELECT SEI_Investor_Id__c, SUM(Position__c.Balance__c)
FROM Position__c WHERE SEI_Investor_Id__c
IN :Trigger.newMap.keyset() GROUP BY SEI_Investor_Id__c]) {
Trigger.newMap.get(result.get('SEI_Investor_Id__c')).Sum_of_Positions__c = (Decimal)result.get('expr0');
}
}
- Chad Ritchie
- July 31, 2018
- Like
- 1
- Continue reading or reply
Basic Visualforce DataTable Filter
Does anyone know how I could add a simple filter to both of these datatables?
For example the first one I'd like to add a filter allowing only balances__c>0 only.
I'm using a standard controller, and would ideally like to avoid using a custom controller to solve this.
<table>
<tr>
<td>
<apex:dataTable value="{!Contact.Positions__r}" var="b" rules="all" columns="3" columnsWidth="250px,250px" align="left"
columnClasses="columnBorders" headerClass="dataTableHeader" cellpadding="5px" cellspacing="0">
<apex:column value="{!b.Product__r.Name}" headerValue="Product" />
<apex:column value="{!b.Name}" headerValue="Account Name"/>
<apex:column value="{!b.Balance__c}" headerValue="Balance"/>
</apex:dataTable>
</td>
<td>
<apex:dataTable value="{!Contact.Transactions__r}" var="b" rules="all" columns="3" columnsWidth="250px,250px" align="left"
columnClasses="columnBorders" headerClass="dataTableHeader" cellpadding="5px" cellspacing="0">
<apex:column value="{!b.Product__r.Name}" headerValue="Product" />
<apex:column value="{!b.Investor_Account_Name__c}" headerValue="Account Name"/>
<apex:column value="{!b.Gross_Amount__c}" headerValue="Gross Amount"/>
</apex:dataTable>
</td>
</tr>
</table>
Thanks!
- Chad Ritchie
- May 14, 2020
- Like
- 0
- Continue reading or reply
Sorting DataTable in Visualforce
I have a pretty simple dataTable in Visualforce (see code below), I'm just trying to figure out how to sort by {!b.Balance__c}
I've tried a number of things, but none of them seem to work.
Thanks!!!
<apex:pageBlock >
<apex:dataTable value="{!Contact.Positions__r}" var="b" width="100%" columns="1" columnsWidth="60%,40%">
sortorder = "{!b.Name}"
<apex:column >
<apex:outputText value="{!b.Product__r.Name}"/>
</apex:column>
<apex:column >
<apex:outputText value="{!b.Name}"/>
</apex:column>
<apex:column style="text-align:right" headerClass="CurrencyElement">
<apex:outputField value="{!b.Balance__c}"/>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
- Chad Ritchie
- May 14, 2020
- Like
- 0
- Continue reading or reply
prevent sharing via case team
Now I need to prevent users who don't have this profile from being able to access the records. I've done what I can with OWDs, profiles, sharing button (removed the button from the page layout for this record type), but now I'm trying to figure out how I can block access via the case team.
I have a case open with salesforce and the support rep recommended creating a VFpage for the record type. I don't code so I'm trying to figure out what all of the options are before we try to bring on outside resources. A validation rule isn't possible. I could remove the case team related list from the page layout but I feel like someone might want to add a team member some day. I did see the trailhead for 'with sharing' here (https://trailhead.salesforce.com/en/content/learn/modules/data-leak-prevention/identify-and-prevent-sharing-violations). I don't really understand it but am trying to at least understand if it might be a possible solution. Also I have had to create a trigger in the past to block users from deleting opportunity products. I'm wondering if I could do the same for this. Create a trigger that will block sharing for this record type with all users who don't have a particular word in their profile name.
I'm really bummed that this is so complicated :/
Thanks in advance for your help!
- Julie Curry
- January 29, 2020
- Like
- 0
- Continue reading or reply
Visualforce Page for Filtering Reports
I'm trying to embed a Visualforce Page onto my home page that allows users to select a report and filter it right there.
When running I seem to be getting the following error:
caused by: System.NullPointerException: Attempt to de-reference a null object
Class.AnalyticsController.getSelectedFilters: line 69, column 1
Class.AnalyticsController.getChartFilter: line 64, column 1
Can anyone identify what's causing this issue? I notice this code was written for API Ver 29, while I'm on 48.
Visualforce Page:
<apex:page controller="AnalyticsController"> <style> label { font-weight: bold; } #filters { overflow: hidden; width: 100% } #filterBox { float: left; align: center; padding: 5px 5px 5px 0px; } </style> <apex:form > <apex:outputLabel value="Select Report"/> <apex:selectList value="{!reportId}" multiselect="false" size="1"> <apex:selectOptions value="{!availableReports}"/> </apex:selectList> <apex:commandButton action="{!getReportInfo}" value="Get Report Filters" reRender="report"/><br/> <apex:outputPanel id="report" layout="block"> <apex:outputPanel rendered="{!reportId != null}"> <div id="filters"> <apex:repeat value="{!availableColumnFilters}" var="colFilter"> <div id="filterBox"> <apex:outputLabel >{!colFilter.label}</apex:outputLabel><br/> <apex:selectList value="{!colFilter.operator}" size="1" multiselect="false" style="width: 100px;"> <apex:selectOption itemLabel="--None--" itemValue=""/> <apex:selectOptions value="{!availableDataTypeFilterOperators[colFilter.dataType]}"/> </apex:selectList> <apex:inputText value="{!colFilter.value}"/> </div> </apex:repeat> </div> <apex:commandButton value="Get Chart with Filters" reRender="chart"/><br/> <apex:outputPanel layout="block" id="chart"> <analytics:reportChart reportId="{!reportId}" filter="{!chartFilter}"/> </apex:outputPanel> </apex:outputPanel> </apex:outputPanel> </apex:form> </apex:page>
Controller:
public with sharing class AnalyticsController{ public List<SelectOption> availableReports { get; set; } public Id reportId { get; set; } public Map<String, List<SelectOption>> availableDataTypeFilterOperators { get; set; } public List<ColumnFilter> availableColumnFilters { get; set; } public AnalyticsController() { availableReports = retrieveAvailableReports(); availableDataTypeFilterOperators = retrieveAvailableDataTypeFilterOperators(); } public List<SelectOption> retrieveAvailableReports() { List<SelectOption> reptOpts = new List<SelectOption>(); for (Report r : [ Select Id, Name From Report Where Format In ('Summary','Matrix') Order By Name ]) { reptOpts.add(new SelectOption(r.Id, r.Name)); } return reptOpts; } public Map<String, List<SelectOption>> retrieveAvailableDataTypeFilterOperators() { Map<String, List<SelectOption>> dataTypeFilterOpts = new Map<String, List<SelectOption>>(); Map<String, List<Reports.FilterOperator>> filterOperatorMap = Reports.ReportManager.getDataTypeFilterOperatorMap(); for (String dataType : filterOperatorMap.keySet()) { List<SelectOption> operators = new List<SelectOption>(); // Append _DATA to match ColumnDataType from ReportTypeColumn dataTypeFilterOpts.put(dataType.toUpperCase() + '_DATA', operators); for (Reports.FilterOperator fo : filterOperatorMap.get(dataType)) { operators.add(new SelectOption(fo.getName(), fo.getLabel())); } } return dataTypeFilterOpts; } public PageReference getReportInfo() { Reports.ReportDescribeResult descRes = Reports.ReportManager.describeReport(reportId); availableColumnFilters = new List<ColumnFilter>(); for (Reports.ReportTypeColumnCategory category : descRes.getReportTypeMetadata().getCategories()) { for (Reports.ReportTypeColumn col : category.getColumns().values()) { if (col.getFilterable()) { ColumnFilter cf = new ColumnFilter( col.getLabel(), col.getName(), col.getDataType().name() ); availableColumnFilters.add(cf); } } } return null; } public String getChartFilter() { return JSON.serialize(getSelectedFilters()); } private List<ColumnFilter> getSelectedFilters() { List<ColumnFilter> selectedFilters = new List<ColumnFilter>(); for (ColumnFilter cf : availableColumnFilters) { if (String.isNotBlank(cf.operator)) { selectedFilters.add(cf); } } return selectedFilters; } public class ColumnFilter { public ColumnFilter(String lab, String col, String dt) { label = lab; column = col; dataType = dt; } // Values needed for apex:analytics component public String column { get; set; } public String operator { get; set; } public String value { get; set; } // Values need for display and operator select list public String label { get; set; } public String dataType { get; set; } } }
Thanks for the help!!
- Chad Ritchie
- January 29, 2020
- Like
- 0
- Continue reading or reply
Creating Button on Record
Hey guys, I created a junction object, "CU", under a custom object, "Investor". The junction has a button to create a new record, which is just what we want, but how do we get that button to appear at the top of "Investor" record rather than way near the bottom as a Related Object button. Is this possible? It'd really help our users to see this New Record button at the top than at the bottom with other related object buttons.
- Chad Ritchie
- June 21, 2019
- Like
- 0
- Continue reading or reply
Need Help with Date Formula
I would like to create a date formula that takes the last day of the current month and subtracts 7 business days from it. This part isn't too complicated to do with the Weekday function, but how would be the best way to deal with holidays. For example Christmas is right around the corner, so how could I tell this formula, without necessarily hardcoding it every year, to not ever count the 25th day of December? Here's kind of the foundation of my formula: (IF( MONTH( TODAY() ) = 12,
DATE( YEAR( TODAY() ), 12, 31 ),
DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 1, 1) - 1) - 7
but I'm not sure where to start on the Holidays issue and I haven't had much luck using the Sobject Holidays..
Thanks!!!
- Chad Ritchie
- December 19, 2018
- Like
- 0
- Continue reading or reply
Running Workflow as Another User
I have a few active workflows that look at an opportunity, if there's been no activity for 21 days, it'll send a follow up email to the Contact who owns the opportunity. In order have the email sent I have to login as another user, make a minor change on the opportunity to trigger it (usually I'll have a checkbox and do a list view so it's quick), and then the email will send from him. The problem is that everyday because there's hundreds of opportunities I have to go in there and trigger all of these opportunities as him in order for the emails to be sent. Is it possible to create a workflow/process/flow (preferrably not apex) that will automatically check each opportunities "Trigger box" as him, so then the emails automatically send as him without me ever having to go in, login as him, and manually check each opportunities "Trigger box" in a list view???
Thanks!!!
- Chad Ritchie
- December 03, 2018
- Like
- 0
- Continue reading or reply
Attaching Salesforce File to Visualforce Email
Is it possible to attach a file, a PDF that appears under the "Files" related object, to an email??? Ideally if I'm using visualforce and the email is being triggering off of a change on the Opportunity object, I'd like to send an email and attach all the files that appear under the "Files" object on that opportunity. Is this possible, and if so how difficult would this be to achieve? Thanks!!
- Chad Ritchie
- November 29, 2018
- Like
- 0
- Continue reading or reply
Visualforce Related Objects - 2 levels
THANKS!!
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<messaging:emailTemplate subject="TEST" recipientType="Contact" relatedToType="Contact" >
<messaging:htmlEmailBody >
<html>
<style type="text/css">
body {font-family: arial; size: 12pt;}
</style>
<body>
Dear {!relatedTo.Name},
<br>
<br>
<apex:repeat var="opp" value="{!relatedTo.Opportunities__r}">
<table border="0">
<tr>
<td>{!opp.Name}</td>
</tr>
</table>
</apex:repeat>
<apex:repeat var="cls" value="{!relatedTo.Opportunities__r.Closings__r}">
<table border="0">
<tr>
<td>{!cls.Name}</td>
</tr>
</table>
</apex:repeat>
- Chad Ritchie
- November 27, 2018
- Like
- 0
- Continue reading or reply
Nested If Formula Not Working
I appreciate all the help I can get,
Here's my formula :
IF(ISBLANK(IF(Length_of_Strategy_String__c <50,(LEFT( Strategy_just_used_for_update_email__c , LEN( Strategy_just_used_for_update_email__c ) - 4)),IF(AND( Length_of_Strategy_String__c >50, Length_of_Strategy_String__c <56),(LEFT( Strategy_just_used_for_update_email__c , LEN( Strategy_just_used_for_update_email__c ) - 4)),IF( Length_of_Strategy_String__c >56,(LEFT( Strategy_just_used_for_update_email__c , LEN(Strategy_just_used_for_update_email__c ) - 4)))))),IF(Length_of_Strategy_String__c <50,(LEFT( Strategy_just_used_for_update_email__c , LEN( Strategy_just_used_for_update_email__c ) - 4)),IF(AND( Length_of_Strategy_String__c >50, Length_of_Strategy_String__c <56),(LEFT( Strategy_just_used_for_update_email__c , LEN( Strategy_just_used_for_update_email__c ) - 4)),IF( Length_of_Strategy_String__c >56,(LEFT( Strategy_just_used_for_update_email__c , LEN(Strategy_just_used_for_update_email__c ) - 4))))),GAI)
And here's the error: Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 2
I know it's very close, I just can't figure out where the error's coming from.
Thanks!
- Chad Ritchie
- October 24, 2018
- Like
- 0
- Continue reading or reply
Choosing first instance of substitution formula
I'm trying to figure out how to get this formula to work on just the first ",and" and not the second. Here's what I have: Chad, and Chris, and Sean.
I would like it to return Chad, Chris, and Sean by simply replacing ", and" with ",". And keep in mind that sometimes it brings back 1 name, sometimes 2, and sometimes 3, so I'd like to apply for each of those. Here's what I have now: SUBSTITUTE(LEFT(test__c, 40),", and",",") but unfortuntely this always does it to both instances so it will return Chad, Chris, Sean, instead of adding an and after Chris. Any help is appreciated!!! I know this is really easy in excel because you can indicate the instance that you want it to apply to, but not sure about doing this on Salesforce. Thanks guys!!
- Chad Ritchie
- October 19, 2018
- Like
- 0
- Continue reading or reply
Merging Picklist Value into Formula
Hey guys,
What's the syntax to use for a picklist value in order to have that value merge into a formula? So that way I see the value of the field, and not just the field's name. Thanks!!
- Chad Ritchie
- October 18, 2018
- Like
- 0
- Continue reading or reply
Merge Fields Not Working In Text Formula
I've created this formula, which will go in an email template and basically serve as the whole email. Unfortunately, the formula just keeps bringing back the field name, and not the value of the field. There's a small piece of my formula below, what I'd like is for the name of the Sales Professional to come in, but unfortunately every time I send myself an email, using this formula, the only thing that comes back is the name of the field, not the person. Any idea why this might be happening? (And I've tried to put the field in brackets, and a number of other formats, but still no luck. Thanks!!!
IF(AND(ISBLANK( Prospect_First_Name__c ),ISPICKVAL(StageName,'Proposal Sent')),"Dear SalesProfessional__r.Full_Name__c , I wanted to follow-up and make sure you received and reviewed our proposal.
- Chad Ritchie
- October 18, 2018
- Like
- 0
- Continue reading or reply