I have a template which have a couple of variables, such as
$tempTitle (String) $tempQuality (list of Strings)
where $tempTitle is just a string and $tempQuality is a list variable given in the template.
Now, I have spent a lot of time trying to figure out how I'm supposed to do this, and my employer should probably kill me for spending so much time on just nifty feature...
I'm trying to rename the title with the code given by Nelson in this answer, which works on $tempTitle. However, I'm not able to write more code that actually are able to evaluate the $tempQuality and include this evaluation in the title.
My code as it stands now (not working)
## @noparams <script> $("input[name='variableValues.tempQuality']").change(function(){ var KEnr = $(this).val(); }); $("input[name='variableValues.tempTitle']").change(function(){ console.log($(this).val()); $("form[name='filltemplateform']").find("input[name='title']").val($(this).val()) }) </script>
I completely fail to understand how the Confluence macros handle data from template variables, can someone please enlighten me? I'm going completetly bonkers over how riddiculously difficult it is to have some sophisticated dynamic content in Confluence.
Hi Axel, maybe try this:
<script> AJS.toInit(function() { if (document.URL.indexOf("createpage-entervariables.action?templateId=132939777") !== -1) { var variableNameElement = $('input[name="variableValues.variableName"]:visible'); variableNameElement.on("change", function() { $("input[name=title]").attr("value", variableNameElement.val() + " - " + (new Date()).toISOString().substring(0,10)); }); } }); </script>
Change 132939777 to whatever your template ID is (when you load the template, it's shown in the URL) and change all instances of "variableName" whatever your variable name is. I included also inserting the current date in the page. You seem fairly familiar with Javascript, so you can customize it as you want.
Unfortunately, including it in a user macro won't work. You'll have to insert it in the Global Custom HTML to get it to work.
Want to leave your mark on Confluence? One winner will have their whiteboard design added into Confluence for all users to access! This is your chance to showcase your creativity, help others, and gain recognition in the Confluence community.
Share your template today!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.