0

So, I've been attempting to gather picklist dependencies per Opportunity record type for my lightning components. I have been able to retrieve Standard Field dependencies by RecordType, but it the Tooling API will not return the custom field dependencies. Standard calls and queries will not work either, as they state that the field has no controlling value or dependency.

Given this information I suspected that there was a table that is hidden somewhere that contains the keys for the RecordType and FieldDefinition, hopefully with a nested Metadata object.

I found an Id in one of the parameters in the setup menu for a Record Type and Id.getSObjectType() on it. The table name is CustomFieldDefinition. However, it is not accessible via SOQL or the Tooling API.

Has anyone accessed this table? Or has anyone been able to retrieve the field-record type picklist dependencies on custom fields AND standard fields?Tooling API ResponseDebug Log with SObject Name

1 Answers1

1

I think you're doing it wrong.

"Controlling field" would be another picklist or a checkbox for example, something you change during same edit action. If you have dependency to record type - in that sense it's not a controlling field. Sure, you change record type and picklist changes - but really everything would change, it should be a different page layout (different fields shown, marked readonly/required etc). There's a reason that record type change is not done on normal edit screen, you do it by clicking special link on detail view and then everything "explodes".

  1. Have a look at "User Interface API" - set of tools meant to help your custom app (mobile? desktop?) steal recreate a normal page layout. This one might be especially useful: https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_picklist_values_collection.htm
  2. There's even a Trailhead: https://trailhead.salesforce.com/en/content/learn/modules/user-interface-api (skim through whole set but especially read last module)
  3. And since you mentioned Lightning Components - are you aware of these ready tools:

Have a look, if I didn't give you a working solution then at least you have some keywords to Google around. If you're still stuck - try to post a code sample as new question?

eyescream
  • 18,088
  • 2
  • 34
  • 46
  • Thanks! I'll take a look at the User Interface API. I tried calling the layouts in Tooling as well to no avail. The `` is the whole reason I'm trying to do this. For some reason it is very slow to load and submit and it is straining the UX of the app :(. – indiana.jones Feb 07 '20 at 23:05
  • Do you have debug mode enabled? Have you tried logging in as end user, maybe it's slower because you're sysadmin and can see too many Opportunity fields... Hard to say without seeing some code. Worst case you could do the UI API callouts, store them in platform cache and call that. And if it's still slow - ticket with SF support I guess. – eyescream Feb 08 '20 at 00:45
  • Yeah, boiled it down to a process with recursion on. It is still slow to load, so I'm grabbing the values and storing them as custom settings. I figured that is the best way for the time being, maybe schedule to update once a day. – indiana.jones Feb 08 '20 at 06:41
  • Check if editing record type-picklist dependencies leaves an entry in SetupAuditTrail, you could query it on schedule? Or tables like FieldDefinition (see https://stackoverflow.com/a/60067076/313628), there's LastModifiedDate in them, maybe you could filter by Opportunity, Picklist, modified today. – eyescream Feb 08 '20 at 08:15
  • I'm not sure how to go about it. I was looking into Platform Events, maybe those would be relevant? Already updated my component with the custom settings received from the UI API. You saved my sanity, thank you so much haha – indiana.jones Feb 10 '20 at 16:11
  • Schedule job to run every hour with query similar to `SELECT QualifiedApiName, LastModifiedDate FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Opportunity' AND DataType IN ('Picklist', 'Picklist (Multi-Select)', 'Checkbox') ORDER BY LastModifiedDate DESC NULLS LAST` and if needed - rebuild your cache? (yeah, you should totally consider https://trailhead.salesforce.com/en/content/learn/modules/platform_cache for this). Platform Events - I don't think you can fire custom events based on setup changes. – eyescream Feb 10 '20 at 20:38