0

https://developers.google.com/admin-sdk/directory/v1/guides/search-users states that when "a user schema named EmploymentData with the fields projects" exists, you can set query to EmploymentData.projects:'blah', and it will search for all users having projects field on EmploymentData schema set to "blah".

It all works for me when schema name is single word, but now I have schema called my-schema. Dashes and underscores are allowed by API in schema names. As in googleapis TypeScript library (and guess in all other libraries) this field is just a string, I was not able to find some quotes combination to make it work. "my-schema.fieldName", "my-schema".fieldName, etc.

How can I search by schema field where schema name contains dashes?

glebsts
  • 337
  • 4
  • 11
  • What programming language are you using to reference the user schema, which is a JSON object? – CMB Jan 11 '21 at 16:30
  • https://developers.google.com/admin-sdk/directory/v1/guides/manage-schemas#search_fields I am referencing to user schema field in search query, not working with schema object itself. – glebsts Jan 12 '21 at 09:36

1 Answers1

0

Schemas are JSON objects, as such, referencing keys that have hyphens are interpreted as subtraction operations.

To reference keys that have characters that are not allowed in identifiers you can use brackets, for example:

jsonObject['my-schema']['fieldName']

References:

Unable to Access JSON property with dash

Manage Schemas

CMB
  • 4,950
  • 1
  • 4
  • 16
  • It is not about accessing object fields, but about using `query` string parameter. No ideas what happens with this value in GSuite backend, but this syntax ofc doesn't work, it would look like `eval` is used. https://developers.google.com/admin-sdk/directory/v1/guides/manage-schemas#search_fields – glebsts Jan 12 '21 at 09:35