In many cases, you would like as a developer to be able to enable or disable certain related functionalities in your APEX applications.
Build Options are useful in that case as they enable developers to enable or disable application components and functionalities when the application installs or at runtime using the APEX_UTIL.GET_BUILD_OPTION_STATUS and APEX_UTIL.SET_BUILD_OPTION_STATUS APIs.
Build Options status can have two values only. Either Include or Exclude. Include value enables the application components associated with the build option, while Exclude disables them.
Build Options Use Cases
The three main use cases for Build Options are:
1- Enable and Disable Functionalities during the installation
The first scenario where the developer wants the end-user to enable or disable functionality during the installation. For example, you may want to deploy an application to a server where email notification is not yet configured, or the mail server is not working in that environment. During development, that functionality will work just fine because you have your mail server configured and enabled in that environment.
Ideally, you would like to enable the notifications only on the environments that support sending notifications.
Alternatively, you might want to have different functionalities enabled or disabled based on the business requirements. Let's imagine you have created a ServiceDesk system to log tickets. Different customers will use your ServiceDesk application that has a field called Ticket's Origin to track if the ticket was logged using the ServiceDesk application, through the phone or received by email.
Some customers would love to know and record the Ticket's Origin field, while other customers may not need this functionality at all.
In these kinds of cases, Build Options can be used to provide a mechanism to enable or disable the notification or the ticket origin functionalities during the installation of your application. Later on, if the privileged end-user would like to enable or disable an application functionality, they can do that utilizing the APEX_UTIL.GET_BUILD_OPTION_STATUS and APEX_UTIL.SET_BUILD_OPTION_STATUS at runtime.
2 -Hiding Incomplete Functionalities in Various Environments
The second scenario allows the developer to use build options to disable functionalities that are not ready yet. Those incomplete functionalities on the DEV environment can be assigned to a Build Option with the status Exclude to disable them on the other environments.
Once the functionalities are complete, the developer will simply export the application and change the status of the Build Option to Include to enable them.
This a great way to prevent delays in delivering your application. The unfinished related functionalities are excluded easily.
3 -Determining the Consequences of Removing Functionality
Sometimes the developer is not sure what would be the effect of removing certain functionality. To determine the consequences of removing functionalities, you can create a Build Option with the status Exclude and assign it to the components.
This is a good alternative to using Condition. Let's say that you have a component with Condition assigned to it. You are not sure whether to remove this component or not.
You decide to test its removal by updating the Condition's Type to Never. You run and test your application and you find out that the component is actually needed and it is affecting other components. Now you want to revert back to the previous Condition's Type. The issue is you will not be able to get the previous code/values for the Condition.
The solution is to simply create a build option of status Exclude and assign it to the component. Test the application and check if the component is still needed. If yes, then easily change the Status of the Build Option to Include or remove it altogether and your condition will work as usual being intact.
Creating a Build Option
Let's have a look at how Build Options are created.
1) Go to Shared Components
2) Click on Build Options
3) Click on Create button
4) In the Attributes page:
In the above screenshot, we have created a Build Option called Test with a Status value Include. Any component assigned to this the Test Build Option will be enabled. If we change the value of the Status to Exclude. Any component assigned to the Test Build Option will be disabled.
Applying Build Option to a component
You can apply Build Options to most application components (such as pages, regions, items, validations, and so on) and specify whether to include or exclude them in the runtime application or during the application installation.
Let's see how to do that.
In the App Builder select any region that you have in your application. Under Configuration => Build Option. Select Test Build Option.
Including Build Options in the export file
Go to the App Builder => Click on Supporting Objects
Under Supporting Objects click on Build Options
Select Test Build Option to include in your export file as a supporting object and then click Apply Changes.
Export your application and import it again. Ideally, the import will occur in a different environment. But for the sake of testing, you can try it in the same environment.
In the import process, enable Install Supporting Objects.
Finally, you will see that you now have the Test Build Option under the Available Build Options, and you can Include or Exclude it as you per your requirements.