Methods > glpi.linkObjects

Version Comments
1.3.0 no change
1.2.0 must be super admin to use this method
1.1.0 Method added

This method is only accessible by authenticated and super-admin users

Link an object to another (when is not possible with glpi.createObjects method).

input hastable

  • help : for showing parameters name, type, and mandatory/optional
  • fields : an array for link 2 Object(s) in GLPI

Obviously the parameters are same as glpi.createObjects method for this method, but the array-structure is changed again.

  • from_item array : the informations of main object that you want to connect to another object.
  • to_item array : the informations of slave object that you want to connect to the main object.
['fields'] = array(

   array('from_item' =>array( 'itemtype'=>'Computer',
                              'id'=>30),
         'to_item'   =>array( 'itemtype'=>'DeviceHardDrive',
                              'id'=>1,
                              'quantity'=>10,
                              'specificity'=>500)
      ),

   array('from_item' =>array( 'itemtype'=>'Computer',
                              'id'=>31),
         'to_item'   =>array( 'itemtype'=>'Monitor',
                              'id'=>25)
      )
);
In this example :
  • You provide 10 (with a specificity = 500) new connections of the DeviceHardDrive with ID = 1 on Computer with ID = 30.
  • You attach the Monitor with ID = 25 to the Computer with ID = 31