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.
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());
	}
);	


User Comments

User comments are not part of official documentation. Use information provided by other users in the comments at your own risk.

The User Comments section is not to be used as a feature discussion board. Only registered users can post comments. Your comment will be visible once it has been approved by the moderator.
© «Bitrix Inc.», 2001-2017, «Bitrix Inc.», 2017