Case Record Assignee change will clear the follow-up field

Jira code: HTL-21

Once the assigned field changed in edit mode of the case record, it should clear the follow-up date. It should run only in edit mode.

Client script

/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 * @NModuleScope SameAccount
 * @ScriptTitle HTL 6 JJ CS Case Issue field Change.js
 * @ScriptId customscript_jj_htl6_cs_case
 * @ScriptDeploymentId customdeploy_jj_htl6_cs_case
 * @Description This script is used to get the time when issue field changed to ID 8 or ID 9
 * 
 */

define(['N/currentRecord','N/format'],

		
function(currentRecord,format) {
	
	 var MODE;
	
	/***************************************************************************
	 * Function to get  next month N date 
	 * 
	 * created by aj 28/7/2018
	 ****************************************************************************/
	
	function checkDayAndMonth(dates,months,years)
	{
		// to ge the month N date
		var date = dates;
		var month = months;
		var year = years;

		if((date>31)&&((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)))
		{


			date= date-31;
			month = month+1;
			year =year

		}
		else if((date>30)&&((month==4)||(month==6)||(month==9)||(month==11)))
		{
			date= date-30;
			month = month+1;
			year =year;
		}
		else if((date>28)&&((month==2)))
		{
			date= date-28;
			month = month+1;
			year=year;
		}
		if((month==12)&&(date>31))
		{
			date= date-31;
			month = 1;
			year = year+1;
		}


		var obj = {};
		obj['date'] =date;
		obj['month'] =month;
		obj['year'] = year;
		var dateMonth = JSON.stringify(obj);

		return dateMonth;
	}
	
	
	/***************************************************************************
	 * Function to get  next month N date  -ENDS 
	****************************************************************************/
	
	
	
	 function pageInit(scriptContext) {

		
			try{
				MODE = scriptContext.mode;
			}catch(e)
			{
				//log.debug("Err@ FN ",e.message);
				console.log("Err@ pageInit FN =",e.message);
			}
	    }

	
	function fieldChanged(scriptContext) {
		try{
			/***
			 * HTL 21 Modified BY AJ on 20/11/2018 04:33 pm
			 */
			var currRecord = scriptContext.currentRecord;
			if(scriptContext.fieldId == 'assigned' && MODE=='edit')
				{
				
				
				// to set the custevent3 as empty
				
				var follow_up = currRecord.setValue({

					fieldId: 'custevent3',
					value: null


				});
				
				}
			


		}catch(e)
		{
			console.log("Err@ field change",e.message);
		}


	}




	return {
		pageInit:pageInit,
		fieldChanged: fieldChanged
	};

});

Leave a comment

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