Solved

@Environment Problem

Posted on 2003-10-24
15
218 Views
Last Modified: 2013-12-18
I have a form that has a button which creates a duplicate document in order to save on rekeying etc.

One of the fields is an invoice number and this need to have a letter put to the end of the number everytime this  button is pressed and a new documnet is created

I am working off Environment fields in order to create the new doc, but i can't get the InvoiceNumber Field to take on the new letter that should be assigned to it, the code i have tried is as follows:

envvar := @Environment("InvoiceNumber");
@If(envvar != ""; @SetEnvironment( "InvoiceNumber"; ""); "");
envvar;

@If(@Ends(@Environment("InvoiceNumber");"a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z");@Right(@SetEnvironment("InvoiceNumber";"");7); @Right(@SetEnvironment("InvoiceNumber";"");6));  

Any help please
0
Comment
Question by:DavidAbbott
[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
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 9614542
Here's your problem: you reset the environment variable before you use it!

Your second line nakes the variable blank, butthen you try to use the variable in fifth line!!
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9614572
envvar := @Environment("InvoiceNumber");
@SetEnvironment( "InvoiceNumber"; "");
endsInLetter := @Ends(envVar;"a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z");
sizeToGet := @If(endsInLetter;7;6)
@Right(envVar;sizeToGet)
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9614593
Here is the modified code

envvar := @Environment("InvoiceNumber");
envvar


@If(@Ends(@Environment("InvoiceNumber");"a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z");@Right(@SetEnvironment("InvoiceNumber";"");7); @Right(@SetEnvironment("InvoiceNumber";"");6));  


~Hemanth
0
Technology Partners: 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!

 
LVL 31

Expert Comment

by:qwaletee
ID: 9614639
Of course, I don't think you are really dong this the right way anyway.

1) You should use inheritance to transfer values, instead of environment vaiables

2) Where are you SETTING the value of this environment value to start with -- why would it not always be missing (blank)?

3) The whole 6 v. 7 business makes no sense to me.  Let's say the "main" invoice number is a six-digit number, and you are appending a single letter.  So, if there is NO letter on the end, you want the whole thing, and then you want to add a letter. If there IS a letter on the end, you want to take the whole thing with the letter.  At least, that's what your code says. Most likely, you want to do the opposite -- make sure you get the first 6 characters nomatter what, always dropping the last letter, then add a new letter on the end.  the new letter will depend on the previous letter -- a if there was none, b if a, c if b, etc.  Do I understand what you WANT correctly?  he code woudl eb as follows:

envvar := @Environment("InvoiceNumber");
@SetEnvironment( "InvoiceNumber"; "");
@If(@Length(enVar = 6; @Return(envVar + "a"); CONTINUE );
letters := "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
base := @Left(enVar;6);
priorLetter := @Right(envVar;1);
newLetter := @Replace(priorLetter; "dummy" : letters; letters : "error- ran out of alphabet!");
base + newLetter
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9614643
I believe it is two piece of code ? Am I right ? Anyway The second line of code also has some problems

envvar := @Environment("InvoiceNumber");
envvar


@If(@Ends(@Environment("InvoiceNumber");"a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z");@Right(@Environment("InvoiceNumber");7); @Right(@Environment("InvoiceNumber");6));  
(@SetEnvironment("InvoiceNumber";"");
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 9614934
You seem not to care about multiple users on multiple databases on multiple servers doing the same thing at the same time, hence creating duplicate documents (not replication conflicts). Well, that's not the issue here, is it? ;-)

Suggested ways to solve the problem, prioritized:
1. use @DbLookup to find existing documents and adapt the invoice number (if a unique key is required)
2. store the latest invoice number in the original document
3. anything else
4. ... or this ...
....
9999. use environment vars

0
 

Author Comment

by:DavidAbbott
ID: 9615561
None of the above works, i will try to make my problem a bit clearer.

The button carrys the code: (with other fields)

@Environment("InvoiceNumber"; @Text(InvoiceNumber));
@PostedCommand([FileCloseWindow]);
@PostedCommand([Compose]; ""; "Customer Log")

and the field has the code:


envvar := @Environment("InvoiceNumber");
@If(envvar != ""; @SetEnvironment( "InvoiceNumber"; ""); "");
envvar;

@If(@Ends(@Environment("InvoiceNumber");"a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z");@Right(@SetEnvironment("InvoiceNumber";"");7); @Right(@SetEnvironment("InvoiceNumber";"");6));  

What i need is, if the button is pressed and the field already has an invoice number (which it would have) for a suffix of a, or if it has already a suffix of a then b and if it has already a suffix of b then c etc etc, but only one letter to be present at any time

Cheers Guys
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9616109
This will be the code to do that

envvar := @Environment("InvoiceNumber");
@If(envvar != ""; @SetEnvironment( "InvoiceNumber"; ""); "");
alphas := "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
idx  := @If(@Ends(a;alphas); @member(@Right(envvar; 1); alphas); 0);
@leftback(envvar;1) + @if( idx > 0; @Subset(@Subset(alphas;idx+1);-1);  "");
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9616773
The code I gave earlier will do that, assuming a 6 charcater (no letter suffix) or 7 characer with one letter suffix) invoice number.

Can you confirm that invoice numbers are 6+1 character, i.e., 135791, 135791a, 135791b, etc.?

Only problem was, I had a typo, now fixed:

envvar := @Environment("InvoiceNumber");
@SetEnvironment( "InvoiceNumber"; "");
@If(@Length(envVar = 6; @Return(envVar + "a"); CONTINUE );
letters := "a":"b":"c":"d":"e":"f":"g":"h":"i":"j":"k":"l":"m":"n":"o":"p":"q":"r":"s":"t":"u":"v":"w":"x":"y":"z";
base := @Left(envVar;6);
priorLetter := @Right(envVar;1);
newLetter := @Replace(priorLetter; "dummy" : letters; letters : "error- ran out of alphabet!");

  base + newLetter
0
 

Author Comment

by:DavidAbbott
ID: 9796328
still a problem with this,
0
 

Author Comment

by:DavidAbbott
ID: 9796346
@If(@Length(envVar = 6; @Return(envVar + "a"); CONTINUE );

Something wrong with this line I believe
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 9884516
David I recd your mail.. din't see it for past 1 week

If you want me to take a look at your form send it to me I will take a look at it. Zip if before you send with minimal design for the form to work.

0
 
LVL 31

Accepted Solution

by:
qwaletee earned 500 total points
ID: 9884548
Change from
@If(@Length(envVar = 6; @Return(envVar + "a"); CONTINUE );
to
@If(@Length(envVar) = 6; @Return(envVar + "a"); CONTINUE );


It was the missing ) after @Length(envar
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9884552
(We alredy covered this in the other question)
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Missing Rules 1 318
Lotus Notes mail can not display in send item after send out 9 363
Lotus notes email code 13 99
Domino Lotus Notes Client 4 73
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

735 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