VIEW MEMBER FEEDACK TO THIS TIP
Have you ever needed to use a list description and its synonym in different views?
This Formula script allows you to set a field with the description value of a list for later use.
The Formula code relies on the presence of the following conditions:
- You have a Profile Document called "profile."
- Your list field is called "xxxxxxList."
- Your form has a field to allows selection -- i.e. dialog/checkbox/etc. -- called "xxxxxx."
- You have "refresh fields on keyword change" selected.
- You have an addition computed text field with the name "xxxxxxText."
Once you've arranged the above parameters, use the Formula in the computed field to get the original list and find the synonym value, or return the description. Alternatively, you can use an input translation to set the 'text' field.
COMPUTED FIELD
fPfx := @Left(@ThisName;@Length(@ThisName)-4);
listNum := @Elements(@GetProfileField("profile";fPfx+"List"));
tmp:= @GetField(fPfx);
@For(
n:=1;
n <= listNum;
n := n+1;
tmp := @If(@RightBack(@GetProfileField
("profile";fPfx+"List")[n];"|") =
@GetField(fPfx);@LeftBack
(@GetProfileField("profile";fPfx+"List")
[n];"|");tmp));
tmp
INPUT TRANSLATION
fPfx := @ThisName;
listNum := @Elements
(@GetProfileField("profile";fPfx+"List"));
tmp:= @ThisValue;
@For(
n:=1;
n <= listNum;
n := n+1;
tmp := @If(@RightBack(@GetProfileField
("profile";fPfx+"List")[n];"|") =
@ThisValue;@LeftBack(@GetProfileField
("profile";fPfx+"List")[n];"|");tmp));
@SetField(fPfx+"Text";tmp)
@ThisValue
MEMBER FEEDBACK TO THIS TIP
When working with lists, you can also use @Transform instead of @For. In this case, you do not need to count the elements and use an index variable. The code for the same solution with @Transform would be something like this:
fPfx := @Left(@ThisName;
@Length(@ThisName)-4);
_resultlist := @Trim(@Transform(
@GetProfileField("profile";fPfx+"List");
x; @If(@RightBack(x;"|")=@GetField(fPfx);
@LeftBack(x;"|");
@Nothing)
));
_resultlist
Alternatively, we can return with @Implode(_resultlist)
Gabor B.
Do you have comments on this tip? Let us know.
Related information from SearchDomino.com:
Learning Guide: Formula Language
FAQ: Formula language
Tip: @Formula library
Tip: Expand group members and nested groups in @Formula
Reference Center: Formula language resources and tips
This tip was submitted to the SearchDomino.com tip library by member John Humphreys. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.