I have a constants class that has:
public static final String DATA_TYPE_INTEGER = 'INTEGER';
I tried to access this in my LWC by doing an import like this:
import DATA_TYPE_INTEGER from '@salesforce/apex/ConstantsClass.DATA_TYPE_INTEGER';
But in my Javascript, .toLowerCase()
is not an operation on DATA_TYPE_INTEGER and I can't seem to get any actual string value from it.
I then tried in my apex class for my LWC:
@AuraEnabled
public final String DATA_TYPE_INTEGER = ConstantsClass.DATA_TYPE_INTEGER;
And importing that, but got the same issues. I don't think Lightning Components allowed you to access variables like this at all, but was thinking that LWCs might, like they can import custom labels...
Is this actually possible? And if so, how do I go about importing an apex class variable into my javascript?
'INTEGER'
toInteger.ObjectType
or however we might get that. We do not want hard coded strings thrown around the code, we want them contained and rely on returned Salesforce information (like with Object.SObjectType()) to help with translation. So looking to get the value out of Apex to get the type, or directly get the type from some kind of import LWCs support. Like, can you just directly import type names?