Developers / Artificial Intelligence

Can ChatGPT Replace a Salesforce Developer?

By Andrew Cook

ChatGPT, the AI chatbot that uses natural language processing to interact with you, has been a revelation since its inception in late 2022.

So what does ChatGPT mean for jobs in the Salesforce ecosystem? In this post, I’ll explore this question as it relates to what is quite possibly the largest role to be impacted by AI: the Salesforce Developer.

What Is a Salesforce Developer?

A Salesforce Developer is a professional who specializes in developing applications and customizing the Salesforce platform to meet specific business needs. Developers have expertise in Salesforce technologies, programming languages, and development methodologies.

Some key aspects of this role include customization and configuration, stakeholder management, Apex development, Visualforce and Lightning Component Development, integrations, testing and debugging, and the Salesforce Development Lifecycle.

READ MORE: Salesforce Developer Interview Questions & Answers

How Could AI Impact These Areas?

Customization and Configuration

This area is normally taken care of by admins, but it is something that developers can also delve into. This isn’t something that will be impacted by ChatGPT for the most part; an admin or a developer may ask ChatGPT how to perform a specific configuration task, but they will still need to perform the task in question.

There is a possibility that this may change when Salesforce releases Einstein GPT, as it is much more tightly integrated with the platform.

Apex Development/Visualforce and Lightning Component Development

Potentially, this is one of the biggest things to be impacted by AI… ChatGPT has the potential to write code for you.

Context is a massive issue here. For example, you may be working in an org that already has some custom Apex code and Visualforce/Lightning Component customization. You could ask ChatGPT to create an Apex class/Lightning component to do a certain task. However, this code will not take into consideration any of the other code already in your org.

So, to ChatGPT, the code will look absolutely fine, but when it comes to the code actually working in your org, the results may be very different and you could see issues just trying to push your code into production.

Again, this may change when Salesforce releases Einstein GPT, as the model will be trained on your existing code base and will be able to write better code for you.

It could, however, be used to help you improve code that has already been written. You may have an Apex Trigger which includes some logic that ideally should be in its own Apex Class. You could ask ChatGPT to help in rewriting this code so that it adheres more to Salesforce best practices. Or you may have an existing Aura Component that you would like to convert to a Lightning Web Component – if so, ChatGPT could also help with this.

For example, I have the following Apex Trigger which has a lot of logic built into it. If I were to follow best practices, this Trigger should be logic-less and the logic should instead be within an Apex Class. This is something ChatGPT can assist with.

Apex Trigger:

trigger AccountTrigger on Account (before insert, before update) {
    for (Account newAccount : Trigger.New) {
        if (String.isBlank(newAccount.Industry)) {
            newAccount.Industry = ‘Construction’;
        }
        if (String.isBlank(newAccount.AccountSource)) {
            newAccount.AccountSource.addError(‘The Account Source is required.’);
        }
    }
    if (Trigger.isBefore &&
        Trigger.isUpdate) {
        for (Account newAcct : Trigger.New) {
            Account oldAcct = Trigger.oldMap.get(newAcct.Id);
            if (String.isBlank(oldAcct.AccountNumber) &&
                String.isNotBlank(newAcct.AccountNumber)) {
                newAcct.Type = ‘Customer - Direct’;
            }

I can then give ChatGPT the following prompt:

I have the following Apex Trigger, could you move the logic into an Apex Class and amend the Apex Trigger to not include any logic, as per Salesforce best practices?

As you can see, not only has ChatGPT helped me move the logic into an Apex Class, it has also given an explanation on how it has achieved this.

Stakeholder Management

I’m sure that many of us would love ChatGPT to manage and communicate with our stakeholders, but this just isn’t plausible. I’ve lost count of the number of times I’ve been given a set of requirements by a stakeholder, but what they want to achieve is completely different to what they’ve written. Being able to communicate this to a stakeholder and make them understand is a real art form – one that ChatGPT won’t be able to understand.

On the other hand, if you have a well-written user story that you need to summarize for someone, this is something ChatGPT can absolutely help with. For example, I have the following user story:

As a Salesforce Developer, I want to create an Apex Class that runs on the Account object and updates a field on any related Contacts. This will allow me to automate the process of propagating changes made to certain fields in the Account object to the associated Contacts.

User Story:

As a Salesforce Developer,
I want to create an Apex Class called “AccountContactUpdater”
So that I can update a specific field on related Contacts when changes are made to the Account object.

Acceptance Criteria:

  1. When changes are made to specific fields (e.g. Account Name or Account Status) on the Account object, the Apex Class should trigger and initiate the update process on related Contacts.
  2. The Apex Class should run in real-time or near real-time, ensuring that the related Contacts are updated promptly.
  3. The Apex Class should update a custom field (e.g. “Account_Status__c”) on the related Contacts with the corresponding value from the updated Account field.
  4. The Apex Class should handle bulk updates efficiently, processing a large number of Account records and updating the associated Contacts accordingly.
  5. The Apex Class should be configurable and reusable, allowing the Salesforce administrators to specify the fields to be monitored for changes on the Account object, as well as the field to be updated on the Contacts.
  6. Proper error handling should be implemented in the Apex Class to handle any potential exceptions or failures during the update process.
  7. The Apex Class should be thoroughly tested to ensure its accuracy, reliability, and performance.
  8. Detailed documentation should be provided, including clear instructions on how to deploy, configure, and use the Apex Class.

Additional Considerations:

  • The Apex Class should adhere to Salesforce best practices and coding standards.
  • Governor limits should be taken into account to ensure the efficient use of resources and avoid hitting any limitations.
  • The Apex Class should be version-controlled to manage changes and facilitate collaboration among developers.
  • Continuous integration and deployment processes should be implemented to streamline the development and deployment lifecycle.

I then asked ChatGPT the following: Can you summarize this user story so a high-level sales director can understand it?

Integrations

Integrations are something I can’t see being affected by ChatGPT, or even Einstein GPT for that matter. An integration is the action or process of integrating two or more systems together. As such, they have the ability to be extremely complex to set up and manage. ChatGPT may be able to help you with certain things like the initial code required to set up an integration, but it will still take a person to understand the requirements of the integration and what the solution needs to accomplish.

The biggest drawback with ChatGPT at the moment is that there isn’t a single source of truth. This means that if you ask the same question in a slightly different way, you could get different answers.

Testing and Debugging

This is where ChatGPT (and later Einstein GPT) will save countless hours of time for developers. ChatGPT is quite good at reading and understanding the code you give it. As such, when a developer creates an Apex class or Trigger, you can put this code into the chatbot and ask it to generate a test class that will work for this.

I have found that this is something that takes some back-and-forth as the model isn’t trained to apply Salesforce best practices at the moment. But debugging is pretty straightforward, as with any error messages that appear in the Problems section of the developer console, you can simply copy and paste into ChatGPT. It will then rewrite the code for you to try again.

Again, after some back-and-forth, this is the test class I got for the Apex class ChatGPT wrote in the previous example:

Here you can see that with each iteration of the code, ChatGPT is giving an explanation as to what has changed and why.

One thing to also note here is that the back-and-forth with ChatGPT is helping to train the model in learning Apex best practices, meaning that more reliable code will be written in future releases.

Salesforce Development Lifecycle

Here’s another thing I can’t see being affected by ChatGPT, the Salesforce development lifecycle will more than likely be completely separate from this tool. From change sets to DevOps Center, the development lifecycle is different for every organization. Some are entirely owned by a person or team, whereas others have some automation involved.

However, it’s unlikely this will be something that is wholly overtaken by AI. There should always be people involved in this process.

Considerations for Using ChatGPT

Currently, there is one flaw with OpenAI’s ChatGPT that is hard to ignore – there is no single source of truth. As a result, you can ask the same question in slightly different ways, and get completely different answers. Without a single source of truth, no matter how useful the tool may be in some circumstances, we won’t be able to totally trust what it gives us.

READ MORE: Breaking News: Salesforce Einstein GPT Officially Announced

Summary

There are some roles that are more at risk than others when it comes to generative AI and ChatGPT. The junior developer role is one that could be most at risk, especially when Einstein GPT is launched and a lot of admins will be able to perform tasks that would previously have been done by junior developers.

On the flip side, a lot of admins cannot fully understand code that is written in their org and wouldn’t be able to troubleshoot any issues if something were to break. Therefore, I’m certain that the Salesforce Developer role will be absolutely fine.

READ MORE: Being a Salesforce Developer in the Age of Generative AI

The Author

Andrew Cook

Andrew is 14x certified and has worked in the ecosystem for 12 years.

Comments:

    Adrian
    June 19, 2023 11:31 pm
    I do not think that the developer's role will disappear. Code produced need to be verified as pointed out in the article. I think ChatGPT will make the developer more productive instead,
    Lauren Westwood
    June 23, 2023 11:38 am
    We agree, Adrian - it's a tool for humans, not the other way around :)

Leave a Reply