[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

@Environment Problem

Posted on 2003-10-24
15
Medium Priority
?
222 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1500 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

650 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