I want to change the label of the ‘Save’ button to ‘Create’ or ‘Update,’ depending on whether it is a new document or an existing one. If the document is new, display ‘Create’; if the document already exists, display ‘Update’.
aslo if change any value than aslo show update
frappe.ui.form.on(‘Participant’, {
refresh: function(frm) {
// Call the function to change the submit button label
change_submit_button_label(frm);
},
});
// Define helper function to set the button label
function change_submit_button_label(frm) {
// Wait for the document to be ready
$(document).ready(function () {
// Determine if the document is new or existing
const label = frm.is_new() ? ‘Create’ : ‘Update’;
// Find the button by its class and data-label attribute
$("button.btn-primary.primary-action[data-label='Save']").each(function () {
// Change the label inside the <span> to the desired value
$(this).find("span").html(label);
});
});
}