How to take help from ChatGPT for Salesforce Apex Code
- COMPLEX TEST CLASS BY CHATGPT:
Problem Statement: “We were facing an issue in the test class (this test class follows the Apex Enterprise Patterns). We tried to cover the code coverage but somehow, we didn’t achieve test code coverage after that I got the idea of using ChatGPT.
So, we asked about the error that we were facing, it gave the sample code and I tried that code and it resolved the issue.”
How we used ChatGPT: You can see the below screenshot.
Conclusion: ChatGPT is really helpful even for complex scenario (if we could make it understand what we’re actually looking for) that is hard to find on google and directly provides answer to the problem statement (saving our time of toggling between blogs for finding the optimize solution).
- CUSTOM SOLUTION BY CHATGPT:
Problem Statement: “I was trying to get a specific word from a sentence (not substring). I first tried this with the flow but I haven’t found a way to achieve that, so, I searched on google, how to achieve this with the flow.
But it seems like google didn’t even understand my question and was showing results only related to fetching a substring from a string and not a single word from an entire sentence.
Finally, I went to ChatGPT for help and it straight-forward told me that it is not possible via Flow rather this can be achieved by writing custom code and showed me the below code.”
How we used ChatGPT: You can see the below screenshot.
You can use the below code.
Conclusion: Using Chat GPT we resolved one more issue. Chat GPT gave the sample code, after which we optimized that code and resolve that issue. So again it is helpful.
related blog