-2

I create headless quick action "Generate and attach pdf". But when i click on my action i have error "List has no rows for assignment to SObject". What is my problem?

Error enter image description here

How i can fix it?

1
  • Looks like you are passing in a blank recordid to me. The Opportunity query then returns no rows
    – codeulike
    Commented Feb 4, 2022 at 14:52

1 Answer 1

1

This may be probably due to the fact that recordId is undefined in connectedCallback() as I can see the value logged in console is undefined. When using headless quick actions, implement invoke() method to read the recordId and then trigger any Apex controller actions. You can find more details here. Thanks !

5
  • It's strange, for some reason I can't add Invoke here. imgur.com/a/FAkSgvg
    – Bogdan
    Commented Feb 4, 2022 at 15:01
  • 1
    You can't define connectedCallback() inside invoke(). Consider moving the code from connectedCallback() to invoke() method. :) Commented Feb 4, 2022 at 15:05
  • thanks,, this removed the error, but for some reason Attachment still does not appear, it only works in Debug execute, when I click on Quick Action nothing happens, please watch the video youtube.com/watch?v=fmMLaPeHpls
    – Bogdan
    Commented Feb 4, 2022 at 15:15
  • 1
    Seems like a common issue, getContentAsPdf() doesn't work in lightning context. It fails silently. Workaround is you can replace getContentAsPdf() with getContent() and fill the attachment record field ContentType with value as application/pdf Commented Feb 4, 2022 at 15:48
  • you're right! thank you! You helped me a lot. I had another little problem in that I just had ScreenAction, you can read about that here if you are interested. thank you again salesforce.stackexchange.com/questions/347055/…
    – Bogdan
    Commented Feb 4, 2022 at 21:38

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