I am using Schema class to retrieve metadata of object.
Controller :
getCustomObject : function(cmp, event, helper) {
var action = cmp.get("c.getCustomObject");
var objectName = component.get("v.objectName"); // objectName = 'Test__c' without namespace
action.setParams({
"jsonObject" : JSON.stringify(obj)
});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
// something login
}
});
$A.enqueueAction(action);
}
Apex class :
@AuraEnabled
public static void getCustomObject() {
Map<String, Schema.SObjectField> objectFieldSetMap = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
}
This was working fine as I was passing the objectName from my lightning component. But when I tested this in Sandbox after creating managed package and tested it throws
NullPointerException
After searching little bit I found the objectName coming from lightning component is without Namespace.
But in my scratch org it doesnt work with namespace. Please ignore any typing mistake or let me know if something is missing or I am not clear.
What would be the feasible solution for this?