Solved

How to Prune from a List in Formula Language

Posted on 2002-03-06
10
3,546 Views
Last Modified: 2013-12-18
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?  
0
Comment
Question by:blyons48
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6844972
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
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6846496
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
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6847146
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.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Accepted Solution

by:
David_Gordon earned 75 total points
ID: 6850472
Try this:

-------begin code----------

List:= (the name of your list field)
Value:= (name of field which contains the value to remove OR the literal string)

@if(@ismember(Value,List);"";@return(0)); 'if Value is not in List, then exit

Position:=@member(Value,List); 'gives position of Value in List

Newlist:=@subset(list,position-1):@subset(list,position-@elements(list)); ' concatenate all elements in List before Value with all elements in List after Value

-------end code-----------

Good luck

David
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6856870
Hm, my solution worked perfectly too. So why did you propose an answer and steel my points, David??
0
 

Expert Comment

by:David_Gordon
ID: 6858127
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.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6858279
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.
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6859781
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?)
0
 

Author Comment

by:blyons48
ID: 6861479
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.
0
 

Author Comment

by:blyons48
ID: 6861695
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.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Lotus Domino Server Failure 1 182
Domino Application - View Refresh on Subform 15 96
Switching from Lotus Notes to Outlook 4 49
Code for extraction to mkdir folder 5 61
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question