Documentation

crm.deal.add

crm.deal.add(fields, params)

The method creates a new deal.

Parameters

Parameter Description
fields An array that specifies the parameters for the new deal ("field"=>"value"[, ...]). See the example for the array specification.
Note: to find out the required field format, execute the method crm.deal.fields to view the retrieved field format.
params Set of parameters. REGISTER_SONET_EVENT - registers deal adding event in the activity stream. Additionally, notification will be sent to the responsible for the deal.

Example

	var current = new Date();
var nextMonth = new Date();
nextMonth.setMonth(current.getMonth() + 1);
var date2str = function(d) 
{
	 return d.getFullYear() + '-' + paddatepart(1 + d.getMonth()) + '-' + paddatepart(d.getDate()) + 'T' + paddatepart(d.getHours()) + ':' + paddatepart(d.getMinutes()) + ':' + paddatepart(d.getSeconds()) + '+03:00';
};
var paddatepart = function(part)
{
	 return part >= 10 ? part.toString() : '0' + part.toString();
};
	
BX24.callMethod(
	"crm.deal.add", 
	{
		fields:
		{ 
			"TITLE": "Regular sale", 
			"TYPE_ID": "GOODS", 
			"STAGE_ID": "NEW", 					
			"COMPANY_ID": 3,
			"CONTACT_ID": 3,
			"OPENED": "Y", 
			"ASSIGNED_BY_ID": 1, 
			"PROBABILITY": 30,
			"CURRENCY_ID": "USD", 
			"OPPORTUNITY": 5000,
			"BEGINDATE": date2str(current),
			"CLOSEDATE": date2str(nextMonth)					
		},
		params: { "REGISTER_SONET_EVENT": "Y" }	
	}, 
	function(result) 
	{
		if(result.error())
			console.error(result.error());
		else
			console.info("Created deal with ID " + result.data());
	}
);	


© «Bitrix24», 2001-2022
Up