To my knowledge that's not possible/easy
Maybe adding some PHP code on the method DoCheckToWrite() to control that at least one attachment was added.
An other option is to add a AttributeFile to the Ticket class and make it mandatory at resolution time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thanks, I found the solution
$oqlObject = new DBObjectSet(DBObjectSearch::FromOQL("SELECT Attachment WHERE item_id = $item_id"), array(), array());
$attachment = $oqlObject->Fetch();
if(!$attachment)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I want to make it mandatory for my users to link at least one attachment to a ticket on resolution.
What are the steps to do it ?
Thank you
Best regards
To my knowledge that's not possible/easy
Maybe adding some PHP code on the method DoCheckToWrite() to control that at least one attachment was added.
An other option is to add a AttributeFile to the Ticket class and make it mandatory at resolution time.
Hello Vdumas,
Thanks for your help, I tried by updating DoCkeckToWrite() and it works.
Can you help me, how did it work for you, I can’t do the same?
From iTop 3.1 onwards you could also use an event listener ( EVENT_DB_CHECK_TO_WRITE ) .
So, you need to create an extension with a bit of PHP code in it to enforce this requirement.
https://www.itophub.io/wiki/page?id=latest:customization:events_api
https://www.itophub.io/wiki/page?id=3_2_0:extensibility:events_crud
Thank you. But I have version 3.0, I wrote the code but it doesn't seem to work
$status = $this->Get('status');
$item_id = $this->Get('id');
if ($status == 'registered') {
$oqlObject = new DBObjectSet(DBObjectSearch::FromOQL("SELECT Attachment WHERE item_id = $item_id"), array(), array());
if($attachment = $oqlObject->Fetch())
{
$this->m_aCheckIssues[] = Dict::S('Class:Ticket/Error:NoManager');
return;
} else{
$this->m_aCheckIssues[] = Dict::S('Class:Ticket/Error:Error8');
return;
}
}
So registered is a custom state you added?
thanks, I found the solution
$oqlObject = new DBObjectSet(DBObjectSearch::FromOQL("SELECT Attachment WHERE item_id = $item_id"), array(), array());
$attachment = $oqlObject->Fetch();
if(!$attachment)
You should also set a condition on the item_class, otherwise your test might be pretty false, item_id is only unique within a given class...