Sample naming pattern - yearlySampleCount

LabKey Support Forum
Sample naming pattern - yearlySampleCount katy wiseman  2023-02-21 08:20
Status: Active
 

Hi,

I'm trying to use the yearlySampleCount in my sample naming pattern but even in a new folder with nothing else in it it's not starting at 1. I entered ${yearlySampleCount} as my name expression and my first test sample was given a name of 17886. The next one was give 17887. I made a new project folder and made a new sample type with ${yearlySampleCount} as the naming expression and my first sample was given 17888. It looks like the scope is maybe extending across folders, but the documentation says it's only "All Sample Types / Data Classes in the current folder".

Is this how it's meant to be working or am I doing something very wrong?

Thanks,

Katy

 
 
mohara responded:  2023-02-21 10:52

Hi Katy:

You're seeing the correct behavior, the documentation was wrong and I've corrected it. My apologies for this confusion. The yearlySampleCount (and other similar date-based counters) applies to all samples (and data classes/registry sources) across the site. This is true whether you use it standalone or as a modifier on a particular date field you might add.

If you want a local counter that will start at 1, you can use ${genId} - that will apply to a given Sample Type and container, typically used as part of a compound naming pattern.

Another good naming option is to use the ":withCounter" syntax to add an incrementing 'starts from 1' counter to your sample names. For example, if you had a "Blood" sample type and used the naming pattern ${Blood-:withCounter} you'd get names like: Blood-1, Blood-2, etc.

You could also have a "Year" column in your data, then use an element in your naming pattern like ${Blood-${Year}-:withCounter}
to get names like: Blood-2023-1, Blood-2023-2, etc. This could effectively give you the yearly-total tally you may be seeking, on a per-sample-type basis.

I hope one of these helps you get the behavior you're seeking, and happy to help further if not.

--Molly

 
katy wiseman responded:  2023-02-27 09:05

Thank you! I'll stop trying to do the impossible then. I'll try one of the other counters.

Best,

Katy