Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
function fieldsOnCancel(){ return " moduleid.count"; }
function onCancel(count){
	if(count <= 0){
		window.location = "Melt://showAlert/message to display to the user"; return false;
	}else{
		return true;
	}
} 


An example of a complete onCancel query with header and footer information is as follows. This is placed in the Activities Module:

Code Block
<html><head><title>onCancel</title><script type="text/javascript">> 
 
function fieldsOnCancel(){ return "7.count"; }
function onCancel(count){
	if(count <= 0){
		window.location = "Melt://showAlert/You can not cancel this record, at least one Activity record is required for this Lead";
		return false;
	}else{
		return true;
	}
}
</script></head><body></Body><body></html> 



where:

  • function fieldsOnCancel() { return "moduleid.count"; } defines which module to count. To check the number of activity modules (module ID 7) associated with the current Lead and replace the module number with 7, the code used in the onCancel example is as follows:

...


The conditional query { if(count <=0) defines what to check for. In this case, to check if the count (that is, the number of other activity modules) is less than or equal to zero. Because this is the start of a conditional query, a left brace { is inserted at the beginning of the command.
If the condition is met, then two commands are performed: a message is displayed to tell the user why the user cannot cancel record creation, and a False result is returned preventing the user from using the Cancel button. The commands are included inside braces {}, and separated by a semicolon in the onCancel example as follows:

Code Block
{
if(count <= 0){
	window.location = "Meltmelt://showAlert/ You can not cancel this record, at least one Activity record is required for this Lead "; 
	return false;
} 

...

 

Otherwise the code below defines what happens if the conditional query is not met (that is, when other activities exist), and allows you to cancel creating the current activity. 

Code Block
else{ return true; }
}


A right brace } closes the conditional query, and the footer follows.