Suitelet API for unsubscribing the campaigns

Suitelet

Unsubscribe the customer global subscription status to Opt out.

/**
 * @NApiVersion 2.x
 * @NScriptType Suitelet
 * @NModuleScope SameAccount
 **/
 /*******************************************************
 *Unsubscribe news letter in customer Record
 ********************************************************/
define(["N/record"],function(record){
var OPT_OUT  = "globalsubscriptionstatus";

var SUCCESS  = "<html><head></head><body><script>window.alert('Success');window.location.href='https://www.nickollsandperks.co.uk'</script><body></html>"


	function unSubscribe(c)
	{
			try
			{


		var customer  = c.request.parameters.customer;
		if(customer)
		{
			var values={};
			values[OPT_OUT]=2;
			log.debug("values",values);
			record.submitFields({
				id:customer,
				type:"customer",
				values:values

			});
			c.response.write(SUCCESS);	
		
		}


			}
			catch(err)
			{
			log.debug("error@unSubscribe",err);
			}

		}

			

return {
	onRequest:unSubscribe
}

})

Leave a comment

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