The new force:recordData component is awesome since it allows us to retrieve sObjects without a direct apex server call. However as a managed package provider, we have a very common situation where we need to conditionally include the CurrencyIsoCode field if the organization is using multiple currencies. It looks like including this in the fields attribute causes an internal server error when the org is single currency. It would have been great if this was supported but I am not surprised that it isn't. This leads me to two questions:

  1. Is there any way to determine if an org is multi-currency without hitting the server? It doesn't look like this info exists in any of the global value providers.
  2. If we need to hit the server to determine what fields to query, is there actually any advantage to using the force:recordData component? It seems as though this may result in two server calls a lot of the time.

1 Answer 1


Try this in your component (.cmp):

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="record" type="Object" />
<aura:attribute name="requiredFields" type="String[]" />

<aura:if isTrue="{!greaterthan(v.requiredFields.length,0)}">
    <force:recordData recordId="{!v.recordId}" fields="{!v.requiredFields}" mode="VIEW" targetFields="{!v.record}"/>   

And in controller (.js):

    doInit: function(component, event, helper) {
        var myAction = component.get("c.init");

        myAction.setCallback(this, function(response) {
            if (response.getState() === "SUCCESS") {
                component.set("v.requiredFields", response.getReturnValue());


And in APEX controller (.cls) you just return (String[]) appropriate API field names.

You must log in to answer this question.

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