XML counter columns

LabKey Support Forum
XML counter columns katy wiseman  2021-01-14 01:43
Status: Closed
 

Hi,

I'm trying to get an XML counter column to work as described here at the bottom of the page:
https://www.labkey.org/Documentation/Archive/20.7/wiki-page.view?name=sampleIDs

However it's not working. I've created the sample type as it's shown in the example and pasted the XML code into the XML metadata but it's not generating an automatic 'SampleInLot' number for each new 'Lot' in the table.

This is the XML metadata suggested:

<tables xmlns="http://labkey.org/data/xml">
<table tableName="MySampType" tableDbType="NOT_IN_DB">
<javaCustomizer class="org.labkey.experiment.api.CountOfUniqueValueTableCustomizer">
<properties>
<property name="counterName">
SampleCounter
</property>
<property name="counterType">
org.labkey.api.data.UniqueValueCounterDefinition
</property>
<!-- one or more pairedColumns used to derive the unique value -->
<property name="pairedColumn">
lot
</property>
<!-- one or more attachedColumns where the incrementing counter value is placed -->
<property name="attachedColumn">
sampleInLot
</property>
</properties>
</javaCustomizer>
</table>
</tables>

Does anyone have any thoughts about how to get this to work? Or any other alternatives?

Thanks,

Katy

 
 
chetc (LabKey Support) responded:  2021-02-05 16:48

Hello Katy,

We appreciate you reaching out to us!

The example on https://www.labkey.org/Documentation/Archive/20.7/wiki-page.view?name=sampleIDs does indeed work, but if you copied and pasted the metadata directly (as is) from that page it does not. There are some extra carriage returns/characters in the paste that cause issues. You don't see them arise in the UI but the primary site log file throws some warnings regarding the counter.

We will work to get that example corrected, thank you for bringing it to our attention!

Please try using (below). Note: Change the "tableName" to the table you are targeting and "counterName" to a name of your choice.

<tables xmlns="http://labkey.org/data/xml">
<table tableName="ForumTestXMLCounter" tableDbType="NOT_IN_DB">
<javaCustomizer class="org.labkey.experiment.api.CountOfUniqueValueTableCustomizer">
<properties>
<property name="counterName">TESTSampleCounter</property>
<property name="counterType">org.labkey.api.data.UniqueValueCounterDefinition</property>
<!-- one or more pairedColumns used to derive the unique value -->
<property name="pairedColumn">Lot</property>
<!-- one or more attachedColumns where the incrementing counter value is placed -->
<property name="attachedColumn">SampleInLot</property>
</properties>
</javaCustomizer>
</table>
</tables>

After changing your metadata you should note that the column "SampleInLot" shows the value of the counter and it uses the uniqueness of "Lot" to determine how to increment "SampleInLot" per "Lot", in this scenario.

Please let us know if there is anything we could clarify or if you still run into issues.

Thanks,
Chet

 
katy wiseman responded:  2023-04-04 02:52
Status: Active

Hi,

I have a further question related to the counter columns.

I have these working but is there any way to get them to start at a different number? We want to use this for our samples going fowards but we have legacy data which is going to take a long time to clean. We want to start using a new controlled system as soon as possible and deal with the legacy data in the background but not end up with the same sample names. Our thought is to skip ahead and start at say 1000 to avoid any overlap. Is there a way to do this?

Best,

Katy