template.massadd

Description

object template.massadd(object parameters)

This method allows to simultaneously add multiple related objects to the given templates.

This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object) Parameters containing the IDs of the templates to update and the objects to add to the templates.

The method accepts the following parameters.

ParameterTypeDescription
templates
(required)
object/arrayTemplates to be updated.

The templates must have the templateid property defined.
groupsobject/arrayHost groups to add the given templates to.

The host groups must have the groupid property defined.
macrosobject/arrayUser macros to be created for the given templates.
templates_linkobject/arrayTemplates to link to the given templates.

The templates must have the templateid property defined.

Return values

(object) Returns an object containing the IDs of the updated templates under the templateids property.

Examples

Add host group “2” to a two templates.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.massadd",
  4. "params": {
  5. "templates": [
  6. {
  7. "templateid": "10085"
  8. },
  9. {
  10. "templateid": "10086"
  11. }
  12. ],
  13. "groups": [
  14. {
  15. "groupid": "2"
  16. }
  17. ]
  18. },
  19. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  20. "id": 1
  21. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "templateids": [
  5. "10085",
  6. "10086"
  7. ]
  8. },
  9. "id": 1
  10. }

Link templates “10106” and “10104” to template.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "template.massadd",
  4. "params": {
  5. "templates": [
  6. {
  7. "templateid": "10073"
  8. }
  9. ],
  10. "templates_link": [
  11. {
  12. "templateid": "10106"
  13. },
  14. {
  15. "templateid": "10104"
  16. }
  17. ]
  18. },
  19. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  20. "id": 1
  21. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "templateids": [
  5. "10073"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

CTemplate::massAdd() in ui/include/classes/api/services/CTemplate.php.