Documentation

crm.automation.trigger.execute

Scope: catalog Permissions to execute: for all

Method executes a trigger. Returns true or an error with description

Parameters

Method Description Available from version
CODE Internal unique (within application) trigger identifier. Must match to the mask [a-z0-9\.\-_]
OWNER_TYPE_ID CRM entity type (Lead or Deal as listed in crm.enum.ownertype)
OWNER_ID Entity identifier

Example

function executeTrigger(code)
{
	BX24.selectCRM({
		entityType: ['lead', 'deal']
	},
	function(selected)
	{
		var typeId, id;
		if (selected['lead'] && selected['lead'][0])
		{
			typeId = 1;
			id = selected['lead'][0]['id'].substring(2);
		}
		else if (selected['deal'] && selected['deal'][0])
		{
			typeId = 2;
			id = selected['deal'][0]['id'].substring(2);
		}
		BX24.callMethod(
			'crm.automation.trigger.execute',
			{
				CODE: code,
				OWNER_TYPE_ID: typeId,
				OWNER_ID: id
			},
			function(result)
			{
				if(result.error())
					alert("Error: " + result.error());
				else
				{
					alert("Success: " + result.data());
				}
			}
		);
	});
}

© «Bitrix24», 2001-2024