Chceking if id exist in document or in a sesion.
Fixing edit agenda see BT#8857