0

I have a save button on a lightning component that when clicked fires a SAVE function that does validations, computations and then sets params on several diff actions that create or updates other objects.

I need to do an update on 100+ records from data loader to change a value on these records. Since the button is UI, of course, it won't fire off the lighting component during data load and the triggers are not being used here.

In what way can I fire off the UI Save lighting component from the back end to do the necessary computations and update/creation of records.

1 Answer 1

2

Lightning is inherently a UI layer. You can't call a Lightning component's JavaScript controller from the back end, at least not without doing some really elaborate (and fragile) engineering with headless web browsers.

You may want to consider assembling a small Apex batch class that you can run manually which implements your business logic and calls the specific server-controller methods (you can call a Lightning server controller's methods from other Apex code) that your front end is using.

In the long run, you're likely to face this issue again, since any API-based load or update will have the same challenges. Consider moving data integrity and complex database manipulation into a reusable Apex service layer, while performing validation in Lightning client-side code. Your Lightning component's server controller can call into your service layer to efficiently reuse code, while centralizing and standardizing your business logic so it applies to any data-related action.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .