_setSchedule

Sets the contents for types of Schedules in a Recurring Job (Job Types, Stock, SoR)

Parameters

id

The ID of the Recurring Job

val

A JSON-encoded string with various contents set for the Recurring Job

skip-run

An optional parameter which if set, skips the process of creating new jobs to adapt to changes in the Recurrence settings, which can be time-consuming.

Examples

In this example, Job Types has 2 entries and Schedule of Rates has 1, skip-run is not set. Job Types for the 3rd and 6th instances of the Recurrence and Schedule of Rates for the 2nd instance.

"jobtype_items" => A table of entries with both the recurrence number it is scheduled for and the Job Type id (e.g "6":"93775"). "stock_items" and "sor_items" => A table of arrays indexed by their recurrence numbers, each with 3 variables:

  • "num" => the amount

  • "id" => the ID of the Stock Type/Schedule of Rates

  • "price" => the price per item

Recurrence numbers always have a minimum value of 2.

FM_api('AppointmentRecurrence_setSchedule',[
  'id'=>'429031',
  'val'=>json_encode([
    "jobtype"=>1,
    "jobtype_items"=>[
      "3"=>"152003",6=>"152003"
    ],
    "sor"=>1,
    "sor_items"=>[
      "2"=>"[{\"num\":3,\"id\":370001,\"price\":38}]"
    ]
  ])
  ]
);

This example includes 1 schedule of Stock for the 4th recurrence the job is scheduled for and 1 Schedule of Rates for the 3rd recurrence the job is scheduled for.

FM_api('AppointmentRecurrence_setSchedule',[
  'id'=>'429027',
  'val'=>json_encode([
    "stock"=>1,
    "stock_items"=>[
      "4"=>"[{\"num\":250,\"id\":457355,\"price\":9}]"
    ],
    "sor"=>1,
    "sor_items"=>[
      "3"=>"[{\"num\":103,\"id\":370001,\"price\":12}]"
    ]
  ]),
  'skip-run'=>'1'
  ]
);

Results

On Success

{"ok":1}

On Failure

If the "id" parameter is not set or has a value less than 1:

{"error":"missing or invalid parameter: id"}

If the "val" parameter is not set:

{"error":"missing or invalid parameter: val"}

Last updated