In salesforce to deploy new functionality in the client’s org we need to create a managed package that is available on Salesforce AppExchange and then it is deployed on their org but we being the subscribers don’t have the access to code. Sometimes we come across a requirement in which we need to debug in the destined org but due to the unavailability of code, it becomes really tough for us. So then the ISV Customer debugger comes in place which helps a subscriber debug the issues in the client’s sandbox org. The most important thing for this software to run is the requirement of a sandbox org of the client’s environment. Now we will learn some more information about ISV Customer Debugger
Configure ISV Customer Debugger
ISV Customer Debugger is a part of the Apex Interactive Debugger (salesforcedx-vscode-apex-debugger) extension, so you don’t need anything extra just install the Salesforce Extension Pack and its prerequisites and you are good to go. Once you are done installing the pack then these further steps need to be followed.
- Log into your License Management Org (LMO) and enable the ‘View and Debug Managed Apex’ permission for the users you want to by going into profiles or using permission sets.
- Log in to your client’s sandbox org via your LMO. To obtain login access to your client’s org, you will have to ask your customer to provide it. Once you have access then you will have to login into the LMO and search for your client’s org click on the name and then click login from the org details page or you can click on the action buttons from the orgs list and click login.
- In your client’s org, click on Setup, search for Apex Debugger from the Quick Find box, then click Apex Debugger.
- Once the Apex Debugger gets opened click Start Partner Debugging Session.
- Now you can see the Using Salesforce Extensions for VS Code section, just copy the forceide:// URL present there.
- In VS Code, open the Command Palette by pressing Ctrl+Shift+P (Windows or Linux) or Cmd+Shift+P (macOS), then select and run SFDX: Create and Set Up Project for ISV Debugging.
- You will be then directed, once directed paste the copied forceide:// URL into the box, and press Enter.
- Then you will be shown the popup to select the project name in which you can either keep the default project name or enter a name of your choice for your debugging project, and press Enter.
- Choose a location to store the project, and click Create Project.
- Once the project is generated. VS Code will retrieve your packaged metadata, your client’s metadata, and basic classes of other packages in the org and convert them to source format, and finally create a Salesforce DX project. VS Code will also create a launch configuration json file for the project. This process can take a lengthy time, especially for orgs that contain lots of metadata, so you can leave it running and do any other work in the meantime and check back later. You can view the progress in the output panel at the bottom of VS Code. To view the output panel, select View > Output, then select Salesforce CLI from the dropdown menu in the corner of the Output tab. When the project is ready, VS Code will open a new window with the project loaded in it.
- In the new window, from the Explorer view, open the Apex class or trigger that you want to debug.
- To set a breakpoint, click on the left of the line numbers.
- Switch to the Debug view and launch the Apex Debugger, click the play icon next to the launch configuration dropdown menu.
Debug Functionality On Your Client’s Org
Now you can debug the functionality in client org and just for information the debug will work the same way as you do in any of your other orgs. If your session expires, then you can start a new session from Setup using the same steps that you followed when you started the original session.
Client’s Security Is Your Priority
The security of the code of your client’s org is the main agenda that should be taken care of. You should not leave the project as it is after debugging. You should delete the entire project from the location where it was stored when you performed the setup process. Never store your client’s metadata in your version control system. If you need to again work on the same org again you can always start a new debugging session and again store the project.
Here are some final points to keep in mind while using ISV Customer Debugger
- You can debug only sandbox orgs.
- You can debug in one customer org only at a time. However, you can purchase Apex Debugger licenses, and then you can debug multiple customers at once.
- Keep in mind that once you return to your LMO the debug mode for your client’s org will terminate and you will have to start a new one if you want to do some more debugging.