Solved

@Environment Problem

Posted on 2003-10-24
15
217 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
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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 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…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

861 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