Jump to content

Check Box When Download Button Is Clicked


Recommended Posts

I'm trying to make a simple 'counter' style workflow on my page. It is a Letter Style page that is meant to be downloaded and printed out. 

What I am trying to do is differentiate what records have been printed and what records have not been. I've created a field in my table called Print_Checkbox that I was going to use for this. I wrote a little script trying to get it to work, however I freakin suck at this compared to you guys. I can't get it to work, but I feel it is something simple in my script that needs to be changed.

var clickHere = document.querySelector('[id*=DataDownloadButton]');  // id of download button
var pCheckBox = document.getElementById('EditRecordPrint_Checkbox');  // id of newly made Print Checkbox

clickHere.onclick = function (){
  pCheckBox.value = true;
  
};

I don't get any errors in the console, but the checkbox is not being checked.

Any help is appreciated!

Link to comment
Share on other sites

Do you have a Separate List DataPage and (Single-Record Update, or Details DataPage)?

 

I assume you have two DataPages since you can't have Inline Edit on List DataPage.

 

In this case, you would need some interface to have the two connected to each other. Let me know if you have the deployed the SRU/Details DataPage as an iframe, or as embed on the same page as the List DataPage. Also, let me know if my assumption is correct.

Link to comment
Share on other sites

23 minutes ago, DefinitelyNot31337 said:

I assume you have two DataPages since you can't have Inline Edit on List DataPage.

I only have one datapage, and it is a List Report. I never thought of the Inline Edit (which, I see now is probably effecting the way I am calling the checkbox element) because I didn't need it. All this page does is fill in a couple fields into a document to be printed - nothing is edited, and the only thing a user can do on this page is click on the print button. 

*Edit 

Now I am understanding this more. Since there is no inline edit, which I originally thought I didn't need, I cannot change the value of the checkbox. Alright, now this sucks. Lol.

Link to comment
Share on other sites

I'm trying to think of a way to do this. I can do Bulk Edit on a List Report, which I think miiiiiiight work. I'm trying to make a script that, upon the click of the DataDownloadButton, opens the bulk edit and checks the Print_Checkbox with an auto-submit button, then opens up the PDF generator. 

I'll update this post with what I find out.

*Edit

I've pulled in a lot of information and different scripts to get this going on the right track. I think. I used DN31337 auto select all script for both selecting all records on the results page and also for clicking the Print_Checkbox. I then used another script I found here to click the the Bulk Edit button. I am now trying to get this all wrapped in a click event for when the Print/Download button is clicked. I was thinking I might create a fake button to overlap the download button, then have an auto-click script to click the actual print/download link after the bulk edit is done.

//Needs to happen before Print Button Is Clicked


//Automatically select all for bulk edit
var check_all = document.querySelector(`[action*="[@cbAppKey]"] [type=checkbox][id*="HCB"]`);
setTimeout(checker, 500);

function checker() {
 check_all.click();
}


//When Print Button Is Clicked      Need wrapped in click event


//Open Grid Edit automatically - changed for Bulk Edit
function openBulkAutomatically(delay)
{
	setTimeout(
		function()
		{
			var bulkEditButton = $("[data-cb-name='BulkEditButton']")[1];
			if (bulkEditButton)
				f_dispatchEvent(bulkEditButton, "click");
		}, delay ? delay : 500);
}
function f_dispatchEvent(v_element, v_type){
 if(v_element.dispatchEvent) {
  //var v_e = new Event(v_type);
  var v_e = document.createEvent('MouseEvents');
  v_e.initEvent(v_type, true, true);
  v_element.dispatchEvent(v_e); //new Event(v_type, {"bubbles":true, "cancelable":true})
 } else if(v_element.fireEvent){
  v_element.fireEvent('on' + v_type);
 }
};
openBulkAutomatically();


//Afer Print Button Is Clicked 


//Click Printed Checkbox

var check_print = document.querySelector(`[action*="[@cbAppKey]"] [type=checkbox][id*="EnableBulkEditPrint_CheckboxCkb"]`);
setTimeout(checker, 500);

function checker() {
 check_print.click();
}

Right now, this script will select all records, bring up the Bulk Edit screen and select the printed checkbox as soon as the page loads.

Edited by kpcollier
Updated workflow
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
Reply to this topic...

×   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...
×
×
  • Create New...