Page 1 of 1

How to value-link ?

Posted: October 14th, 2019, 4:27 am
by Cesavhi
Hi all,

i'm trying to make cspro value that linked with my previous answered question. is that possible ?

i attach the program to fully describe my question.

name 1 :
name 2 :
name 3 :
name 4 :
name 5 :

Smartest : Linked value 5 name above choose 3.

Best : linked value 3 name from smartest, choose 1.

Any help would be appreciated.

Thank you,

Ces.

Re: How to value-link ?

Posted: October 14th, 2019, 11:38 am
by josh
You should dynamic value sets for this with the valueset object. You can read more about them in the help: https://www.csprousers.org/help/CSPro/valuesets.html. You can also check out this blog post that gives some additional examples: https://www.csprousers.org/posts/2019-0 ... bject.html

You have two procs where you need to create dynamic value sets based on the names entered in the first five questions. First you need to create a value set for the SMARTEST which will contain each of the names (NAME1, NAME2...). Declare a valueset object. Since this is a checkbox field it needs to be a string valueset so it can contain alpha codes. Then add each name to the value set with a code (A for the first name, B for the second...).
PROC SMARTEST

onfocus
valueset
string smartestVs;
smartestVs.
add(NAME1, "A");
smartestVs.
add(NAME2, "B");
smartestVs.
add(NAME3, "C");
smartestVs.
add(NAME4, "D");
smartestVs.
add(NAME5, "E");

setvalueset($, smartestVs);
For the BEST question, you want to create another value set but this time only for those names that were checked in SMARTEST. To do that use the pos function (https://www.csprousers.org/help/CSPro/pos_function.html) to see if each of the options (A,B,C...) were checked in the previous questions and only add the ones that were picked from the first value set into the second:
PROC BEST

onfocus
valueset
string bestVs;

if pos("A", SMARTEST) > 0 then
    bestVs.
add(NAME1, "A");
endif;
if pos("B", SMARTEST) > 0 then
    bestVs.
add(NAME2, "B");
endif;
if pos("C", SMARTEST) > 0 then
    bestVs.
add(NAME3, "C");
endif;
if pos("D", SMARTEST) > 0 then
    bestVs.
add(NAME4, "D");
endif;
if pos("E", SMARTEST) > 0 then
    bestVs.
add(NAME5, "E");
endif;


setvalueset($, bestVs);

Re: How to value-link ?

Posted: October 15th, 2019, 11:35 pm
by Cesavhi
Thank you so much sir josh..

it works perfectly <(_ _)>