Link to home
Start Free TrialLog in
Avatar of blyons48
blyons48

asked on

How to Prune from a List in Formula Language

In Lotus Notes Formula Language, we need to code a formula which removes 1 item from anyplace in the list, where the list is userids.

As pseudo code it would read: If USER1 is part of LIST, then remove USER1 from LIST and leave all the other userids.

Example: Given the list: "john smith/miami/abc, james williams/tampa/abc, bill jones/boston/abc, mary bock/phoenix/abc" , and given that USER1 = bill jones/boston/abc, then remove bill jones/boston/abc from LIST.

Does anyone know a Lotus Notes Formula Language to do that removal?  
Avatar of HemanthaKumar
HemanthaKumar

Here it is

List := "john smith/miami/abc, james williams/tampa/abc, bill jones/boston/abc, mary
bock/phoenix/abc" ;
USER1 := "bill jones/boston/abc";

@trim(@replace( @trim(@Explode(List;",")); User1; ""));


~Hemanth
Close Hemanth, but what if the list isn't in a string like you provided, but in a multi-value field for example ?

Then the formula would be a bit more complicated :

Suppose you have a field called "List" that contains the list from which you want to remove the user, then this would be the formula:

ListString:=@Implode(List; ",");
User1:="bill jones/boston/abc";

@Explode(@ReplaceSubstring(ListString; User1+","; ""); ",");

The code explained :
The @Implode function will first combine all the list entries in one string and seperate them with a comma.
The @ReplaceSubstring, will remove the name and the seperation comma from the string.
The @Explode will then return the list as a list, minus the removed name.

Regards,
JM
String is not provided by me, it is provide by blyons48, he din't mention it was a list. If it is a list then he don't have to convert it to the list, that extra step (explode) is not needed at all.
ASKER CERTIFIED SOLUTION
Avatar of David_Gordon
David_Gordon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hm, my solution worked perfectly too. So why did you propose an answer and steel my points, David??
jerrith - Your solution was not complete. Choose a certifier with a comma, i.e. "Foobar, Inc." and run it through your script. I knew my code to be a full solution to both the current problem and any similar list-management problem as well as helping the questioner to understand the procedure, and therefore I felt it qualified to be proposed as an "answer". If you are sure of your solutions, propose them as answers so I do not mistake them for comments.
David,

You are right if I thought my answer was perfect I would have locked down. But as far as the rules of this forum, nobody locks the question as you did.

Blyons48,

Could you comment why my solution din't work for you ???
Before grading the points, ask the expert for clarification because nobody is on the same page as far as understanding of your problem.
David,

Just FYI : We tend to never lock questions because :
- locking a question will remove the question from the attention of other experts, thus valuable input may never be given
- we leave it up to the person who asked the question to choose the correct answer. Sometimes for one question there are multiple answers and it's up to the asker to decide which answer suits him best.

As to your comment for my code not being perfect : If you read the question you'll see that it is intended for userids. Now do you know of anybody that uses a comma in userids ? Therefore it is not needed to complicate things by checking for things that will never happen, right?

I do however agree that your code was better, nevertheless I just wanted to point out to you that we don't usually lock questions.

Oh yeah, and it might not sound as such by my comments, but i was not offended or intended to offend anyone (my humour doesn't always get through to people) :-)

Blyons48,
It is common practice to provide an expert with feedback why you accept an answer and say at least thank you for your help.
Nothing as bad as not being appreciated for the work you do. (We are doing this for free to help you here, remember?)
Avatar of blyons48

ASKER

I hope I haven't started WWIII on EE.  When I went in yesterday to accept jerrith's answer, I found that David's newly posted answer was the only one that would allow me to click on accept.   So that's what I did.   While both may work, what's a body to do given only one choice?    Thank you all for your solutions, and please forgive me for only having one clickable choice.
I hope I haven't started WWIII on EE.  When I went in yesterday to accept jerrith's answer, I found that David's newly posted answer was the only one that would allow me to click on accept.   So that's what I did.   While both may work, what's a body to do given only one choice?    Thank you all for your solutions, and please forgive me for only having one clickable choice.