Page 1 of 1

Enumerating valuesets of an item in code

Posted: February 17th, 2021, 5:51 pm
by alex_izm
Hello everyone!

I was wondering in CSPro code is it possible to get a reference to a valueset(s) object of a dictionary item. Say for example I have a dictionary item WCOL1, which has a value set WCOL1_VS1. In code I can get a reference to the value set object by declaring a variable of type ValueSet and just assigning it from WCOL1_VS1 like this:

Code: Select all

ValueSet myVs = WCOL1_VS1;
But what if I don't know the name of the value set at compilation time, and only know the item name? Firstly I need to know how many value sets the item contains (if any), and then assign first (or second, or third) value set to 'myVs' object. Something like:

Code: Select all

ValueSet myVs;
numeric vsCount = WCOL1.GetValueSetCount(); //get count of value sets defined in WCOL1 dictionary item
if vsCount then
  myVs = WCOL1.GetValueSet(1); //assigning the first valueset of WCOL to 'myVs'
endif;
Is something like this possible? If not, is there maybe some kind of clever workaround?

Thanks!
Alex

Re: Enumerating valuesets of an item in code

Posted: February 17th, 2021, 6:31 pm
by josh
No, there isn't any way to enumerate all the value sets of an item.