Hide Print Button And Print button Trigger

Scenario

Hide Button to avoid multiple reprints

Solution:

To hide this Print button, here are the steps:

1. Create a User Event script using the following code:

if (context.type === context.UserEventType.PRINT) {
	let invoiceId = newRecord.id;
	log.debug(' Print Button Clicked', 'Invoice ID: ' + invoiceId);

	let button = form.getButton({ id: 'print' });
	button.isHidden = true;
        // Set Value to custom check box to flag already printed.
	record.submitFields({
		type: record.Type.INVOICE,
		id: invoiceId,
		values: {
			'custbody6': true,
		}
	});

}

if (context.type === context.UserEventType.VIEW) {
	let alreadyPrint = newRecord.getValue({ fieldId: 'custbody6' });


	if (alreadyPrint === true) {  
		let button = form.getButton({ id: 'print' });
		button.isHidden = true;

	}
}

Leave a comment

Your email address will not be published. Required fields are marked *