6

I'm investigating an issue where values of one of the columns on the "FieldPermissions" object get truncated when we sync them to a DB. The column in question is called "Field", and it contains the name of the field being permissioned in the form .. A Describe call on the FieldPermissions object returns length: 40, and our ETL process sizes the db column accordingly, and then enforces the length during the load. When querying the results, I noticed a few records with longer values got truncated. I then used SOQLXplorer to run the same query againsf SF directly, and found the values return correctly (non-truncated), and some of them are longer than 40 chars (51, to be exact in one case). I ran a Describe call in the workbench to confirm the values:

/services/data/v37.0/sobjects/FieldPermissions/describe/

A few questions around it:

  1. How can Field contain a string longer than the length advertised by the API?

  2. There is another attribute called byteLength that actually returns 120. Could that be the "real" length allowed into that field? If so, would it be applicable to all string fields?

  3. SOQLXpolorer must be using the same API to talk to SF, so why would it correctly display the long strings, even though a "describe" in the app also shows 40 as the string length?

If someone could help make sense of this, would be greatly appreciated.

  • 2
    It's also strange that they FieldPermissions object uses the field's API name plus the parent Object name as the unique id instead of the field's actual ID. And the schema describes FieldPermissions.Field as a picklist! – AlwaysThinkin Mar 10 '17 at 17:19
  • Yep, my colleague and I noticed that as well, and were just as surprised. – Oleg Berfirer Mar 10 '17 at 17:49
4

How can Field contain a string longer than the length advertised by the API?

In this case, some of the fields being permissioned may have a length longer than 40. For example, there is a standard field called UserPreferencesDisableFileShareNotificationsForApi whose length is 50. I don't have any fields in my org of length 51, but if you extended permissions to such a field through the FieldPermissions object, the length of the Field value would match.

There is another attribute called byteLength that actually returns 120. Could that be the "real" length allowed into that field? If so, would it be applicable to all string fields?

No, that is not what byteLength means. From the documentation:

For variable-length fields (including binary fields), returns the maximum size of the field, in bytes.

As you may notice, each character of a Text field counts as 3 bytes.

SOQLXpolorer [sic] must be using the same API to talk to SF, so why would it correctly display the long strings, even though a "describe" in the app also shows 40 as the string length?

I haven't looked at what SOQLXplorer uses under the hood, but this is how queries are expected to work. They just return the data. They don't examine the schema and make sure the data conforms to it, then modify it accordingly if it does not. The query is just the extract step in the Extract-Transform-Load paradigm.

  • Thanks, Adrian. Could you clarify what you mean by ".. but if you extended permissions to such a field through the FieldPermissions object, the length of the Field value would match."? I do currently have a few fields that exceed 40 characters in that table, so are you saying the API would dynamically adjust the describe call to return the max of actual length of values I store? If so, I don't see that happening... – Oleg Berfirer Mar 10 '17 at 17:53
  • No, the describe won't change. The "max" length is 40. It's just that sometimes (for example with system objects), that's a soft limit. – Adrian Larson Mar 10 '17 at 18:06

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.