So i am trying to make a js to run when the page loads initially but am failing to trigger it.
not sure where i am failing
my js looks like this
<script type="text/javascript">
AJS.toInit(function() {
console.log("Script loaded and running in AJS context!");
var nameFieldName = "ProductGroup";
var emailFieldName = "recipientEmail";
var emailMap = {
"john": "john.dow@gmail.com",
"team": "team.all@gmail.com",
"mary": "mary.pop@gmail.com"
};
var nameField = document.querySelector('[name="' + nameFieldName + '"]');
var emailField = document.querySelector('[name="' + emailFieldName + '"]');
console.log("Dropdown field:", nameField);
console.log("Email field:", emailField);
if (nameField && emailField) {
function updateEmail() {
var selectedID = nameField.value;
var email = emailMap[selectedID] || "";
console.log("Selected:", selectedID, "Setting email:", email);
emailField.value = email;
}
nameField.addEventListener('change', updateEmail);
updateEmail();
} else {
console.log("Fields not found. Double-check field names.");
}
});
</script>
ps. it runs fine if i try to manually run it via console
Hi @sai sreekar
IFTTT in ConfiForms is triggered as a result of the form submit - it cannot run on page load
If you want your JavaScript to run on page load then just put it to run on a page load - https://support.atlassian.com/confluence/kb/how-to-use-javascript-in-confluence/
Alex
Good Morning @Alex Medved _ConfiForms_
when you said just put run on page load do you mean the Fire IFTTT action only when this condition/filter is met and if yes what can i put for to run it on page load and if not can you please tell me
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What I am saying is that if you want to run some JavaScript on a page load then there is no need for ConfiForms
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good Morning @Alex Medved _ConfiForms_
I have tried to use the HTML macro but i was not able to trigger it, i have tried to put in at the top which is not even in the confiform or in between the confiforms. And also in confluence when i try to add it in the macro it was never running it when the page loaded.
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it worked @Alex Medved _ConfiForms_
i had to run it before the confiform, as part of confluence, i was trying to add it in the confiform and was expecting it to work
Thank you so much @Alex Medved _ConfiForms_
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, you need to have an HTML macro outside of ConfiForms macro, to be part of the page
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @sai sreekar and welcome to the Atlassian Community!
Do you have other IFTT macros where the javascript is executed?
According to the plugin's documentation running javascript could be disabled in the general settings of the app.
Administrators could restrict this in ConfiForms general settings
Can you check this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good Morning @Charlie Misonne
i have other pages where the other js are working, i am not sure if that changes with each page , but if doesnot that should be any issue
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok then my suggestion does not apply.
@Alex Medved _ConfiForms_ 's answer is more on point since he seems to be working for the plugin vendor.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Charlie Misonne
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.