Name

x_snc_codesanity.PrepareNewCheck

Description

The function is to be called in a display business rule to prepare a new check.

Script

function PrepareNewCheck(grCheck)
{
  var IsValidRecord = x_snc_devtools.IsValidRecord;
  var GetStringValue = x_snc_devtools.GetStringValue;


  if (IsValidRecord(grCheck) == false)
  {
  	return;
  }
  
  if (grCheck.isNewRecord() == false)
  {
  	return;
  }
  
  if (GetStringValue(grCheck.category) != 'code_sanity')
  {
  	return;
  }

  var strClassName = grCheck.getRecordClassName();
  
  if (strClassName == 'scan_script_only_check')
  {
  	gs.addErrorMessage('Script only checks will not run when scanning a scoped application or a point scan.<br/>They are not suitable for the CodeSanity suite.<br/>Are you sure you want to add a script only check to the CodeSanity suite?');
  	return;
  }
  
  if (   strClassName != 'scan_table_check'
  	&& strClassName != 'scan_column_type_check'
  	&& strClassName != 'scan_linter_check')
  {
  	return;
  }

  if (strClassName == 'scan_table_check')
  {
  	current.advanced = true;
  	current.script = 
  		"(function (engine) {\n"
  		+"\n"
  		+"   if (x_snc_codesanity.IsCheckApplicableToRecord())\n"
  		+"   {\n"
  		+"      // Add your advanced code here\n"
  		+"   }\n"
  		+"\n"
  		+"})(engine);";
  }

  
  if (strClassName == 'scan_linter_check')
  {
  	current.script = 
  		"(function (engine) {\n"
  		+"\n"
  		+"   if (x_snc_codesanity.IsCheckApplicableToRecord())\n"
  		+"   {\n"
  		+"      // Add your advanced code here\n"
  		+"   }\n"
  		+"\n"
  		+"})(engine);";
  }	
  
  if (strClassName == 'scan_column_type_check')
  {
  	current.script = 
  		"(function (engine) {\n"
  		+"\n"
  		+"   if (x_snc_codesanity.IsCheckApplicableToRecord())\n"
  		+"   {\n"
  		+"      // Add your advanced code here\n"
  		+"   }\n"
  		+"\n"
  		+"})(engine);";
  }		
  
  
}

Sys ID

9605c643db1d1510dcbdd03cd396194a

Offical Documentation

Official Docs: