Documentation

crm.deal.recurring.add

crm.deal.recurring.add(fields)

The method adds new setting for recurring deal.

Parameters

Parameter Description
fields Set of fields - array ("field"=>"value"[, ...]) type containing values of deal fields. Required field - DEAL_ID [deal ID that have IS_RECURRING=Y] parameter specified.
Note: to find out the required field format, execute the method crm.deal.recurring.fields to view the retrieved field format.

Example

   var current = new Date();
   var nextMonth = new Date();
   var nextYear = new Date();
   nextMonth.setMonth(current.getMonth() + 1);
   nextYear.setYear(current.getFullYear() + 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.recurring.add",
       {
           fields:
           {
               "DEAL_ID": "45",
               "CATEGORY_ID": "1",
               "IS_LIMIT": "D",
               "LIMIT_DATE": date2str(nextYear),
               "START_DATE": date2str(nextMonth),
               "PARAMS": {
                   "MODE": "multiple",
                   "MULTIPLE_TYPE": "month",
                   "MULTIPLE_INTERVAL": 1,
                   "OFFSET_BEGINDATE_TYPE": "day",
                   "OFFSET_BEGINDATE_VALUE": 1,
                   "OFFSET_CLOSEDATE_TYPE": "month",
                   "OFFSET_CLOSEDATE_VALUE": 2,
               }
           }
       },
       function(result)
       {
           if(result.error())
               console.error(result.error());
           else
               console.info("recurring deal settings added. Record ID - " + result.data());
       }
   );


© «Bitrix24», 2001-2022
Up