Solved

How to Prune from a List in Formula Language

Posted on 2002-03-06
10
3,482 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now