Hi Everyone
I have some code that works perfectly but I assume that it go do with some “list love” i.e. I think that this would be better solved with lists.
I have a config document that admins can use to set values for a checkbox field (actually it can be used for any type of field). I allow the use of alias’s for the field values in the config document. I then load the values from the config document and display them in my checkbox field. The users then select what they want and the alias is saved in the field. No problem. I then have a computed for display field that displays the values selected when the document is in read mode. This displays the alias’s and not the values!
Here is an example:
config document field name: verteiler
Values:
value1 | 1
value2 | 2
value2 | 3
I then have a field on some form called testVerteiler that then loads the value of verteiler from the config doc (value1 | 1; value2 | 2; value3 | 3). I have a further field called _dispTestVerteiler that needs to display the selected values. if 1 and 3 was selected then the field currently displays 1 : 3 and I want it to display value1 : value3. I have code that does this but it uses 2 for loops that I think would be better suited to list processing - unfortunatly I cannot seem to figure out what I need :o(
Maybe some kind person would take a look at it?
Thank you in advance
Ursus Schneider
----------- here is the code -------
REM {get the current value};
REM ;
currValue := testVerteiler;
@If (currValue = “”; @Return (“”); “”);
REM ;
REM { now get the list of possible values from the config document };
REM ;
fieldName := “testVerteiler”;
key := “#” + formName + “#” + fieldName + “#”;
list := @DbLookup (“” : “NoCache”; “”; “vwKeywords”; key; 2; [FailSilent]);
REM ;
REM { check if you even need to search for aliases - if not then just return what was selected };
REM ;
@If (@Contains (list; “|”); “”; @Return (currValue));
REM ;
REM { split the values into 2 lists };
REM ;
abbrName := @Trim (@Right (@Explode (list; “;”); “|”));
longName := @Trim (@Left (@Explode (list; “;”); “|”));
REM ;
REM { now try and find your value in the list };
REM ;
retValue := “”;
@For (i := 1; i <= @Elements (currValue); i := i + 1;
@Do (
@For (j := 1; j <= @Elements (abbrName); j := j + 1;
@Do (
@If (@UpperCase (currValue [i]) = @UpperCase (abbrName [j]); retValue := retValue : longName [j]; "")
)
)
)
);
retValue
---------- end of code --------