As a Salesforce admin, I like to not just learn about new technologies but to apply them to solving real life problems. Tinkering around with generative AI, I’ve come up with some helpful hacks to deal with some common challenges related to Apex code and data tasks, we well as the somewhat less common use case of knowledge migrations.
You can apply these hacks directly or to use them as inspiration for your own ideas for solutions that help you work smarter rather than harder and get more done in less time.
AI for fun
The company that made generative AI a household term is OpenAI. It’s the company that made it possible to generate images based on description with DALL·E 2 and the one that got everyone to try their hand at prompts for ChatGPT.
It was one of those prompts that drew my attention. Someone gave ChatGPT a prompt to write a transcript of a debate between Barack Obama and a donut. For this scenario, Obama was aware the donut isn’t sentient, though the audience thinks it is.
The debate proceeded back and forth with Obama saying things and a line for the donut remaining silent. Though the donut never said anything, the audience would still applaud and cheer for it, prompting an exasperated Obama to point out that it’s not even alive
I thought that was a pretty creative output and was intrigued by the possibilities of these tech. I started playing around with it, experimenting with a bunch of different random stuff.
Experiments and brainstorming
I then shifted to try out applications that could help other people I know. For example, my sister likes to write stories that feature character development. I worked out a way to use ChatGPT to generate ideas for her.
Generative AI can be very helpful as a brainstorming tool. It functions like a feedback loop; you take the first output and then ask it to expand on the idea.
That made me think of other possibilities where brainstorming is helpful. Even in our work as Salesforce admins, when we’re working on things like new product launches or designing solutions for feature requests, brainstorming can be a powerful tool.
If you don’t always have someone available, being able to chat with the bot can be helpful for sparking new ideas. There are lots of ways you could use ChaGPT in this way. You can modify how you ask the same thing based on original output or take a piece you like and ask different questions about it.
AI for Apex coding
When I saw that some people started using ChatGPT to do technical stuff, I thought: “I wonder if it knows Apex.” That would really help me for work.
Apex is a programming language that Salesforce developed. While it’s based on Java, it’s not one of the top programming languages out there. I wasn’t sure ChatGPT would be able to write or understand Apex, but it turned out it does.
That capability is a game-changer for users of Salesforce who have to deal with Apex code.
A lot of businesses have had to have Salesforce developers write code for their CRMs to meet specific needs. As a result, they often find that they have inherited code in the system that remains in place even after the developer who wrote it may have moved on from that company.
In the absence of the developer who wrote the code, you may need to hire another one just to tell you what the code does. But now you can use ChatGPT for that.
You can copy pieces of code that were written for your system and paste it into the prompt to have the chat describe it for you. So if you don’t know how to read Apex, it can help decipher the intent and function of the code. It’s not always perfect, but it’s still very helpful for those of us who work with Salesforce.
When you want to go with the Flow
A common scenario is that the business has a need to modify a Salesforce function that was set up in Apex code some years back. That can easily happen due to shifts in business process or strategy.
It’s possible that the developer who built out the requirements didn’t document the code. Now when a new manager steps in, she doesn’t know what the code is doing but can’t just deactivate in case it’s doing something essential that they’re not aware of.
The only viable alternative in the past was to hire someone proficient in Apex just to modify the code. But now it’s possible for a Salesforce admin who can at least find what Apex is running to take pieces of the code and get a plain English description of what it does.
Once the admin has established what the Apex code directs the system to do, it’s possible to shift those functionalities into Flows, which have and continue to become more featured and cover use cases that were previously only available via Apex. That’s one of the ways I’ve used it – to understand pieces of code.
Salesforce Flows can do more and more things over time. But they still can’t do everything, and that’s why there’s still a need for code.
Cracking the code
Senior admin typically know a bit of code. I’m able to read and understand code, though it takes a lot of time and I would struggle to write it from scratch.
Now those of us who have some familiarity with Apex but are not trained Salesforce developers can use the chatbot to write the Apex code we need based on plain English descriptions. Using ChatGPT, I can take a piece of code and modify it to do something slightly different.
This functionality is also helpful to generate code you need with comments in line that will document what the code does. That means that when someone else takes over, they don’t have to puzzle over what the code does; it will all be recorded.
This function is also of value for developers who could use the tool to save time to come up with the infrastructure part of the code. They would then have to spend less time on the more boring, mundane tasks (or the documentation that tends to get neglected) and spend more time on the fun stuff.
Easier quota planning
A common data task for Salesforce admins is loading sales quotas. The business typically gives the data for it in a matrix format that then has to be manipulated in order to load it into Salesforce. AI chatbots can help write excel macros (VBA code) to manipulate the matrix data into a flat file that can save admins time when loading quota data.
In many businesses, sales leadership plan out their quotas a year at a time. That can get complicated with multiple factors involved like the quantity of products they aim to sell as well as the dollar amount set for a specific time frame.
When the quotas have to be further broken down into various product lines and families, it grows even more complex. The amount of data Salesforce has to track gets bigger and bigger with more products, more people, and longer time frames.
All that data has to be uploaded in the appropriate format in Salesforce. Doing that manually is tedious and time-consuming, so I used ChatGPT to come up with a script that would transform it into a more usable format automatically.
The way I wrote the prompt with specific ranges, I had only expected it to work for this one case. In fact, the output was better than what I had expected for my input because it is more general and would work for any amount of data in the sheet.
For the one task that inspired me to create the script, I saved about an hour. But over the course of a year of filling up quotas for sales people, I’ll be able to reuse this multiple times and save many hours.
That’s not to say that you can just sit back and leave the driving to ChatGPT. It doesn’t do everything for you. You do have to have some level of technical capability to take advantage of the automation enabled by generative AI.
In the case of what I did, I had to understand how to load the VBA code into an Excel workbook and run it as a macro. It isn’t that hard and is quick to learn and worth it to save you time.
As you can see from the illustration of my prompt and response, you can always scrub client data out before feeding in the prompt. You ask a general question based on the structure rather than specific client data.So there is no danger of confidential company info going into OpenAI.
Pulling smaller files from ZIP files
You may find yourself in the situation I faced. My client had acquired different companies – all with their own Salesforce orgs and sought to merge them into a single Salesforce org.
One part of that project was knowledge base migration/consolidation. That called for bringing articles hosted in separate Salesforce orgs with embedded images into a single, unified system.
The challenge here is translating the components of ZIP files. When you extract articles from a Salesforce Knowledge base that have HTML and images, it gives you a ZIP file that contains article details in a csv, html files for the article bodies, and the images in a subfolder structure.
When you extract it from Salesforce, you get one ZIP file with all the individual files and folders that can contain thousands of images across hundreds of articles. But when you have to load it into the knowledge base, that ZIP folder – with thousands of images – has to be broken down into individual files under a certain size, or else the import articles tool will error out .
Other than manually setting up the smaller folders what can you do? If you know Python, then you can write scripts that work directly with the files and directories on your OS.
But what if you’re not adept at Python? Now you can use AI to write something in Python to read from the larger directory and put the right files into the right structure into a smaller folder that meets the size limit requirements.
I found Python code on Stack Exchange and figured it out myself in the recent past before I knew about ChatGPT’s capability. Had I known about it, I could have saved myself a lot of time by writing targeted scripts for ChatGPT to provide the code I needed, or at least to get very close.
Instead of having to copy and paste into search and then pasting into another file manually, the code could do that and save many hours of manual work. In other words, I can now zip through the work of extracting key information from ZIP files.
Playing in Salesforce sandboxes
When it comes to trying out something new in production, the best practice is to test it out in a sandbox before going live. Salesforce offers different types of sandboxes for this: full, partial, developer pro, and developer.
A full sandbox gives users a complete copy of what’s in your production environment including all of the data. But most people don’t have that.
Most purchase an edition that comes with a partial sandbox that takes a snapshot of some of the data but not all of it. The drawback of that is that sometimes you can’t properly test with only partial data because the underlying data is necessary to see the same functionality that exists in production.
Developer sandboxes can be refreshed every day, but the fact that they don’t come with any data means that you have to create test data to run automations that mimic what’s in production without throwing a ton of errors or functioning unexpectedly.
When you need to create data for testing, you can save time by running an Apex class when refreshing the developer sandbox. That’s difficult to do for people who are not trained as Salesforce developers.
But now it’s possible to use ChatGPT to write the Apex class to seed the sandbox with test data. You merely have to describe the objects that need data seeded for the sandbox to get it generated by the AI. ChatGPT already knows about many of the standard objects and standard fields they contain, so that can save you even more time!
That capability means you can create all of these relationships in the requisite hierarchies without having to do those iterative data loads. The result of this is loads of saved time on the tasks surrounding testing.
Making communication more effective
We technical people naturally use technical terms that are not always fully understood by business people. How handy would it be to have a sort of Babel Fish on hand to translate for you?
That’s one of the things you can do with generative AI. give it a prompt that says “Give me a more simplified version of this to eliminate the complexity that business users wouldn’t care about or understand.”
In general, you can tell it “TLDR” for long messages to get a simplified summaries of complex descriptions. It can also break out long text requirements into user stories and or a table that categorizes information within requirements docs
You can also use it to structure and format information to meet different needs for different audiences. For example, it can convert meeting notes into summaries or turn a summary into bulleted note points.
There are lots of different things you could do with it. If you just want it to clean up grammar mistakes, it can do that, too.
Have you experimented with generative AI to help you out with Salesforce tasks yet? I’m always happy to learn more.
Learn more about working smarter with Salesforce by subscribing to the Delegate blog.
About The Author: Kyle Hegland
More posts by Kyle Hegland