Ability to display end users' user field value in a Guide article
Hi,
We created custom user fields in our instance and implemented a process to hydrate them.
The end goal for us is for end users to consult a specific article in Guide and see the values of these user fields.
I couldn't find any built-in solution for that:
- Articles don't seem to support a token-based approach where it'd be swapped server side by Zendesk.
- I looked at Guide templates, but none of the available helpers seem to expose user fields.
We tried building a custom solution built in the theme that performs the following steps:
- When the page loads, some JavaScript code makes a call to the /api/v2/users/me endpoint.
- We then programmatically replace the content of specific HTML elements and inject the correct values.
While this solution worked during our testing, we found that the /api/v2/users/me endpoint only returns a subset of the data for end users, excluding the user fields. We found after the fact that this is documented here: https://developer.zendesk.com/rest_api/docs/support/users#:~:text=Responses%20will%20vary%20depending%20on%20the%20role%20of%20the%20client%20making%20the%20request.
At this stage, we're stuck and can't come up with any other viable solutions.
Any chance you could help?
Cheers,
Mick
-
Have you explored using the Zendesk HelpCenter JavaScript object?
-
Thanks for the suggestion, Bruce.
I didn't know about the HelpCenter JS object.
The only docs I could find about it are here: https://www.screensteps.com/articles/customizing-your-help-center-with-javascriptUnfortunately, the custom user fields are not exposed through it, so it's not a viable solution for me.
-
If the field is a dropdown you will be able to use the HelpCenter object as it contains the user tags and the dropdown options maps to tags.
If you are using a free text field or a numeric field the only way I can see is to have a backend service that will map those fields as tags and then recover them using HelpCenter object again. It is pretty much a workaround but it would work.
Example of a custom tag mapping (with syncing using backend):
Field: Number of aquisitions = 5
Create custom tag => n_aq_5
Get that tag in the HelpCenter object and parse the number out of it. -
Thanks Andre!
We're in the process of implementing the solution you described, and it looks promising.
Thanks for your help, I'll try and loop back with the final result when we've deployed this to our production instance.Cheers!
-
We've deployed that implementation to production and it works like a charm!
Hopefully we'll find a solution that doesn't rely on the undocumented HelpCenter JavaScript object in the future, but for now all good!
Thanks again, your help is much appreciated!
サインインしてコメントを残してください。
5 コメント