3

Is it possible to access the picklist value collection response body in a custom component js using a built in component? I need access to the dependent picklist values and their validFor property. I'm using the onload function of lightning:recordEditForm to get all the field values of a record without having to do anything server side like this:

componentController.js

var payload = event.getParams().recordUi;
var flds = payload.objectInfo.fields

From everything I've searched for and read I can't find a way of getting to the picklist value collection through the RecordUi response body.

Is it possible to do something like that lighting:recordEditForm call and access the picklist value collection response body? The information has to be somewhere because if you use lightning:inputField within the lighting:recordEditForm your dependent picklists function correctly...

Ultimately I need to get to the information that looks like this:

"picklistFieldValues" : {
    "Cities__c" : {
  "controllerValues" : {
    "Australia" : 0,
    "Brazil" : 1,
    "China" : 2,
    "Colombia" : 3,
  },
  "defaultValue" : null,
  "url" : "/services/data/v43.0/ui-api/object-info/account/picklist-values/012000000000000AAA/Cities__c",
  "values" : [ {
    "attributes" : null,
    "label" : "Cali",
    "validFor" : [ 3 ],
    "value" : "Cali"
  }, {
    "attributes" : null,
    "label" : "Chicago",
    "validFor" : [ 0 ],
    "value" : "Chicago"
  }, {
    "attributes" : null,
    "label" : "Dakar",
    "validFor" : [ 1 ],
    "value" : "Dakar"
  },]
},

So I can build strings of valid nested combinations for an end user search (essentially make it so they can search for a nested value and select all field values at once).

Thanks for any help!

5

Yes you can, via the onload event of the lightning:recordEditForm (as you are currently doing),

access the recordUI Object:

JSON.stringify(event.getParam("recordUi"))

in the console you will see all your picklist values alongisde dependencies.

to access the picklist values:

event.getParam("recordUi").picklistValues.Fieldname.values

(be carefull, javascript is CAse Sensitive)

  • omg, that worked perfectly. Thank you so much! I tried reading through the recordUi output but it was 2mil lines and ctrl+f wasn't working all that great. – McWiskers Aug 28 '18 at 21:09
  • Took me a while to get to it as well when I had done the same a while back – glls Aug 28 '18 at 21:10
1

It seems like this behaviour is changed with recordEditForm since the picklistvalues are not coming in the onLoad event. There is a separate call being made to get the picklist values and i dont think we can access to that event.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.