You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2018-04-21 05:51:57

nvnam
Member
Registered: 2017-10-20
Posts: 10

How to add and update custom fields plugin with api

How to add and update value custom fields plugin with api REST?
Please help me,
Thanks

Offline

#2 2019-07-29 10:39:54

ronnie.peeters
Member
From: Eindhoven, the Netherlands
Registered: 2016-10-09
Posts: 72

Re: How to add and update custom fields plugin with api

Same question here. Someone succeeded in this?
I am unable to find ANY documentation about it


GLPI 9.4.3 - Currently in Dev environment - preparing for production
-Preparing data migration from OSTicket to GLPI for the Ticketing/Helpdesk part.
-Preparing data migration from OrangeSCRUM to GLPI for the project management part.
@Working at a company that is responsible for the IT environment of over 4500 employees that have IT assets

Offline

#3 2019-07-29 10:59:29

Jean-Christophe
Moderator
Registered: 2007-08-22
Posts: 734

Re: How to add and update custom fields plugin with api

Hello,

For instance, if you created a field "custom inventory number" in the computer object, you can read, write and update the field thru the computer object using the field name "custominventorynumberfield".

As simple as that :-)

Offline

#4 2019-07-29 12:21:55

ronnie.peeters
Member
From: Eindhoven, the Netherlands
Registered: 2016-10-09
Posts: 72

Re: How to add and update custom fields plugin with api

Would it be so simple ... ? Let me try that. Thanks for the info!


GLPI 9.4.3 - Currently in Dev environment - preparing for production
-Preparing data migration from OSTicket to GLPI for the Ticketing/Helpdesk part.
-Preparing data migration from OrangeSCRUM to GLPI for the project management part.
@Working at a company that is responsible for the IT environment of over 4500 employees that have IT assets

Offline

#5 2019-07-29 13:31:12

Jean-Christophe
Moderator
Registered: 2007-08-22
Posts: 734

Re: How to add and update custom fields plugin with api

do not forget the "field" part at the end of the field's name ;-)

Offline

#6 2019-07-29 13:36:43

ronnie.peeters
Member
From: Eindhoven, the Netherlands
Registered: 2016-10-09
Posts: 72

Re: How to add and update custom fields plugin with api

I saw the field getting it from the rest api:


id                          : 8
name                        : lastupdatetimestampfield
label                       : Last Update Timestamp
type                        : datetime
plugin_fields_containers_id : 2
ranking                     : 3
default_value               :
is_active                   : 1
is_readonly                 : 0
mandatory                   : 0
links                       : {@{rel=PluginFieldsContainer; href=https://myglpiserver/apirest.php/PluginFieldsContainer/2}}

Now I am struggling with another issue, I am unable to update any field. Asked a question about that in a new post.


GLPI 9.4.3 - Currently in Dev environment - preparing for production
-Preparing data migration from OSTicket to GLPI for the Ticketing/Helpdesk part.
-Preparing data migration from OrangeSCRUM to GLPI for the project management part.
@Working at a company that is responsible for the IT environment of over 4500 employees that have IT assets

Offline

#7 2019-07-30 21:59:12

ronnie.peeters
Member
From: Eindhoven, the Netherlands
Registered: 2016-10-09
Posts: 72

Re: How to add and update custom fields plugin with api

Jean-Christophe wrote:

do not forget the "field" part at the end of the field's name ;-)

Thanks Jean-Christophe, for your input.


GLPI 9.4.3 - Currently in Dev environment - preparing for production
-Preparing data migration from OSTicket to GLPI for the Ticketing/Helpdesk part.
-Preparing data migration from OrangeSCRUM to GLPI for the project management part.
@Working at a company that is responsible for the IT environment of over 4500 employees that have IT assets

Offline

#8 2019-09-18 15:44:33

ronnie.peeters
Member
From: Eindhoven, the Netherlands
Registered: 2016-10-09
Posts: 72

Re: How to add and update custom fields plugin with api

Jean-Christophe wrote:

Hello,

For instance, if you created a field "custom inventory number" in the computer object, you can read, write and update the field thru the computer object using the field name "custominventorynumberfield".

As simple as that :-)

Jean-Christophe,

The update succeeds, for fields that have the block type 'Insertion in the form (before save button)'
Fields that have a block type 'Add Tab' give me still a '200 OK' at the PUT webrequest, but the update is not processed!

Anything that I am missing?


GLPI 9.4.3 - Currently in Dev environment - preparing for production
-Preparing data migration from OSTicket to GLPI for the Ticketing/Helpdesk part.
-Preparing data migration from OrangeSCRUM to GLPI for the project management part.
@Working at a company that is responsible for the IT environment of over 4500 employees that have IT assets

Offline

#9 2019-09-18 15:50:20

Jean-Christophe
Moderator
Registered: 2007-08-22
Posts: 734

Re: How to add and update custom fields plugin with api

I do not use this kind of custom field. Only the 'Insertion in form'.
Currently, I don't have any GLPI instance where I can try :-/

Offline

#10 2019-09-19 23:20:10

ecollet
Member
Registered: 2019-07-29
Posts: 34

Re: How to add and update custom fields plugin with api

Hi,
I'm intersted with this but I do not understand
"Where" is this field ?
I add a custom field 'test' (insertion in the form..) in the 'Phone' object

In a Phone /1 object, I put 'test' in the 'test' field
here what API get me : apirest.php/Phone/1/
I don't see my 'test' field !
---
   
id    1
entities_id    0
name    "tel01"
date_mod    "2019-09-18 21:50:40"
contact    ""
contact_num    ""
users_id_tech    0
groups_id_tech    0
comment    ""
serial    ""
otherserial    ""
locations_id    0
phonetypes_id    0
phonemodels_id    0
brand    ""
phonepowersupplies_id    0
number_line    ""
have_headset    0
have_hp    0
manufacturers_id    0
is_global    0
is_deleted    0
is_template    0
template_name    null
users_id    0
groups_id    0
states_id    0
ticket_tco    0
is_dynamic    0
date_creation    "2019-09-18 21:50:40"
is_recursive    0

Offline

#11 2019-09-20 06:17:20

Isia
Member
Registered: 2019-05-26
Posts: 96

Re: How to add and update custom fields plugin with api

Hello !
You must make a second call to insert the value in the custom field.
When you create a custom field group, the plugin will create a class here: / path / to / glpi / files / _plugins / fields / inc / {field group name}.
You open this file to retrieve the name of this class. ex:
"class PluginFieldsChangesixsevenseveneight extends CommonDBTM {...}"
Each class that extends "CommonDBTM" is accessible through the API.
API call:
1. initSession
2. recovery token session
3. ticket creation
4. insert value into custom fields /apirest.php/PluginFieldsChangesixsevenseveneight/
Tip: Run a test with a get query, to get the names of the fields to fill

Offline

#12 2019-09-20 11:46:36

ecollet
Member
Registered: 2019-07-29
Posts: 34

Re: How to add and update custom fields plugin with api

it's ok...
thanks

... How could I know that !? is it writen somewhere ?

I also use generic object, and the away to access extra field is more "simple"!

Last edited by ecollet (2019-09-20 11:48:25)

Offline

#13 2019-11-08 11:26:55

littleadmin
Member
Registered: 2019-11-08
Posts: 1

Re: How to add and update custom fields plugin with api

Hello together,

I'm trying to get all custom fieldvalues or just all fields.

I have tried every variation for the api request: https://myglpiserver/apirest.php/PluginFieldsCustomField but neither of them have worked.
With: /apirest.php/listSearchOptions/Computer ... I found the correct custom fields but didn't understand how to add it to my request still.
I got some "random" custom fieldvalues with .../apirest.php/search/Computer/ but I would like to get all custom fieldvalues not just a few.

I hope you can help me here

Offline

#14 2024-02-08 16:19:26

Maschik1234
Member
Registered: 2023-07-03
Posts: 26

Re: How to add and update custom fields plugin with api

How can I call up the custom fields in a computer asset? For a custom field with the name "Test", do I have to enter it like this?

$GLPI_Link + "/Computer/452/testfield

This does not work.

I would like to retrieve a custom field in an asset as in the example above and be able to update the field.

I can call up the fields or containers in this way:

$GLPI_Link + "/listSearchOptions/Computer/"
$GLPI_Link + "/PluginFieldsContainer/"

But I don't see a link to an asset or a way to change the values.

Offline

Board footer

Powered by FluxBB