Can you use a set in an auraenabled method?

Can you use a set in an auraenabled method?

You won’t be able to use a Set, but at least you won’t have any surprise with this one. Try to save an AuraEnabled method with a parameter of type Set , and you’ll see the following error message, preventing you to save: Parameter type does not support AuraEnabled: Set . List and Map are working perfectly though.

Is the auraenabled annotation cacheable on the client?

Only methods with this annotation are exposed. In API version 44.0 and later, you can improve runtime performance by caching method results on the client by using the annotation @AuraEnabled (cacheable=true). You can cache method results only for methods that retrieve data but do not modify it.

How to pass an apex class to an auraenabled method?

Every time I tried I received the following error: An internal server error has occurred. The best way I found to pass an Apex class to your AuraEnabled method is stringify it on client-side, and then deserialize it in Apex. The following code will work fine: You won’t be able to use a Set, but at least you won’t have any surprise with this one.

What does the @ auraenabled annotation do in apex?

The @AuraEnabled annotation enables client- and server-side access to an Apex controller method. Providing this annotation makes your methods available to your Lightning components (both Lightning web components and Aura components). Only methods with this annotation are exposed.

How are auraenabled method parameters used in Lightning?

There is 3 parts in this call: A very basic component that would send a String to the server would look like this: As you would expect, the client-side attribute and the apex method parameter have the same type. On Lightning side, available aura:attribute types are listed here.

Is the passed attribute null in auraenabled method?

On a side note, remember that with Lightning Data Service you may not even have to query the server anymore to get the record you need. I was not able to use Date in an AuraEnabled method, the passed attribute always ends up being null: However, the workaround is pretty easy to implement, just pass the date as a string, and then cast it to a Date:

Can a custom exception be added to aurahandledexception?

Unfortunately, you cannot extend AuraHandledException to create a custom exception because it is not an extensible Apex class. However, there is a trick that can help you bypass this limitation. You can add custom data to your AuraHandledException by following these steps.