You are not logged in.
Hi everyone,
can anybody help me to find out why notes in asset templates not working? I would like to have a note field in a template that should be set to any created computer based on this template. I can save the note in the template, thats works fine. I can see the note when i create a new computer but when i save the new computer based on the template, all informations are saved but only the notes are missing.
Does anyone have the same problem and solved this?
Thanks for help.
Offline
For which version of GLPI?
For which object?
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline
Sorry,
i forgot. I have updated glpi from 9.2.1 to 9.2.2. In both Versions is the same issue. I want to save the note to the computer object. Or want do you mean with object?
Thanks.
Offline
Hi @all,
i have solved this problem by myself. It is only a workaround, so i hope this issue would be fixed in other versions. For all of you which have the same issue, here my solution.
I wrote a trigger in the glpi mysql database for the table "glpi_computers". The Trigger makes after an insert to the computer table an another insert in the notes table with an reference to the new created computer. Before it makes an insert, the trigger checks if the computertemplate has notes. If notes exists in the computertemplate it will iterate through the template notes and save them as new notes with an reference to the new computer.
Here is the Code:
CREATE DEFINER=`USERNAME`@`localhost` TRIGGER `glpi`.`glpi_computers_AFTER_INSERT` AFTER INSERT ON `glpi_computers` FOR EACH ROW
BEGIN
DECLARE v_itemtype VARCHAR(255) DEFAULT 'Computer';
DECLARE v_timestamp DATETIME DEFAULT NOW();
DECLARE v_note TEXT;
DECLARE v_notecount INT(11);
DECLARE v_done TINYINT DEFAULT FALSE;
DECLARE c_notes CURSOR FOR SELECT
glpi_notepads.content
FROM
glpi_notepads
JOIN
glpi_computers ON glpi_notepads.items_id=glpi_computers.id
WHERE
glpi_computers.is_template=1
AND
glpi_computers.template_name=NEW.template_name
AND
glpi_notepads.itemtype=v_itemtype;
OPEN c_notes;
SELECT FOUND_ROWS() INTO v_notecount;
l_fetch_data: LOOP
FETCH c_notes INTO v_note;
IF v_done THEN
LEAVE l_fetch_data;
CLOSE c_notes;
END IF;
IF v_notecount > 0 THEN
INSERT INTO
glpi_notepads
(itemtype, items_id, date, date_mod, users_id, users_id_lastupdater, content)
VALUES
(v_itemtype,NEW.id,v_timestamp,v_timestamp,NEW.users_id_tech,NEW.users_id_tech, v_note);
END IF;
END LOOP l_fetch_data;
END
Hope this helps.
Last edited by dormaich (2018-03-27 09:23:41)
Offline
Ticket opened: https://github.com/glpi-project/glpi/issues/3798
Correction: https://github.com/glpi-project/glpi/pull/3799 (it's the same for 9.2.x)
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline