Menu

Non-Duplicate Serial Number

2014-11-19
2021-03-19
  • Daniel Ferrari

    Daniel Ferrari - 2014-11-19

    Hi..!! I need to prevent the serial number for a CI (like PC/Laptop) to be duplicated and can not find where to configure this feature.

    Can anyone help me?

    Thanks, Daniel

     
  • Romain Quetiez

    Romain Quetiez - 2014-11-21

    Hi,

    There is still no parameter for this. It requires the development of a DoCheckToWrite procedure. Such a handler should be injected by the mean of a custom module, so as to preserve the capability to upgrade iTop when a new version becomes available.

    Here is an example of such a handler, found into core/userrights.class.inc.php:


    public function DoCheckToWrite()
    {
    parent::DoCheckToWrite();

    $aChanges = $this->ListChanges();
    if (array_key_exists('login', $aChanges))
    {
        if (strcasecmp($this->Get('login'), $this->GetOriginal('login')) !== 0)
        {
            $sNewLogin = $aChanges['login'];
            $oSearch = DBObjectSearch::FromOQL_AllData("SELECT User WHERE login = :newlogin");
            if (!$this->IsNew())
            {
                $oSearch->AddCondition('id', $this->GetKey(), '!=');
            }
            $oSet = new DBObjectSet($oSearch, array(), array('newlogin' => $sNewLogin));
            if ($oSet->Count() > 0)
            {
                $this->m_aCheckIssues[] = Dict::Format('Class:User/Error:LoginMustBeUnique', $sNewLogin);
            }
        }
    }
    

    }

    Regards,
    Romain

     
  • Wasim

    Wasim - 2021-03-18

    Hi i am also facing the same issue can anybody help me how should i restrict Duplicate Serial number

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2021-03-18

    Nowadays you'd need to create an extension which puts a uniqueness rule on the class, so serial number has to be unique.

     
    • Wasim

      Wasim - 2021-03-19

      Thank you for replying....can you please share any sample files which are working.

      As i am new to the system not getting exactly in which files i have to do the changes.

       
  • Pierre Goiffon

    Pierre Goiffon - 2021-03-18

    Hello,

    Wassim please next time open a dedicated thread instead of adding a reply in an old one !

    Jeffrey : yes exactly !

    See this wiki page to learn everything about uniqueness rules : Prevent duplicates [iTop Documentation]

     
    • Wasim

      Wasim - 2021-03-19

      Sure Pierre will create a new thread..

       
      🎉
      1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.