Enumerating valuesets of an item in code
Posted: February 17th, 2021, 5:51 pm
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:
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:
Is something like this possible? If not, is there maybe some kind of clever workaround?
Thanks!
Alex
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;
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;
Thanks!
Alex