Salesforce: How does one retrieve whether a layout field has been marked as required? - salesforce

So this is weird, wondering if perhaps SFDC is just returning "wrong" information.
I'm working with layouts for an object, and in the interface I have set a field in the default layout (there are no other layouts) to "required".
But, when I retrieve this layout from the API, the field in question's "nillable" attribute is TRUE when it should be FALSE.
Does salesforce expect data like this to be retrieved from somewhere else? Regardless it seems the API is lying.

The API is not lying - the field is only required by that particular layout, not by the underlying system.
If you want it to truly be required, you need to set this attribute on the field itself.

Related

Rename salesforce columns from API_name to field label

When you use salesforce data that has being exported through any API, tables you get have column names in their "API_Name" format. This differs a bit from their "Filed Label" format in which they are presented on salesforce's web UI (for example on reports).
You can find what API name corresponds to any of the columns (objects) in the salesforce object manager.
My question is: is there anywhere a dictionary to map API Names back to their Filed Labels? It will be very helpful to have in JSON or anything that can be used programmatically.
It's called "describe" data. It's available for whole object (label, plural label), fields (label, picklist value translations), names of related lists.
In Apex this is a good initial reading: https://developer.salesforce.com/docs/atlas.en-us.200.0.apexcode.meta/apexcode/apex_dynamic_describe_objects_understanding.htm and for fields: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_fields_describe.htm
If you're using REST API - make GET to /services/data/v55.0/sobjects/Account/describe for example.
Have a look at https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_quick_start.htm too. For example if you need to build your own UI for "dependent picklists" it can be painful to read it all from "describe", https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_features_records_dependent_picklist.htm is bit better. And when you fetch records via this API you get fields as object with visible label and raw value (useful when displaying dates, numbers for example)

Accessing CustomFieldDefinition metadata via tooling api

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
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".
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
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)
And since you mentioned Lightning Components - are you aware of these ready tools:
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_ui_api
getPicklistValuesByRecordType
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.reference_generate_record_input_create
or maybe you don't have to code it all and stuff like <lightning-record-edit-form> with recordtypeid passed to it will solve all your problems
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?

Azure Search: rotationFromOriginal not properly populated

As I am reading here, "when the imageAction is set to generateNormalizedImages, the new normalized_images field will contain an array of images. Each image is a complex type" which should contain a very important field for my scenario (rotationFromOriginal).
I noticed that, even if Azure Search perfectly accomplish the rotation of the images, this property will always be 0 (unlike other fields as originalWidth, which are correctly populated).
Do you know why I have this issue? Am I the only one?
AFAIK, the value of rotationFromOriginal was in normalized_images and it was as an input, so it must be populated at first.
And use the parameters in normalized_images json file to rotation and process image. For more details, you could refer to this article.

Drupal 7 views exposed filter shows up even when the user does not have access to the field

I have a view that shows user profile fields in a tabular format. There is a "Country" field, which is not accessible to anonymous users. When viewed as anonymous user, the field is not shown by Views, which is correct. However, I also have the same field exposed, so that users can filter by "Country". The exposed filter shows up for anonymous user and an anonymous user can actually filter by the field, even though he does not see the field value. Am I missing something or it is normal behavior? Is there a way to force the filter to be hidden for anonymous users?
If you want to achieve this without having to do any custom coding, you can try to display the filter as a block and set the permissions on the block to display only to authenticated users.
This in fact is a known issue and detailed at http://drupal.org/node/1352654. As per the last comment in that issue this "wont fix". That's strange, and certainly not to my liking. Hopefully there will be some solution in a future version.

When creating a Drupal 7 content type programmatically, is there a way to add tuples of fields?

In Drupal 7, I'd like to create a Person content type. A person may have multiple profiles - an administrator should be able to select which profile will be considered the primary one. So, that means that I need a tuple consisting of:
A textarea, for the profile text
A checkbox, indicating that this is the primary profile
A textbox, for naming this particular profile
I need functionality to behave like that of any of the lists: I can click "Add another Item", and a set of all three of these fields will appear.
I have a vague idea of how this can be executed, but it involves using the form API to add fields before the form renders each time, as well as the necessary AJAX behavior. This seems a bit overcomplicated, since this would also necessitate creating an additional DB table to hold these tacked-on fields.
Is there a relatively simple way of doing this solely through hook_install()?
You can use drupal.org/project/profile2 or you can complete it using standard Drupal functionality, i.e. create a content type named, let's say, 'myprofile' and add all the fields use need. Then add a nodereferece (http://drupal.org/project/references) field to the user standard profie that would point to your 'myprofile' content type.
So all the 'myprofile' content, created by that user would be his profiles and the one pointed in his standard profile will be his default.
I hope it's clear enough )

Resources