I have a xml file name datamodel.network.xml for my extensions and inside it I have the following code:
<methods>
<method id="OnUpdate" _delta="define">
<static>false</static> <access>public</access>
<type>Overload-DBObject</type> <![CDATA[public function onUpdate() {
try { $iCommunityID = $this->Get("community");
$oCommunity = MetaModel::GetObject('Comm_clli', $iCommunityID, true, false, null);
if ($oCommunity === null) {
throw new Exception('Failed to load Community object with ID: ' . $iCommunityID);
}
$sClli = $oCommunity->Get("clli");
if ($sClli === null) {
throw new Exception('Community object with ID ' . $iCommunityID . ' does not have a value for "clli" attribute');
}
$this->Set('clli', $sClli);
$this->DBUpdate();
} catch (Exception $e) {
$this->Set('clli', null); $this->DBUpdate(); throw $e;
}
parent::OnUpdate(); }
]]>
</method>
</methods>
These codes are not compiling into the model.network.php file and I can not figure out why. If anyone have any idea please help. Thanks
Kind Regards,
Hello Guillaume,
Thanks for the quick response. I do have a model.network.php file and it is also being referenced in the module.network.php file. Check the attachements please.
the file name mb-network-db is the actual file name of my xml file , I used network previosult just to keep things concise and no issue is there with the name.
<fieldid="org_id"xsi:type="AttributeExternalKey"><sql>org_id</sql><target_class>OrganizationMB</target_class><is_null_allowed>true</is_null_allowed><on_target_delete>DEL_MANUAL</on_target_delete><allow_target_creation>false</allow_target_creation></field><fieldid="location_id"xsi:type="AttributeInteger"><sql>location_id</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="facility_contact_name"xsi:type="AttributeString"><sql>facility_contact_name</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="address"xsi:type="AttributeString"><sql>address</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="facility_email"xsi:type="AttributeEmailAddress"><sql>facility_email</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="gps_coord"xsi:type="AttributeString"><sql>gps_coord</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="loc_desc"xsi:type="AttributeString"><sql>loc_desc</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="clli"xsi:type="AttributeString"><sql>clli</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="facility_contact_num"xsi:type="AttributePhoneNumber"><sql>facility_contact_num</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="community"xsi:type="AttributeExternalKey"><sql>community</sql><target_class>Comm_clli</target_class><is_null_allowed>true</is_null_allowed><on_target_delete>DEL_MANUAL</on_target_delete><allow_target_creation>false</allow_target_creation></field><fieldid="notes"xsi:type="AttributeText"><sql>notes</sql><default_value/><is_null_allowed>true</is_null_allowed></field><fieldid="devices"xsi:type="AttributeLinkedSet"_delta="define"><linked_class>Device</linked_class><ext_key_to_me>location_id</ext_key_to_me><edit_mode>add_only</edit_mode><count_min>0</count_min><count_max>0</count_max><relation_type>link</relation_type><read_only>false</read_only></field><fieldid="circuits"xsi:type="AttributeLinkedSet"_delta="define"><linked_class>Circuit</linked_class><ext_key_to_me>location_id</ext_key_to_me><edit_mode>add_only</edit_mode><count_min>0</count_min><count_max>0</count_max><relation_type>link</relation_type><read_only>false</read_only></field></fields><methods></methods><presentation><!-- fields that will show up in the presentation--><details><items><itemid="community"><rank>20</rank></item><itemid="devices"><rank>30</rank></item><itemid="circuits"><rank>40</rank></item><itemid="facility_contact_name"><rank>50</rank></item><itemid="address"><rank>60</rank></item><itemid="facility_email"><rank>70</rank></item><itemid="gps_coord"><rank>80</rank></item><itemid="loc_desc"><rank>90</rank></item><itemid="clli"><rank>100</rank></item><itemid="facility_contact_num"><rank>110</rank></item><itemid="org_id"><rank>120</rank></item><itemid="notes"><rank>130</rank></item></items></details><!-- fields that shows up in the search list --><search><items><itemid="community"><rank>10</rank></item><itemid="devices"><rank>20</rank></item><itemid="circuits"><rank>30</rank></item><itemid="facility_contact_name"><rank>40</rank></item><itemid="address"><rank>50</rank></item><itemid="facility_email"><rank>60</rank></item><itemid="gps_coord"><rank>70</rank></item><itemid="loc_desc"><rank>80</rank></item><itemid="clli"><rank>90</rank></item><itemid="facility_contact_num"><rank>100</rank></item><itemid="org_id"><rank>110</rank></item><itemid="notes"><rank>120</rank></item></items></search><!-- fields that shows up in the table list --><list><items><itemid="devices"><rank>10</rank></item><itemid="circuits"><rank>20</rank></item><itemid="facility_contact_name"><rank>30</rank></item><itemid="address"><rank>40</rank></item><itemid="facility_email"><rank>50</rank></item><itemid="gps_coord"><rank>60</rank></item><itemid="loc_desc"><rank>70</rank></item><itemid="clli"><rank>80</rank></item><itemid="facility_contact_num"><rank>90</rank></item><itemid="org_id"><rank>100</rank></item><itemid="notes"><rank>110</rank></item></items></list></presentation><methods><methodid="OnUpdate"_delta="define"><static>false</static><access>public</access><type>Overload-DBObject</type><code><![CDATA[ public function onUpdate() { try { $iCommunityID = $this->Get("community"); $oCommunity = MetaModel::GetObject('Comm_clli', $iCommunityID, true, false, null); if ($oCommunity === null) { throw new Exception('Failed to load Community object with ID: ' . $iCommunityID); } $sClli = $oCommunity->Get("clli"); if ($sClli === null) { throw new Exception('Community object with ID ' . $iCommunityID . ' does not have a value for "clli" attribute'); } $this->Set('clli', $sClli); $this->DBUpdate(); } catch (Exception $e) { $this->Set('clli', null); $this->DBUpdate(); throw $e; } parent::OnUpdate(); } ]]></code></method></methods></class>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is within the itop_design/classes tags. I just have few more other class before and after this which I didn't include here. It is strange that It was working fine the day beofore yesterday, and all of a suddent after I added another method it stopped working. I tried writing the class from scratch still getting the same issue.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello there,
I have a xml file name datamodel.network.xml for my extensions and inside it I have the following code:
<methods>
<method id="OnUpdate" _delta="define">
<static>false</static> <access>public</access>
<type>Overload-DBObject</type>
<![CDATA[public function onUpdate() {
try { $iCommunityID = $this->Get("community");
$oCommunity = MetaModel::GetObject('Comm_clli', $iCommunityID, true, false, null);
if ($oCommunity === null) {
throw new Exception('Failed to load Community object with ID: ' . $iCommunityID);
}
$sClli = $oCommunity->Get("clli");
if ($sClli === null) {
throw new Exception('Community object with ID ' . $iCommunityID . ' does not have a value for "clli" attribute');
}
$this->Set('clli', $sClli);
$this->DBUpdate();
} catch (Exception $e) {
$this->Set('clli', null); $this->DBUpdate(); throw $e;
}
parent::OnUpdate(); }
]]>
</method>
</methods>
These codes are not compiling into the model.network.php file and I can not figure out why. If anyone have any idea please help. Thanks
Kind Regards,
Abdullah
Hello Abdullah,
Do you have a "model.network.php" file in your module?
Is it referenced in the "datamodel" section of the "module.network.php" file of the module?
If you can share the whole module here, it might be easier to help :)
Hope it helps,
Guillaume
Hello Guillaume,
Thanks for the quick response. I do have a model.network.php file and it is also being referenced in the module.network.php file. Check the attachements please.
the file name mb-network-db is the actual file name of my xml file , I used network previosult just to keep things concise and no issue is there with the name.
Can you share the complete XML please?
Here it is:
<class id="LocationMB" _delta="define">
<parent>cmdbAbstractObject</parent>
<properties>
<category>bizmodel,searchable</category>
<abstract>false</abstract>
<key_type>autoincrement</key_type>
<db_table>locationmb</db_table>
<db_key_field>id</db_key_field>
<db_final_class_field>
<naming>
<format>%1$s</format>
<attributes>
<attribute id="community">
</attribute></attributes>
</naming>
<display_template>
<style><br> <icon>/icons/icons8-map-marker.svg</icon><br> </style>
<reconciliation>
<attributes>
<attribute id="community">
</attribute></attributes>
</reconciliation>
</display_template></db_final_class_field></properties>
<fields></fields></class>
The field tag are fine, while I was pasting it got mixed up with my comments. here is the ss
The XML should be within the itop_design/classes tags, that might be your issue.
It is within the itop_design/classes tags. I just have few more other class before and after this which I didn't include here. It is strange that It was working fine the day beofore yesterday, and all of a suddent after I added another method it stopped working. I tried writing the class from scratch still getting the same issue.
Can your share the zip file of your module? Or send it by email so I can check?