Automatically Include The Contents of another Macro in a Macro?
AnsweredIs there any way to automatically include the contents of another Macro in a Macro?
In some programming languages that I have used in the past the command would be similar to:
#include filename.txt
I will explain the scenario.
Let us say, for example, that I am using 20 Macros.
Most, but not all, of the Macros might include some 100% identical code from 'Liquid for Designers'.
Periodically, I might want to change a small portion of the Macro but I would prefer not to have to modify the 18 Macros. I would like to change only one base Macro and have its' code automatically inserted into the 18 Macros.
I realize that I could create one macro and change it as necessary but there are two issues:
1. I would have to remember to run the Macro
2. The comment portion of a Macro can only be inserted at the end of existing comment and not be embedded within the existing comment.
Thank you in advance for all suggestions.
-
You could use Dynamic Content. While DC is primarily used for translations, it effectively lets you create your own personal placeholders within Zendesk. Instead of placing your content in the macro, you can place it in the DC and place the placeholder into your macros.
There are some disadvantages to using DC. It's not as friendly for formatting, you are basically limited to plain text. In addition, editing macros doesn't show you much to work with. You'll just see the placeholders and have to got to the DC settings to update each pieces of DC.
You could mix both and have most of your content in the macro, and only content you think you might edit in your DC and have the placeholder there for that piece of content.
-
No formatting is an issue since I tend to use 'bold' for emphasis.
So, manual HTML code <b></b> will be ignored?
-
Hey Allan!
There's no need to use HTML formatting for macros, because rich text formatting is available. Unless that's not working for you?
-
I am somewhat confused.
I was referring to Daniel's commend regarding Dynamic Content.
-
Hi Allan,
You can use HTML in Dynamic Content and if you enter the dc placeholder into a comment directly, you'll see it send formatted. However, if you put that same placeholder in a macro - when the macro expands, you'll see the HTML code, not the formatted content. Given that my recommendation had you nesting DC placeholders into macros, it's probably not the right solution for you now since you need that formatting.
I would love to see Rich Content in Dynamic Content as well which would help out here, but because not everything is Rich Content ready in Zendesk there are some weird issues here.
-
Ah! Sorry for the confusion. I was evidently confused as well. :)
HTML isn't recognized in macros; if you're not using rich text you can use Markdown. However, based on what Daniel said, I suspect that the Markdown formatting won't render. I'm not 100% on that, though, so it's probably worthwhile to test it.
-
Hi Allan and Jessie,
I tested it with Markdown as well just now.
My DC had something like this in it:
**Test** [Google](www.google.com)
I put that placeholder in my macro and it came back looking like this:
<b>Test</b>
It converted Markdown to HTML and completely stripped the URL.
-
This is the specific example of what I would like to do.
I have perhaps 18 Macros for 'closing' a ticket.
I have a custom dropdown ticket field that is 'Billable'.
Some examples are 'Yes', 'No', 'Subs-Gold', etc.
The 18 Macros all have exactly the same code as follows (in English) something like:
If billable = 'No' print 'There will be no charge for this service'
If billable = 'Subs-Gold' print 'You are subscribed to our Gold Plan. This is a free service'
Etc.
I would like to avoid duplicating this code in the 18 macros.
I would prefer to add a place holder that 'loads' the above code in a macro when it is run.
That way I can change the above code one time when necessary and have it propagate at run time.
-
Is it off the table to have one macro for the code and another macro add the rest of the content? Would be tough if the content in your code is sandwiched between content above and below it, but if it was content at the top, then the code at the bottom, you could run two macros to minimize having to update the code 18 times.
-
Well, *if* the dynamic code is literally at the bottom (just above the signature), I could add the code to the signature :).
However, I do not remember if the signature can contain formatting.
-
Interesting. Other areas like that you might use are your trigger emails that send comment updates out or the global HTML template. If you send those lines out at the bottom of every email, it might make more sense to have it at the bottom of an email versus at the bottom of every comment.
In the trigger scenario you could clone your current notify on comment update trigger and set it to fire only if a certain macro tag is included (and have it remove that tag in the same trigger so you can reuse it). Then have your original trigger only fire if the tag is not on the ticket. Then you can modify your message to have the liquid markup in the trigger instead of in the macro. This does work with HTML for formatting.
You could also use liquid in the global HTML template. This is a lot more risky as EVERY email will include your code's output, so I would test it out on a sandbox, but it could give you an option if you wanted to just have a line under your content letting them know what their plan in.
Hopefully some of this thread is helpful. I know we haven't specifically solved your problem so far, but maybe one of these options sparks the right thing for you.
-
For what it's worth, Zendesk Support indicated the lack of HTML support in Dynamic Content is a known issue when we asked about it at the end of November. Fingers crossed it'll one day be fixed, it currently makes it impossible to have a macro with Liquid and HTML links.
-
Active Feature Request (please vote):
Feature Request: Ability to nest a macro inside of another macro
I just posted a Feature Request for this at the link below. If you would like to see this feature please head over there and show your support. Please make sure to add an upvote and comment even if it is simply a "+1"
Also, you may consider adding it to your post to get the feature request more visible.
Please sign in to leave a comment.
13 Comments