Documentation

crm.activity.add

crm.activity.add(fields)

Creates and adds a new activity object.

Parameters

Parameter Description
fields An array in format array("field"=>"value"[, ...]) containing values of the activity fields.

Variants of fields value uses

    For activities of e-mail type:
  • if an e-mail should not be sent, then DIRECTION=2 shall be specified as COMPLETED='N';
  • if e-mails are required to be marked as completed, then an update must be performed with completion flag specified.

Example

	    var d = new Date();
		d.setDate(date.getDate() + 7);
		d.setSeconds(0);	
		var dateStr = d.getFullYear() + '-' + paddatepart(1 + d.getMonth()) + '-' + paddatepart(d.getDate()) + 'T' + paddatepart(d.getHours()) + ':' 
                     + paddatepart(d.getMinutes()) + ':' + paddatepart(d.getSeconds()) + '+00:00';                   
                var paddatepart = function(part)
                {
                     return part >= 10 ? part.toString() : '0' + part.toString();
                }
		
		BX24.callMethod(
			"crm.activity.add", 
			{
				fields:
				{ 
                                        "OWNER_TYPE_ID": 2, //from the method crm.enum.ownertype: 2 - "activity" type 
					"OWNER_ID": 102, //activity ID
					"TYPE_ID": 2, // see crm.enum.activitytype
					"COMMUNICATIONS": [ { VALUE:"+75555555051", ENTITY_ID:134,ENTITY_TYPE_ID:3 } ], //where 134 - contract id, 3 - "contact" type
					"SUBJECT": "New call",
					"START_TIME": dateStr,
					"END_TIME": dateStr,
					"COMPLETED": "N",
					"PRIORITY": 3, // see crm.enum.activitypriority
					"RESPONSIBLE_ID": 1,
					"DESCRIPTION": "Important call",
					"DESCRIPTION_TYPE": 3, // see crm.enum.contenttype
                                        "DIRECTION": 2, // see crm.enum.activitydirection
			                "WEBDAV_ELEMENTS": 
					                [
					                    { fileData: document.getElementById('file1') }
					                ],
					"FILES": 
					                [
					                    { fileData: document.getElementById('file1') }
      ] //after disk module is installed and converted from webdav, FILES can be specified instead of WEBDAV_ELEMENTS
				}
			}, 
			function(result) 
			{
				if(result.error())
					console.error(result.error());
				else
					console.info("New call with ID is created " + 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-2019, «Bitrix Inc.», 2019