Page 1 of 1

Cascading From LGA to Settlements not displaying Value and labels of the Cascaded Fields

Posted: January 21st, 2021, 9:34 am
by lmoriba
Dear CSPRO Community,
Am in need of urgent help to display values and Labels in the cascaded field. Am cascading the values of my unique identifier field LGA, District, Ward and Settlements using pre-loaded data. The logic below is displaying the Values and not the labels. I need to display both. For instance the logic for district is given below:

onfocus

locateThisGeoID = maketext("%v00000000", LGA);

idx = 1;
do while locate(ITC2021_GEOCODES_DICT,>,locateThisGeoID);
if retrieve(ITC2021_GEOCODES_DICT) then
if GEO_LGA = LGA then
vsCodes(idx) = GEO_DISTRICT;
vsLabels(idx) = maketext("District #%v", GEO_DISTRICT);
inc(idx);
endif;
locateThisGeoID = maketext("%v%v999999", GEO_LGA, GEO_DISTRICT);
endif;
enddo;

vsCodes(idx) = NotAppl;

setcapturetype(DISTRICT, 1); // make this a radio button
setvalueset(DISTRICT, vsCodes, vsLabels);


The logic Compiles fine and cascaded District code and Labels them as District1, District2 etc. Instead displaying the actual value labels. A copy of the program is attached.
Doc2.docx
(30.5 KiB) Downloaded 146 times
PRETRAINING.zip
(163.11 KiB) Downloaded 138 times

Re: Cascading From LGA to Settlements not displaying Value and labels of the Cascaded Fields

Posted: January 21st, 2021, 10:26 am
by josh
You can get the label from the value set using the getlabel() function. It takes two arguments, first is the name of the variable or value set to get the label from and the second is the code that you want the label of. So in your example you can do:

Code: Select all

				vsLabels(idx) = getlabel(DISTRICT_VS1, GEO_DISTRICT);	


This tells to CSPro to get the label in the value set DISTRICT_VS1 corresponding to the current value of the variable GEO_DISTRICT from the lookup file.

Re: Cascading From LGA to Settlements not displaying Value and labels of the Cascaded Fields

Posted: January 21st, 2021, 1:12 pm
by lmoriba
Thanks 😊👍, that is exactly the solution am looking forward to. Thanks a million times.