.ultrageek. Computers, Music, and Thoughts

12Dec/180

Silly Admin Trick: How to Access Salesforce “Platform Integration User” Profile

While trying to disable a record type I got the following message:

This Record type Record_Type_Name Cannot be deactivated because of the following profiles use this record type as default.

Upon clicking the profile "Platform Integration User" I get the "Insufficient Privileges", so sad.

Looking at the article linked below I put this URL together to access the profile record type page:

https://<Instance_Name>/setup/ui/profilerecordtypeedit.jsp?id=<Profile_Id>&tid=<Object_API_Name>

Where object name is WorkOrder or Opportunity or Customer_Object__c. Pretty straight forward and saved me a ton of time. Previous to this fixed I clicked in to the critical profiles and disabled the record type, too much clicking!

Here's the article: https://success.salesforce.com/answers?id=90630000000hNDeAAM

31Jul/180

Silly Admin Trick: Random Character Generator

Sometimes what is so easy in other languages and scripting tools can be a real pain in Apex and Formula Fields. I am talking about random character generation. Not sure why this is not a method but have used this trick a couple of times and in doing some reading it actually taking about 1/10 the computing power to generate versus creating a long string of characters and randomly picking out of it which seems to be a popular programing pattern.

Blob blobKey = crypto.generateAesKey(128);
String updateKey = EncodingUtil.base64encode(blobKey);
updateKey = updateKey.left(10);

Quick easy and simple. I added the third line to get a more manageable size of code but it's a great way to stamp a key on records when doing parent/child updates where you want to make sure that all the records are actually getting updated.

And as always this is the source URL: https://salesforce.stackexchange.com/a/99390

Internet started as a place of knowledge, I'm just paying it forward.

Tagged as: No Comments
25Jul/180

Wave / EA: Counting the number of weeks, months, days, etc. in SAQL

This was for some reason harder than it should have been. Needed to create the number of weeks from the beginning of the year to today. Re-posting this really because there are not a lot of examples out on the web.

date_diff("week",toDate("2018-01-01","yyyy-MM-dd"), now()) as 'YearlyGoal'

I will go back later to make the start of the year to be dynamic but for now this will do. Also watch out for this quote: “ instead of " in the examples. It will total throw an error that will point you in the wrong direction.

Love Wave and EA but wish their community was more open like StackExchange, searching is dreadful and requires a login but this was the article that I used to troubleshoot: https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000009MBPCA2&fId=0D53A00003dGrNGSA0

 

Tagged as: , No Comments
18Jul/180

Silly Admin Trick: Removing Carriage Returns from Long Text Fields

Recently had a project to use Jitterbit to query and pull data out of Salesforce.com in to a CSV file to import in to another system. All great and fine except long text fields with carriage returns were wrecking the CSV. This simple fix was all that was needed:

Replace(root$transaction.response$body$queryResponse$result$records.Account$BillingStreet$,'\n','');

Got it right off the support site linked below. Just changed up the field with the field I was using and re-ran, success!

https://getsatisfaction.com/dataloader/topics/exporting_data_how_do_i_remove_the_carriage_return_within_the_street_address_field

9Mar/180

Too many SOQL queries: 101 even when using testSetup

I am a huge fan of creating global test classes within Salesforce that leverage one testSetup section to set up the data that then can be used many times to test the many different methods and classes. Gone are the days of having a million test classes to manage and update every time changes are made in the system. I've been using this for over a year and as my classes have continued to grow in size and complexity I have run against one limitation that I was unaware of until recently. DML limits are reset when using testSetup but not SOQL limits. Specifically if when you insert a record if that DML generates SOQL statements, which I have a lot of code that relates and joins data, that limit is passed on to the test methods. I think because my test classes are segmented in to major functions I was not running in to a lot of overlap.

In reading the below StackExchange answer it is clear now that all of my test methods need to use Test.startTest() and Test.stopTest(). I always use these methods for scheduled or future class testing but now it is clear that I should be more diligent in always using them.

The tasty bits:

NOTE: If your org has events that are triggered from that INSERT (which you likely do), THEN any DML or SOQL statement that proceeds from those are considered outside the context of @testSetup and will impact your overall governing limits for your test class.

As always these limits are reset within any test method when you invoke Test.startTest(); and Test.stopTest(); but this could affect how much data you can setup within your data setup method (for example when cascading dependencies like Contacts, which need Accounts).

https://salesforce.stackexchange.com/a/73130

14Feb/180

Silly Admin Trick: List of all Objects

Do the following to get a list of Objects by their API names:

  1. Pop in to Workbench
  2. Run the following query:SELECT SobjectType FROM ObjectPermissions
  3. Click Bulk CSV to download
  4. Click the query button to execute
  5. Open in Excel and Dedupe

A quick and easy way to generating a list for creating backups using 'Backup-force.com': https://github.com/neowit/backup-force.com

6Feb/180

Backing up Salesforce.com Meta Data on a Mac

There are a couple solutions both paid and free for backing up your Salesforce.com Metadata in addition to using an IDE like Eclipse.

If you need something 'free' and on a schedule the best solution I have found has been:

Alan Morey's Force Meta Backup

To use this tool though there's a couple of prereq's that have to be loaded:

  • Java Runtime (JRE)
  • Apache Ant
  • Groovy

I have used this solution for years and Window's has been my go to in the past due to usually using a VM...

So how to do this easily and quickly on a Mac?

Install the following: Home Brew which is a package manager for MacOS X

Once installed run the following commands (assuming you have admin to your machine):

  • brew cask install java
    • This will install the Java JRE
  • brew install ant
    • This installs Ant
  • brew install groovy
    • This installs...groovy

Now you just need to:

  • Download and Unzip the Force-Meta-Backup from the link above
  • Make a copy of the build.sample.properties file
  • Rename build.sample.properties to build.properties
  • Edit build.properties
  • Add username and password
  • Validate Production or Sandbox
  • Run the following command: ant backupMetadata

This will create a folder called 'Build' which is where all of your Salesforce.com instance metadata will get backed up to. My recommendations when automating is to only zip up (7zip of course) the folders you need as you will get documents folder which can be a bit hefty to archive constantly.

30Jan/180

Silly Admin Trick: Finding Active ‘Frozen’ Users in Salesforce.com

One gap with freezing users in Salesforce.com is the ability to go back and find those users. Google is your friend for finding the answer. There's even an article from Salesforce: How can I tell what Users are Frozen via the API?

The below is my take on it. Use workbench/bulk/csv to create an exportable list that you can action.

 

Tagged as: , , , No Comments
30Jan/180

Clicking Link in Email Opens Blank Chrome Tab

Restart Chrome...it has an update that has been applied. Click Help -> About to validate but this issue drove me nuts and since I work on a Mac that only needs rebooting when the VPN crashes (1-4 weeks) I was periodically suffering through this one. It is amazing how long you can deal with a problem until you finally have had enough and google it.

Filed under: Knowledge, Stupid No Comments
6Dec/170

Find the API Name from the Field Label

I recently had a use case where I was going to take a drop down value and use that to pull a value from a separate lookup object. I would have "Hourly" and my logic would return "Hourly__c" which I could then use dynamic SOQL and sObjects to do some magic. I did not want to use hardcoded values or a custom setting lookup table and I thought it would be easy to query the metadata...which turned out to be strangely harder than I thought it would be so here is a working solution:

There are a lot of examples of getting the Label from the API name but not really the other way around.