Jump to content
  • 0

Auto-activate Update button in Bulk Edit form, upon opening it.


DesiLogi
 Share

Question

Hi,

Does anyone know how to auto-activate the 'Update' button in the Bulk Edits form, so the user does not have to make a selection on any of the fields, in order to Update? I have a Bulk Edit form that has fields that are 'pre-checked' for updating (see attachment) when Bulk Edits is open. I just need the 'Update' button to be activated as well so the user doesn't have to make a selection on any of the fields. 

 

Bulk Edit.jpg

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi @DesiLogi,

In order to have the records automatically updated when you bulk edit them, you can use the following script in your DataPage Footer:

<script>
document.addEventListener('DataPageReady', function (event) {
        const target = document.querySelector('body');
        const observer = new MutationObserver(mutations => {
               const updateForm = document.querySelector('#BulkUpdateFormBody');
               if(updateForm){
                      document.querySelector('input[value="Update"]').click();
               }
        });
        const config = {subtree:true,childList:true};
        observer.observe(target, config)
});
</script>

 

Link to comment
Share on other sites

  • 0

Hi KlisaN137,

Thanks for the code-- I haven't been able to get it to work, though. Is this supposed to be in the Bulk Edit form footer or the Results footer? I tried both. 

In the image above it doesn't show (because it's hidden in the form) a field called DropItem (Yes/No) that I have code (in Bulk Edit footer) that sets to DropItem = False. This works well but the issue, as per this thread, is that the Update button doesn't 'know' that DropItem has been 'selected' (by the code in the footer) and so is not 'Active.'

I need to add code to the below (that sets DropItem = false, as selected) that then makes the Update button Active (but not clicked as I need the user to click it manually). 

This code below does everything I need except actually enable the Update button. That's all I need to do... 

var checkboxName = "Enable"+ "BulkEditItems_DropItem" + "Ckb";

var checkboxName2 = "Enable"+ "BulkEditItems_ProjectID" + "Ckb";

document.getElementsByName(checkboxName )[0].checked=true;

document.getElementsByName(checkboxName2 )[0].checked=true;

document.getElementById("BulkEditItems_DropItem").checked = false;

 

Link to comment
Share on other sites

  • 0
1 hour ago, DesiLogi said:

the issue, as per this thread, is that the Update button doesn't 'know' that DropItem has been 'selected' (by the code in the footer) and so is not 'Active.'

Just a quick thought from a JS noob, apologies if it isn't helpful. I was having an issue similar to this, where I was setting or changing a value to one of my fields in JS. However, I noticed that just giving the element a value wasn't setting off other events, like some other functions or making Calculated Fields work. 

Maybe try adding something similar to this in your function that selects the DropItem checkbox, after you set the value. 

checkbox.dispatchEvent(event)

 

Link to comment
Share on other sites

  • 0

Hi kpcollier,

I think you're on the right track that DropItem needs to be 'selected' so the Update button activates. I tried the code (various versions) but still haven't gotten it to work. If I figure it out I'll post the solution. 

Link to comment
Share on other sites

  • 0

Just wanted to update this thread in case anyone needs this solution. Mykee was gracious enough to help me work this out. Here's the solution that will: 

a) set a checkbox value in Bulk Edit (in this case the field is called Items_DropItem) to be False/No.

b) activate the field for updating

Note, the first line of code is needed to set the checkbox = False/No instead of just leaving it 'unchecked' by default because some records selected for Bulk Editing may have True/Yes values. This just ensures all selected records will edit to False/No no matter. 

<script>

document.getElementById("BulkEditItems_DropItem").checked = false;

document.querySelector("input[name='EnableBulkEditItems_DropItemCkb']").click();

setTimeout(function(){

document.querySelector("input[name='EnableBulkEditItems_DropItemCkb']").dispatchEvent(new Event("change"));


}, 100);

</script>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...