-2

1-How to render a custom field on the basis of datatype?? As i have already created this custom field on the org but i am unable to figure out how to render it on the component on the basis of data type(like text and number).

2-Also i have a custom field named Field_API_Name.In this i have to fetch contact fields of only text and number datatype.

I am just stuck in these two part of my task.It would be great if someone helps me here. Thanks.

1
  • It is preferred if you can post separate questions instead of combining your questions into one. That way, it helps the people answering your question and also others hunting for at least one of your questions. Thanks!
    – identigral
    Commented Sep 8, 2019 at 19:32

1 Answer 1

1

you can use the lightning edit form to automatically select datatype on the basis of the field. You can find more info here

<lightning:recordEditForm onsubmit="{!c.handleSubmit}"
                          onsuccess="{!c.handleSuccess}" 
                          objectApiName="Bad_Guy__c">

            <lightning:messages />

        <lightning:inputField fieldName="Name" />
        <lightning:inputField fieldName="Has_Weakness__c" />
        <lightning:inputField fieldName="Weakness__c" />
        <lightning:inputField fieldName="Weakness__c" />
        <lightning:inputField fieldName="Birthday__c" />
        <lightning:inputField fieldName="Email_Address__c" />
        <lightning:inputField fieldName="Rich_Text_Field__c" />
        <div class="slds-m-top_medium">
            <lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Save" />
        </div>
    </lightning:recordEditForm>
2
  • let me try this code in my component.
    – Shaurya
    Commented Sep 8, 2019 at 17:41
  • it is not working.need more information to implement it in my component
    – Shaurya
    Commented Sep 9, 2019 at 4:18

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