Solved

How to Prune from a List in Formula Language

Posted on 2002-03-06
10
3,587 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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