How can I get the system to suppress the “The line...
# general
h
How can I get the system to suppress the “The line total amount is not equal to the item price times the quantity. Is this correct?” alert? Assuming we’ll have many instances of it and we’re totally fine with it and just don’t want to see the popup every time?
m
Nuclear option (not recommended!!)
Copy code
function shouldIgnoreAlert(message) {
	var IGNORED_ALERTS = [
		/^The line total amount is not equal to the item price times the quantity$/,
	];
	return IGNORED_ALERTS.some(function(regex){
		return regex.test(message);
	});
}

var nativeAlert = window.alert;
window.alert = function() {
	if (shouldIgnoreAlert(arguments[0])) {
		console.log('Alert suppressed - ' + arguments[0]);
	} else {
		return nativeAlert.apply(this, arguments);
	}
};
Please don't ask me why I have this code handy 🐵
h
Haha. Is this just a client type script I’d have to deploy? The reason this is happening in the first place is because I have another client script that recalculates the amount (multiplies qty x rate x custom field).
m
Yeah that would have to go client side
I'm not commenting on the accounting impact of doing what you are doing either
I'm guessing you already tried setting
ignoreFieldChange
to true when you set the amount and that doesn't stop the alerts?
h
That’s 2.0 right? Is there a 1.0 equivalent?
m
This is vanilla javascript, should work in 1.0 or 2.0
I strongly recommend looking for better supported suggestions before using this
h
Okay, thanks for the advice
fwiw the script you provided seems to prevent me from clicking ok/add to commit a transaction line if I enable the function as a validate line function
m
I would put this function in page init. it only needs to run once
h
like this? doesn’t seem to work even after deployed and released on the transaction
m
No. Put stick everything I gave you into a function called pageInit and set that as the page init function
h
Copy code
function pageInit(){

function shouldIgnoreAlert(message) {
	var IGNORED_ALERTS = [
		/^The line total amount is not equal to the item price times the quantity$/,
	];
	return IGNORED_ALERTS.some(function(regex){
		return regex.test(message);
	});
}
var nativeAlert = window.alert;
window.alert = function() {
	if (shouldIgnoreAlert(arguments[0])) {
		console.log('Alert suppressed - ' + arguments[0]);
	} else {
		return nativeAlert.apply(this, arguments);
	}
};
}
and use the top level function as the pageinit function? that doesn’t seem to work