VisualForce, Lightning Components, and Apex Triggers

Out of the box, Pulsar cannot run Visualforce pages, Lightning Components, and Apex triggers offline because they require the Apex Framework to run. However, there are ways to achieve the same functionality in Pulsar.

What is Apex?

Apex is a strongly typed, object-oriented programming language that allows developers to execute flow and transaction control statements on Salesforce servers in conjunction with calls to the API. Using syntax that looks like Java and acts like database stored procedures, Apex enables developers to add business logic to most system events, including button clicks, related record updates, and Visualforce pages. Apex code can be initiated by Web service requests and from triggers on objects. All Apex runs entirely on-demand on the Lightning Platform. Developers write and save Apex code to the platform, and end-users trigger the execution of the Apex code via the user interface. Apex is compiled, stored, and run entirely on the Lightning Platform. When a developer writes and saves Apex code to the platform, the platform application server first compiles the code into an abstract set of instructions that can be understood by the Apex runtime interpreter and then saves those instructions as metadata.

When an end-user triggers the execution of Apex, perhaps by clicking a button or accessing a Visualforce page, the platform application server retrieves the compiled instructions from the metadata and sends them through the runtime interpreter before returning the result. The end-user observes no differences in execution time from standard platform requests.

For more information, please refer to Salesforce documentation Getting Started with Apex | Apex Developer Guide | Salesforce Developers

Why can’t Pulsar run Apex code?

So given the above explanation, it is now clear that Apex code can’t run anywhere other than Salesforce platform since it requires the Lightning Platform which is proprietary to Salesforce.

What can be done about it?

There are two ways to solve this problem.

Method 1: VisualForce pages and Lightning pages can be exposed as links within Pulsar and they can be launched from within the app and will run in a webview using the session token the app already has established with Salesforce. Please note that these pages will only work if there is a network connection because in essence you are running these pages in a mobile browser window but the actual code is running on the server. And you really don’t need to make any changes to run the Apex triggers on the server. They will simply run on the server when Pulsar syncs data to Salesforce. These triggers will automatically be invoked and run.

Method 2: If you need similar functionality to run when you are completely offline, Pulsar can accommodate that. However, you will need to rewrite these pages or triggers using one of the two methods Pulsar has to offer. You can use Pulsar as a platform and HTML/Javascript or the Pulsar Settings Language (PSL) to create a custom Pulsar app to perform the same tasks offline.

References

For more information, refer to:

Related pages