Menu

Replace field value on display, edit/modify, and add/new AND remove field value modification log from history tab

ray
2021-07-29
2023-02-09
  • ray

    ray - 2021-07-29

    Hi All,

    I hope all of you are well.

    I am just wondering on how to replace field value on display, edit/modify, and add/new. I believe for edit/modify and add/new, I should overload GetAttributeFlags and GetInitialStateAttributeFlags from https://www.itophub.io/wiki/page?id=latest%3Acustomization%3Aread-only-field. How do I change just the display value in this case (i.e. database existing value is kept), (i.e. in the example from documentation, we are just making it read-only, how do I change just the display value while keeping the DB value)? Additionally, how do I implement this for display (what method should be overloaded?)?

    <method id="GetAttributeFlags" _delta="define">
              <static>false</static>
              <access>public</access>
              <type>Overload-DBObject</type>
              <code><![CDATA[   public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
        {
            // This function is invoked when the object is EDITED on the Console
        // It is called for each and every field of the object, 
        // but we just want to change the behavior for a single field
        if ($sAttCode == 'password_field')
        {
            // Combine the new Flag with those impose by a parent class
            return(OPT_ATT_READONLY | parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState));
        }
        return parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState);
        }
    ]]></code>
            </method>
    
       <method id="GetInitialStateAttributeFlags" _delta="define">
              <static>false</static>
              <access>public</access>
              <type>Overload-DBObject</type>
              <code><![CDATA[   public function GetInitialStateAttributeFlags($sAttCode, &$aReasons = array())
        {
            // This function is invoked when the object is CREATED on the Console
        // It is called for each and every field of the object, 
        // but we just want to change the behavior for a single field
        if (($sAttCode == 'password_field'))
        {
            // Combine the new Flag with those imposed by a parent class
            return(OPT_ATT_READONLY | parent::GetInitialStateAttributeFlags($sAttCode, $aReasons));
        }
        // For other fields ask the parent class to do the job
        return parent::GetInitialStateAttributeFlags($sAttCode, $aReasons);
        }
    ]]></code>
            </method>
    

    Finally, just wondering if someone could help me if I could remove log for certain field showing in history tab on add and modification? Is there any reference to perform this?

    The main goal is to implement password field with AttributeEncryptedString without using AttributePasswordsince it seems that AttributePassword is unencrypted in DB...

    For example, please refer to attachment.

    Thank you very much in advance.

    Kind regards,
    Ray

     

    Last edit: ray 2021-07-29
  • ray

    ray - 2021-07-29

    For example, when modifying iTop user password, the history tab only shows the following (it doesn't show previous value). Please refer to attached image

     
  • Pierre Goiffon

    Pierre Goiffon - 2021-07-29

    Hello,

    Can you give more details on what you are trying to do ? Functionnaly speaking I mean ?

    About UserLocal.password, it is an AttributeOneWayPassword and not a standard AttributeString like User.login

     
  • ray

    ray - 2021-07-29

    Hello Pierre,

    Thank you for the response!

    I am trying to create a field named password under NetworkDevice class using AttributeEncryptedString to store password of the network device.

    The issue with using AttributeEncryptedString to store password is that the password is displayed in plaintext when navigating to the NetworkDevice class. I have managed to hide the password value on operation=details,modify,and new using JavaScript.

    My concern now is that when the password field value is modified. It will show the previous modified value which is in plaintext in the History tab of NetworkDevice. I am wondering if there's any way to ensure that the modified previous value is NOT shown in the History tab (perhaps just show "<field name (i.e. password in this case)> modified") using back-end (i.e. PHP and iTop extensions). If not, I might try to use JS again to try to hide the previous modified value in History tab but this is NOT the ideal solution.

    Just like when modifying existing iTop user, when changing the password value, it just shows in history that "Password has been modified" and it does NOT show the previous value of that modified password (please refer to attached image).

    Thank you very much in advance and please let me know if you have any other questions.

    Kind regards,
    Ray

     
    • Pierre Goiffon

      Pierre Goiffon - 2021-07-30

      I bet the fact that the value doesn't appear with AttributePassword is caused by \AttributePassword::GetAsHTML ?
      When using AttributeEncryptedString there are no override of this method, so we are using the one from the hierarchy.

      I'll have a word with our product team, seems odd :/

       
    • Pierre Goiffon

      Pierre Goiffon - 2021-07-30

      After some chat with my colleagues, here are some additional info :)

      There are 3 attribute types that can be used to store passwords :

      As stated before the passwords for local iTop users (UserLocal.password) are stored in AttributeOneWayPassword

      To create a password database to access your assets, you can add some new AttributeEncryptedString field in the needed classes. But indeed there are not much functionalities to hide values, offer copy to clipboard, etc.
      We didn't want to add those functionalities and aren't planning on adding them.

      You could add your own AttributeDefinition in a custom module though... and iTop is open to contributions O:)

       
      • ray

        ray - 2021-08-02

        Hi Pierre,

        Apologies for the very late reply!

        Thank you very much for the information. I will have a look at implementing some security feature for the history tab using AttributeEncryptedString 😅

         
  • daniela lazzari

    daniela lazzari - 2023-01-16

    Hello, I'm new to these forums. I hope someone can help me.
    I should change the properties of an attribute from "NULL ALLOWED" to " NULL NOT ALLOWED" . The field to modify is "User Satisfaction" inside the UserRequest and Incident classes. It's possible to do it? Do you know how to do it?
    Can you help me? Thank you so much

     
    • Vincent @ Combodo

      Hi Daniela,
      Having the "User Satisfaction" moved to "NULL NOT ALLOWED" regardless of the UserRequest status, has no sense, it would force the user to fill that field at UserRequest creation...
      If you want to force it when the UserRequest is closed, then this can be done with a flag on the transition

       
  • daniela lazzari

    daniela lazzari - 2023-01-16

    Ok Vincent, thank you so much. You're right, it doesn't make sense to make it mandatory by default . I need to make it mandatory when the portal user close the UserRequest or the Incident. What you say... " with a flag on the transition" it's possible to do with an extension?

     
  • Vincent @ Combodo

    Absolutely. It's much easier to do it for Combodo's customer, as it's a few clicks in the ITSM Designer and job done, but it is still possible for the Community by writing an iTop extension

     
  • daniela lazzari

    daniela lazzari - 2023-01-17

    Good morning Vincent,
    thanks at first! I don't know the ITSM Designer but now I'm reading something about it and I'm trying to understand how to use it. Could you explain me how could i handle my problem with ITSM Designer? ... if it's possible...

     
  • Pierre Goiffon

    Pierre Goiffon - 2023-02-09

    Hello,
    The ITSM Designer is an online saas tool provided to Combodo customers. It ease customizations : almost all of them can be done with just a few clicks. See https://www.combodo.com/itsm-designer-195
    If you don't have an active service subscription though,n you'll have to code the customization yourself.
    Look at the tutorial Vincent linked to, it explains every step of the way !

     

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.