Menu

#2068 Prefill form failed

3.0.1
assistance
None
Data model
Medium
3.0.1
defect
2022-05-18
2022-05-18
jerry
No

Hello

I tried to follow Example 3, but failed. The start date was not automatically filled in.
Can you help me?
Thanks!

[https://www.itophub.io/wiki/page?do=export_code&id=3_0_0%3Acustomization%3Aform_prefill&codeblock=1]

XML File Path:
iTop\web\datamodels\2.x\itop-service-mgmt*datamodel.itop-service-mgmt.xml*

Code:

  <class id="CustomerContract" _delta="must_exist">
            <methods>
                <method id="PrefillCreationForm" _delta="define">
                    <static>false</static>
                    <access>public</access>
                    <type>Overload-DBObject</type>
                    <code>
                        <![CDATA[
                            public function PrefillCreationForm(&$aContextParam)
                            {
                                if(empty($this->Get('start_date')))  { $this->Set('start_date',time());}
                            }
                        ]]>
                    </code>
                </method>
            </methods>
        </class>
2 Attachments

Discussion

  • jerry

    jerry - 2022-05-18

    Hello
    In addition, I used the ToolKit and compiled it successfully。

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-05-18

    Hello,
    Did you modify datamodels\2.x\itop-service-mgmt\datamodel.itop-service-mgmt.xml directly ?
    This isn't the way customizations are done in iTop : indeed if you modify core iTop files, you will loose all of those modifications on next iTop update. You should better use the standard customization mechanism which are extensions !

    See the first link in the wiki page you were refering to :

    Prerequisite: You must be familiar with the Syntax used in Tutorials and have already created an extension.

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-05-18
    • status: new --> assistance
    • assigned_to: Pierre Goiffon
     
  • Vincent @ Combodo

    I have just tested again to be sure, it works like a charm, so the code example isn't the root cause.

     
  • Vincent @ Combodo

    Except that I have not set that tag, also I am not sure of its impact/usage

      <type>Overload-DBObject</type>
    

    So even if the XML reference states that it is mandatory, it's seems not to be...

     

    Last edit: Vincent @ Combodo 2022-05-18
  • jerry

    jerry - 2022-05-18

    Thank you for your reply!

    datamodels\2.x\itop-service-mgmt\datamodel.itop-service-mgmt.xml
    I modified it according to the example and added the PrefillCreationForm method under the CustomerContract class,I think that's right。

    I don't know where the problem is and where it's not configured correctly。

    Is there a complete example of automatic filling of fields?

    <type>Overload-DBObject</type>
    I'll try to delete this code and have a try again。

    Look forward to your reply!

     
  • jerry

    jerry - 2022-05-18

    <type>Overload-DBObject</type>
    I deleted the code and failed. The start time of field is not prefilled.

    The attachment is my xml file.
    In addition to changing the XML file, are there any other files that need to be modified?

    Look forward to your reply!

     
  • Vincent @ Combodo

    I am sorry, but modifying the iTop source code is not a supported method to customize iTop. I am not going to check why it's failing using that hack.
    I have tested it creating an iTop extension and that's the only way to customize iTop.
    In addition, this method supports transparent iTop version upgrade, while modifying iTop source files does not.

     
    👍
    1
  • jerry

    jerry - 2022-05-18

    Thank you for your reply.
    ITOP extension can be customized, I see.

     
  • jerry

    jerry - 2022-05-18

    Can you send me your test extension and xml files for reference.

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-05-18

    Hello Jerry,
    Everything is documented in the wiki, look at the link I was emphasis.
    If something isn't clear and if you have any suggestion to clarify the documentation, let us know.

     
  • jerry

    jerry - 2022-05-18

    Thank you very much!
    I have implemented my extension.
    If I have new questions, please let me contact you.

     
  • Pierre Goiffon

    Pierre Goiffon - 2022-05-18

    I'm glad you made it ! You will discover a whole new world as an iTop user :)
    For any further questions, just go to the forums ("discussion" tab, "create topic" button)

     

Log in to post a comment.

MongoDB Logo MongoDB