1

I've this very simple component

<aura:component implements="force:lightningQuickActionWithoutHeader, force:hasRecordId" controller="LC09_AccountButtonUpdatePermission_CTRL" access="global">

<aura:attribute name="recordId" type="String"/> 

<lightning:overlayLibrary aura:id="overlayLib"/>

<aura:handler name="init" value="{!this}" action="{!c.updatePermission}"/>

it works and it is activated by an action defined as follows:

action definition

my problem is that i don't expect to see anything, I just want to call an apex method and show a toast message; the results I'm getting are those:

enter image description here

why the white modal? I just need to run some apex. Any suggestions?

2
  • 4
    There is no other option to trigger the Apex, the user will see this modal, you can adjust its height and put some meaningful message for the user and once the Apex processing is done, you can simply show the toast message and close this modal. – itzmukeshy7 Aug 23 '18 at 10:39
  • that sucks... why can't i just make on click javascript :( – JoulinRouge Aug 23 '18 at 10:44
2

I think, you have three possible solutions

  1. Use component with only a button, to make it appear like a button, as already mentioned by @Charles T. Call Apex in that. Put that component anywhere in your lightning page layout. Downside: That button won't be part of other buttons.
  2. Use quick action, I see you already doing that, and instead of a blank / white ghostly looking modal, display a spinner, with some text if required, in that so users know that something is going on in the background. Once done, close the component and display toast or could also display error/success on component; your choice. Downside: component will always display.
  3. Create a quick action , update a record type, update a field that would trigger a process builder, and in that process builder use invocable apex to do what you are trying to achieve, however, I am not sure if you would be able to return success/error message back to user. You could try with "exception throwing".
3

You could also make a Lightning Component that you add to the record page in App Builder, which visually looks like a button but will appear somewhere else on the layout than the usual actions list (e.g. at the top of the sidebar). You'd be able to trigger your Apex call immediately on click of that button.

1

1st - you do not need to add another modal, so delete the line:

<lightning:overlayLibrary aura:id="overlayLib"/>

2nd - on your init method - you need to close the modal like this:

$A.get("e.force:closeQuickAction").fire();

This won't eliminate the modal completely, but is the best you can get with this standard use - the modal will appear for a moment and close by itself

Not the answer you're looking for? Browse other questions tagged or ask your own question.