Multiple Deployments of a Scheduled or Map/Reduce Script

Check whether a scheduled script has multiple deployments which are under process.

function checkDeployemnt() {
	var ss = search.create({
		type:		record.Type.SCHEDULED_SCRIPT_INSTANCE,
		filters:    [
						["status","anyof","PENDING","PROCESSING","RESTART","RETRY"]
						,"AND",
						["script.scriptid",search.Operator.IS,runtime.getCurrentScript().id]
						,"AND",
						["scriptDeployment.scriptid",search.Operator.ISNOT,runtime.getCurrentScript().deploymentId]
					],
		  columns:	["status", "script.internalid"]
	}).run().getRange(0,1);
	return (ss.length > 0);
}

Leave a comment

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