function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kevyn Herbet 10Kevyn Herbet 10 

lightning:inputField as picklist. How to remove options without removing from record type?

Hi,

I'm trying to remove options in lightning:inputField but I didn't know how to do it.
User-added image

This TVN1Result__c returns Active, Cancelled, Draft, Completed. I would like to remove Active and Completed.

 

TVN1Result__c  is a controlling field of  TVN2Result__c dependent picklist field used in RecordEditForm.

 

I can't remove the options on record type because another page will use all the options.

Best Answer chosen by Kevyn Herbet 10
Alain CabonAlain Cabon

STYLE:

.THIS lightning-base-combobox-item[data-value="Active "] {
    display:none!important;
}

.THIS lightning-base-combobox-item[data-value="Completed"] {
    display:none!important;
}
 

All Answers

Alain CabonAlain Cabon

STYLE:

.THIS lightning-base-combobox-item[data-value="Active "] {
    display:none!important;
}

.THIS lightning-base-combobox-item[data-value="Completed"] {
    display:none!important;
}
 
This was selected as the best answer
AnkaiahAnkaiah (Salesforce Developers) 
Kevyn,

It is not possible to do it using lightning:inputField you must replace the field with a lightning:select and assign the value of the picklist in the controller. 

component :
<lightning:select name="TVN1Result" label="Source" required="true"> // With this
      <option value="Cancelled">Cancelled</option>
      <option value="Opt2">Draft</option>
  </lightning:select>

controller.js
handleSubmit: function(component, event, helper) {
  event.preventDefault(); // stop form submission
  var eventFields = event.getParam("fields");
  eventFields["TVN1Result__c"] = component.find("TVN1Result").get("v.value");
  component.find('recordCreateForm').submit(eventFields); // continue form submission
}


If this helps, Please mark it as best answer.

Thanks!!


 
Mohamed ELALAOUIMohamed ELALAOUI

Hi,

Have you been able to resolve this please ?

I'm also using a picklist in a lightning-input-field, and I would like to remove the option "Non défini" (value API name : C0).

User-added image

I have tried to do the same as Alain :

User-added image

But I'm still getting the option "Non défini" :

User-added image

Thanks for you help.