Trying to figure out how to create a new meter reading through the API.
I gather this needs to be done through item_installed and meter_reading_xref.
My first attempt was to use bo_search_keys to specify the meter_id, but this ends up finding and updating the last meter reading, which is undesirable. This makes sense in hindsight.
Attempt 1:
<root>
<session email="" alias="">
<state bc_name="item_installed">
<action name="data">
<main>
<row>
<item_id>556867</item_id>
</row>
</main>
<meter_reading_xref use_retrieve_limit="true">
<row>
<curr_reading>18</curr_reading>
<bo_search_keys>
<item>
<name>item_id</name>
<value>556867</value>
</item>
<item>
<name>meter_id</name>
<value>1</value>
</item>
</bo_search_keys>
</row>
<row>
<curr_reading>19</curr_reading>
<bo_search_keys>
<item>
<name>item_id</name>
<value>556867</value>
</item>
<item>
<name>meter_id</name>
<value>2</value>
</item>
</bo_search_keys>
</row>
</meter_reading_xref>
</action>
</state>
</session>
</root>
Attempt 2 was to just specify the meter readings as rows without search keys.
<root>
<session email="" alias="">
<state bc_name="item_installed">
<action name="data">
<main>
<row>
<item_id>556867</item_id>
</row>
</main>
<meter_reading_xref use_retrieve_limit="true">
<row>
<curr_reading>18</curr_reading>
<meter_id>1</meter_id>
</row>
<row>
<curr_reading>19</curr_reading>
<meter_id>2</meter_id>
</row>
</meter_reading_xref>
</action>
</state>
</session>
</root>
Weirdly, this fails, but if I specify readings that already match an existing reading, it fails because “A row with the identical values for Reading, Reading Date,Source, Replacement and Credit data already exists for the 'JobInvoicingTest_STD' item and 'Total B&W' Meter Type.”
If I update the curr_reading to not be the same as an existing value, then I just get:
succeeded:false
Error Message:: Execute Macro 'Save' failed.
reason: <root><BOName></BOName><MessageID></MessageID><MessageAsteaCode>A2GEN017</MessageAsteaCode><ElementName></ElementName><Message>System error occurred. Contact your System or Database Administrator.
Date: 2024-06-10 9:21:37 PM
Event: 65535
Ref #: b590b1eb-8845-45ec-8819-b00d88ebce30
Date: 2024-06-10 11:21:37 AM UTC</Message><Row></Row><Code>AsteaException</Code></root>
I suspect I’m close, but I need some help. I want to be able to submit meter readings from an external application. These should be able to be submitted with a reference ideally, like the order id for meters logged through a service order, and a new reading should be created even if the value is the same as an existing reading.