0

i want to change the field label based on the condition. i have started but i don't know how to get the filed label in the query.

controller:

public with sharing class Help_samplecontroller {

    public Prop__c bird { get; set; }
    public string Item { get; private set; }

    public Help_samplecontroller() {
        list<Prop__c> prop = [SELECT id FROM Prop__c 
            WHERE id = :apexpages.currentPage().getparameters().get('id')];
    }

    public void prop(){

    }
}
  • Can you elaborate the scenario? – Raul Nov 7 '16 at 12:09
  • according to condition field label and field value have to change. – user37822 Nov 7 '16 at 12:10
1

You can't change a field label directly you will have to use a property:

public string theLabel {get; private set;}

Then set it based on your condition and use that in the VF page.

You could also use custom labels and use them based on condition

Use custom labels in Lightning components with the $Label global value provider.

Custom labels are custom text values that can be translated into any language Salesforce supports. Custom labels enable developers to create multilingual applications by automatically presenting information (for example, help text or error messages) in a user's native language

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/labels_value_provider_platform.htm

If you need the label to make the decision, you don't get the label in a query you use describe information to get the label.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_describe_objects_understanding.htm

Map<String,Schema.sObjectField> flds = Prop__c.sObjectType().getDescribe().fields.getMap();

String exampleLabelGet = flds.get('name').getDescribe().getLabel();
| improve this answer | |
  • Should probably be private set, no? – Adrian Larson Nov 7 '16 at 14:12
  • Probably........ – Eric Nov 7 '16 at 14:19
0

are you looking single input field should rendered depends on condition. Here 'type' is apex class variable to assign field to rerender.

<apex:page standardController=”Account” extensions=”DynamicInputExtension”>  <apex:form >
        <apex:pageBlock >
        <apex:pageblocksection >
        <apex:inputField value=”{!Account[CASE(type,
        ‘Name’,’Name’,
        ‘Active’,’Active__c’,
        ‘EndDate’, ‘End_Date__c’,
        ‘SLASerialNumber__c’)]}” />
        </apex:pageblocksection>
        </apex:pageBlock>
        </apex:form>
        </apex:page>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy