To re-populate a ListBox based on a condition

20 pts.
Tags:
Conditional statements
Formula Language
ListBox
Lotus development
Lotus Notes
I am using a button(to check and repopulate) and a Listbox(Available options). Initially the Listbox uses Default values to Populate values. Then If the button is clicked; it creates a list of already used options through DBlookup(List2) and there is a list of default values(list1). i use @replace to create a list3 which if explode will checkmark all options in list 3 and keep all options of list 2 unchkd. this is code in Button action:
@Command([RefreshWindow]);
List1:="08:00 - 09:00AM;09:00 - 10:00AM;10:00 - 11:00AM;11:00 - 12:00AM/PM;12:00 - 01:00PM;01:00 - 02:00PM;02:00 - 03:00PM;03:00 - 04:00PM;04:00 - 05:00PM;05:00 - 06:00PM;06:00 - 07:00PM;07:00 - 08:00PM;08:00 - 09:00PM;09:00 - 10:00PM;10:00 - 11:00PM;11:00 - 12:00PM/AM;12:00 - 01:00AM;01:00 - 02:00AM;02:00 - 03:00AM;03:00 - 04:00AM;04:00 - 05:00AM;05:00 - 06:00AM;06:00 - 07:00AM";
List2:=@DbLookup("":"Recache";"":"Resource.nsf";"RequiredDate";ReqDate;2);
List3:=@Replace(@explode(List1;";"; @True;@True);List2;"");
FIELD AvailTime:= List3;
@If(@IsError(List2);FIELD AvailTime:=List1;@Explode(Availtime; ";"; @True;@True))
Under Field properties I have set list1 as DeFault Fieldname:="List values"and @explode(Field name) What i need is to remove List 2 options from list1 and repopulate the listbox only with available options. Any ideas? Anbody?

Answer Wiki

Thanks. We'll let you know when a new response is added.

2 things:

1) I would use a hidden field with the formula you show, near the top of the form instead, computed and put the formula there (though in reality what I am saying this is not necessary, just a style choice with some benefits in my opinion, one being that it won’t recalculate if in Read mode, though I believe formulas for listbox fields do).

2) On the properties of the field there is a check box for “Refresh values when document is refreshed”, or something like that. The operation that is causing the need for a reload must refresh the document, also, if a value is selected in the field that is not in the new list may affect the way this acts.

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Brooklynegg
    I will look at this. I don't understand the use of the FIELD argument within the formula. This is not the proper use of FIELD, and, in fact, FIELD should not be used at all (since R6, I think). FIELD AvailTime:=List1
    3,845 pointsBadges:
    report
  • Stiletto
    I agree. Also, this line: @Explode(Availtime; ";"; @True;@True) is wrong, too I think. Availtime should already be a list at this point. And, what does this mean? >Under Field properties I have set list1 as DeFault Fieldname:="List values"and @explode(Field name)
    3,830 pointsBadges:
    report
  • Brooklynegg
    I don't really understand where this runs. Is it a form action button? or a button on the form? Running in Notes client or on the web. I will assume that it runs in the notes client and either a form action or button on the form does the work. I am only addressing the parts of the code that deal with setting a final value among the lists in the code and then set the value in a field called AvailTime. I think that is the part you were having trouble with, from what I can see. This is your code with my changes. @Command([RefreshWindow]); List1:="08:00 - 09:00AM;09:00 - 10:00AM;10:00 - 11:00AM;11:00 - 12:00AM/PM;12:00 - 01:00PM;01:00 - 02:00PM;02:00 - 03:00PM;03:00 - 04:00PM;04:00 - 05:00PM;05:00 - 06:00PM;06:00 - 07:00PM;07:00 - 08:00PM;08:00 - 09:00PM;09:00 - 10:00PM;10:00 - 11:00PM;11:00 - 12:00PM/AM;12:00 - 01:00AM;01:00 - 02:00AM;02:00 - 03:00AM;03:00 - 04:00AM;04:00 - 05:00AM;05:00 - 06:00AM;06:00 - 07:00AM"; List2:=@DbLookup("":"Recache";"":"Resource.nsf";"RequiredDate";ReqDate;2); List3:=@Replace(@explode(List1;";"; @True;@True);List2;""); FinalValue := @If(@IsError(List2);List1;@Explode(Availtime; ";"; @True;@True)); @setfield("Availtime"; FinalValue)
    3,845 pointsBadges:
    report
  • Brooklynegg
    I think I missed something. Try this on the FinalValue line: FinalValue := @If(@IsError(List2); List1; List3); Also, I think you have the @isError function in this code because the @Dblookup function would return an error if there was no match. Instead, you should use the [FailSilent] keyword in @dblookup (check help for examples), which makes the function return blank instead of an error when nothing is found. If so, then the FinalValue line is not even needed and the last line can be changed to: @setfield(”Availtime”; List3)
    3,845 pointsBadges:
    report
  • ServGuy
    Yes it runs in the notes client and the formula is for a button on the form . i.e the when the button is clicked the formula is executed. Then in the field called Availtime under field Properties --> under choices i have used "Enter choices (one per line)" and entered the List1 values one-by-one.. Thanks for the response .I tried the code But i am getting an error saying "Field name requires a value". Any ideas?
    20 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following