I have the code below to check if max limit is met between 3 hotels assigned per division and per coordinator. It should do the following:
-
If limit IS NOT reached for any hotel in a particular division ,then allow to compose doc
-
if limit IS reached for a particular hotel in the division prompt with msg and do not allow to proceed.
It is not working for me Please Help!
Hotel := Hotel;
choice:=@PickList( [Custom] ;@DbName ; “2007\Room Allocation” ; “Select a hotel” ; “Please select the hotel for your reservation” ;1);
TotalRooms:=@If(@IsError(@DbLookup(“” : “NoCache” ;@DbName;“SearchView”;@Name([CN];@UserName);2));0;@DbLookup(“” : “NoCache” ;@DbName;“SearchView”;@Name([CN];@UserName);2));
CurrentRooms:=@If(@IsError(@DbLookup(“” : “NoCache” ;@DbName;“SearchView”;@Name([CN];@UserName);3));0;@DbLookup(“” : “NoCache” ;@DbName;“SearchView”;@Name([CN];@UserName);3));
Division:=@If(@IsError(@DbLookup(“” : “NoCache” ;@DbName;“SearchView”;@Name([CN];@UserName);3));0;@DbLookup(“” : “NoCache” ;@DbName;“SearchView”;@Name([CN];@UserName);4));
@If(choice != “” & Division != “” & CurrentRooms>=TotalRooms;@Prompt([Ok];“Quota Exceeded or Met”;"You are unable to create any more reservations for " + choice);@Command([Compose]; @DbName ; “resv”));
@SetField(“Hotel”;“choice”)
Subject: 2nd post -
what does, “it’s not working for me” mean?
Subject: RE: 2nd post -
I apologize, I should’ve given more details.
It always prompt with the msg. “You are unable to create any more reservations” whether the limit has been reached or not.
thanks.
Subject: RE: 2nd post -
Verify that the dblookups are returning the correct values. Use @prompts to show them. Secondly, I think when it does pass the validation, you will see the new document, but the Hotel field will be empty. If the Hotel field in the newly composed form is an editable field you can use
@Command( [EditGotoField] ; “Hotel”);
@Command( [EditInsertText] ; choice )
after resv is composed.
Any thoughts of using Lotusscript instead?
Subject: Just a little constructive criticism (advice)…
Your code is extremely inefficient.
-
For TotalRooms and CurrentRooms you’re doing the exact same lookup twice, once to see if there is an error and once to go get the data. Do the lookup once into another temp variable and check that temp variable. You can also re-use the result from CurrentRooms in your @If for Division.
-
You re-use @Name([CN]; @Username) (currently) 6 times. Calculate it once into a temp variable and use that temp variable.
-
Instead of doing 3 lookups to the same view (with the same key), create another (possibly hidden) column in your view that combines all three values into some kind of delimited list (i.e. Val1~Val2~Val3), then either @Explode the single lookup or use @Word to get the various values you need.
Basically you want to get into the habit of limiting the amount of times you re-do the same code. Your users will thank you profusely for making their experience that much faster. Well probably not but you can hope. 
Subject: RE: Just a little constructive criticism (advice)…
Thanks…I will try that.