Add a User Field value to an article
Is it possible to add a User Field value to an article and some logic with it?
For example: We develop a SAAS solution and are using ZenDesk to support it. Through the API we automatically create a customers account in ZenDesk and we insert their website address of their SAAS instance into their account. i.e. brenden.service.com.
An article might be about a particular section of our system like making a coupon code so we would like to insert a link directly to the clients instance of their SAAS so it would be http://brenden.service.com/create_coupon. We were hoping to do this with a custom field and logic like:
If (user_field.website != 0) {
<a href="http://[user_field.website]/create_coupon">Click here to create your coupon code</a>
}
That way the link will only appear if their user field 'website' has a value.
Fingers crossed... :)
-
Hi Bprazner,
While there are no tools built into the Help Center user interface to accomplish this, it could be done with some clever usage of our API.
For example:
- Get the value of the custom user field in question for the current user via the Show User endpoint
- Get the content of the requested article via the Show Article endpoint
- Use a function such as gsub to find all instances of a pre-defined element in your article HTML and replace it with a new element containing the value of the custom field.
- Build the page containing the article text with formatting relative to the current user.
That's just my take on this particular issue. Our community members find all sorts of creative ways to use our API though, so they may suggest a different approach, or otherwise fill in the details of my basic outline!
Please sign in to leave a comment.
1 Comments