Anybody knows what do I need to modify in order to set a attribute as non-duplicate attribute between objects of the same class? Now I can add objects with the same name and serial number for example. I would like prevent that someone adds a object that already exists.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had a similar problem. My solution is quite inconvenient...
In my self-developed module with the class "DNS" each domain name has to be unique.
Therefore I use the method "DoCheckToWrite" (based on userrights.class.inc.php). The function ensures that you cannot add a domain that already exists.
Maybe a starting point for you...
Best regards
Alexander
XML Code snippet (example code from userrights.class.inc.php):
<methodid="DoCheckToWrite"><static>false</static><access>protected</access><type>Overload-DBObject</type><code><![CDATA[ public function DoCheckToWrite() { parent::DoCheckToWrite(); // Note: This MUST be factorized later: declare unique keys (set of columns) in the data model $aChanges = $this->ListChanges(); if (array_key_exists('login', $aChanges)) { $sNewLogin = $aChanges['login']; $oSearch = DBObjectSearch::FromOQL_AllData("SELECT User WHERE login = :newlogin"); $oSet = new DBObjectSet($oSearch, array(), array('newlogin' => $sNewLogin)); if ($oSet->Count() > 0) { $this->m_aCheckIssues[] = Dict::Format('Class:User/Error:LoginMustBeUnique', $sNewLogin); } } }]]></code></method>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maybe for others: I wrote a small SAMPLE extension "alx-conf-module-infra":
Features:
- Server Class: define Server name as unique
- Server Class: additional field "local_disk"
- IPinterface Class: allow interface speed up to 10.000 MBit/s (7 digits)
- Language Files DE/EN
Anybody knows what do I need to modify in order to set a attribute as non-duplicate attribute between objects of the same class? Now I can add objects with the same name and serial number for example. I would like prevent that someone adds a object that already exists.
Thanks!
Hi,
Did you get this fixed, i have the same issue!
Kind regards
Hi,
I had a similar problem. My solution is quite inconvenient...
In my self-developed module with the class "DNS" each domain name has to be unique.
Therefore I use the method "DoCheckToWrite" (based on userrights.class.inc.php). The function ensures that you cannot add a domain that already exists.
Maybe a starting point for you...
Best regards
Alexander
XML Code snippet (example code from userrights.class.inc.php):
Hi Alexander,
Thank you for your response.
Would you mind sharing the code for your DNS class please, as i want to see how you have implemented the above code.
Many Thanks
Never mind, i managed to configure it - and it works a charm!
Thank you once again Alexander
I'm glad I was able to help :)
Maybe for others: I wrote a small SAMPLE extension "alx-conf-module-infra":
Features:
- Server Class: define Server name as unique
- Server Class: additional field "local_disk"
- IPinterface Class: allow interface speed up to 10.000 MBit/s (7 digits)
- Language Files DE/EN
Install:
Best regards
Alexander