I want to use the attribute db_key_field that we declare at the beginning of class when objects are displayed in a list, so that a user will be able to see their unique id number. But unfortunately whenever I call the attribute 'id' in reconciliation tag ,it shows the id doesn't exist. Any help will be appreciated.
Hi Vincent, Thank you so much for your response. I would appreciate if you can nudge me towards the right direction here. Here is my code:
<field id="counter" xsi:type="AttributeInteger">
<values>
<value><![CDATA[return $this->GetKey();]]></value>
</values>
<sql>counter</sql>
<is_null_allowed>true</is_null_allowed>
<always_load_in_tables>true</always_load_in_tables>
</field>
but this didnt work. Would you please tell me what changes can I make here?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@cisou I have tried this code which only replaces the value with -1.
<method id="OnInsert">
<static>false</static>
<access>protected</access>
<type>Overload-DBObject</type> <![CDATA[
protected function OnInsert()
{</method>
I assume since its onInsert and the key field was not created yet, its returning -1. but I tried the same code but using the AfterInsert() method which should have worked but when I use the AfterInsert method the value of counter doesnt get updated at all.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I want to use the attribute db_key_field that we declare at the beginning of class when objects are displayed in a list, so that a user will be able to see their unique id number. But unfortunately whenever I call the attribute 'id' in reconciliation tag ,it shows the id doesn't exist. Any help will be appreciated.
Anybody can help please?
No, it's not possible to display this id. You have to copy it in a php method AfterInsert in another field which can be displayed.
Hi Vincent, Thank you so much for your response. I would appreciate if you can nudge me towards the right direction here. Here is my code:
<field id="counter" xsi:type="AttributeInteger">
<values>
<value><![CDATA[return $this->GetKey();]]></value>
</values>
<sql>counter</sql>
<is_null_allowed>true</is_null_allowed>
<always_load_in_tables>true</always_load_in_tables>
</field>
@cisou I have tried this code which only replaces the value with -1.
<method id="OnInsert">
<static>false</static>
<access>protected</access>
<type>Overload-DBObject</type>
<![CDATA[
</method>protected function OnInsert()
{
I assume since its onInsert and the key field was not created yet, its returning -1. but I tried the same code but using the AfterInsert() method which should have worked but when I use the AfterInsert method the value of counter doesnt get updated at all.
Last edit: Abdullah Noman 2023-04-13
I would indeed also just use AfterInsert(), then perhaps
Thank you so much Jeff. It worked. Really appreciate your help.
Hello,
To dig more in the hooks order in the CRUD stack :
https://www.itophub.io/wiki/page?id=3_0_0:customization:sequence_crud