Hello everyone,
I cam across a confusing problem.
As I wanted to save a variable when the submit button on a form is pressed, I could not find a event type working.
I tried the button.onSubmit() and button.onClick() after using a JQuery selector to store the Element inside it.
Is there a way to get the triggerevent of a button in a form? I usually take the id of the element if possible:
Hi @Lucas001 ,
I had to experience similar scenario in the past where I had to show an extra button to do some Api calls with external system. Here is the way how you can add an additional button on Portal profile page and give you control to run your script.
1- Go to Web Pages
2- Open Profile -> Content Page
3- Advance -> Add script
$(document ).ready(function() {
$('#ContentContainer_MainContent_MainContent_ContentBottom_SubmitButton').after('<input type="button" value="Sync With Oracle" onclick="javascript:clearIsDirty();disableButtons();window.history.back();" id="CancelButton" class="btn btn-primary"/>')
});
Here are the results:
Thanks,
Saud
Please mark as verified if the answer is helpful.
Thanks @Fubar and @saudali_25,
to specify my problem a bit more. I have a oracledatabase as backend which needs to check the account data of the newly registered people. So that they are not allowed to make specific actions. They receive a mail and so but I also want to display a message on the profil form which tells the client that their data is currently being processed. Usually a flag is than send and javascript does the rest. Sometimes however the flow or the connection between dataverse and the power page seems to be slow or not fast enough, so that the message is not displayed.
As it is the profile web form which is displayed, I cannot access it via the portal management system. Do you have another solution where I could place Javascript in? To get the click or onSubmit when I write JavaScript into the site itself, is not working on my site.
Similar to the post above from saudali. It may depend on exactly what you are trying to do (e.g. if you needed to capture the User making the submission you would use form Metadata and not something on the Submit, similarly some values you may set on create/change using a Workflow or Plugin code).
When the Submit button is pressed the form will call a Validator, that you can add your own validations to (so this is one place that you know the submit button has been pressed and may be able to add what you want in there).
Hi @Lucas001 ,
I'm unsure, what is your actual use case but generally whenever we have to do some sort of validation etc. on form submission, we do by using jQuery. You can navigate to Additional setting if you're using a Basic Form and put your script there.
Here is the sample script for reference:
if (window.jQuery) {
(function ($) {
if (typeof (entityFormClientValidate) != 'undefined') {
var originalValidationFunction = entityFormClientValidate;
if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
entityFormClientValidate = function() {
originalValidationFunction.apply(this, arguments);
// do your custom validation here
// return false; // to prevent the form submit you need to return false
// end custom validation.
return true;
};
}
}
}(window.jQuery));
}
If you have added a custom button on form, then you can capture events by jQuery as well.
Please mark as verified if the answer is helpful.
Thanks
WarrenBelz
146,771
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,091
Most Valuable Professional