Adding stuff to invoice based on alphabet letter of Sell-to

yuppicide
Member Posts: 410
Navision 3.10.
Awhile ago you guys helped me add special text to print on an invoice based on what the payment terms are.
Example:
Etc.. the above dictates that the customer has already paid by CC. There's a bunch of them for all our different Payment Terms. Those RemitText get filled in with more information for other Payment Terms.. for example if there was an address a payment should be mailed to, it will show that on the invoice.
Now I'm wondering if there's a way to further add something to this.
We have problems where some customers are factored (meaning an outside company gives them credit and handles payments for us). In my instructions that print on the invoice it only has information on who to make checks to and where to mail. If the customer has a payment problem (such as they're going to be late, or want to see if they accept credit card, etc), they should be calling them and not us.
I want to add RemitText10 and how can I get Navision to do this:
If Sell-to Customer name starts with the letters A through C then RemitText10 will print one phone number.
If Sell-to Customer name starts with the letters D through H then RemitText10 will print one phone number.
etc.
There's different reps at the company they should contact.
Awhile ago you guys helped me add special text to print on an invoice based on what the payment terms are.
Example:
IF "Payment Terms Code" = 'CC' THEN BEGIN RemitText1 := 'YOUR ORDER HAS ALREADY BEEN PAID FOR.'; RemitText3 := ''; RemitText4 := ''; RemitText5 := ''; RemitText6 := ''; RemitText7 := ''; RemitText8 := ''; RemitText9 := ''; END;
Etc.. the above dictates that the customer has already paid by CC. There's a bunch of them for all our different Payment Terms. Those RemitText get filled in with more information for other Payment Terms.. for example if there was an address a payment should be mailed to, it will show that on the invoice.
Now I'm wondering if there's a way to further add something to this.
We have problems where some customers are factored (meaning an outside company gives them credit and handles payments for us). In my instructions that print on the invoice it only has information on who to make checks to and where to mail. If the customer has a payment problem (such as they're going to be late, or want to see if they accept credit card, etc), they should be calling them and not us.
I want to add RemitText10 and how can I get Navision to do this:
If Sell-to Customer name starts with the letters A through C then RemitText10 will print one phone number.
If Sell-to Customer name starts with the letters D through H then RemitText10 will print one phone number.
etc.
There's different reps at the company they should contact.
0
Comments
-
Variable Repmarker Type Text
RepMarker := COPYSTR("Sell-to Customer name",1,1);//Gets the first character
IF RepMarker IN THEN REMITTEXT10 := '123-456-7890';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7891';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7892';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7893';
Does anyone start with a number? you'll have to handle that too.0 -
Thanks! I think I notice a potential problem
It's
A - C
D - H
I - M
N - SK
SL - Z
.. your code only checks the first character.0 -
If Sell-to Customer name starts with the letters A through C then RemitText10 will print one phone number.
If Sell-to Customer name starts with the letters D through H then RemitText10 will print one phone number.
is there another field on the customer card that distinguishes the rep differences instead of the characters in the name? perhaps salesperson code? or a custom field? location code?0 -
Savatage wrote:Variable Repmarker Type Text
RepMarker := COPYSTR("Sell-to Customer name",1,1);//Gets the first character
IF RepMarker IN THEN REMITTEXT10 := '123-456-7890';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7891';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7892';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7893';
Does anyone start with a number? you'll have to handle that too.
You could check for the second char in the same way (its not really performant but as it is one record each time it shouldnt be that much of a problem)
RepMarker := COPYSTR("Sell-to Customer name",1,1);//Gets the first character
IF RepMarker IN THEN REMITTEXT10 := '123-456-7890';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7891';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7892';
IF RepMarker IN THEN REMITTEXT10 := '123-456-7893';
if RepMarker = 'S' then begin
Repmarker := COPYSTR("Sell-to Customer name",2,1); //gets second char
if repmarker in then REMITTEXT10 := '123-456-7890';
if repmarker in then remittext10 := '213-456-7890';
end;0 -
I haven't tried this yet, but I want to do it soon. I'm looking at your code and had a question:
if repmarker in ['L',....'Z'] then remittext10 := '212-575-5794';
In that code above, I'm assuming it means any letter L through Z. In the line of code above it, why is B there? Shouldn't:if repmarker in ['A','B',...,'K'] then REMITTEXT10 := '212-575-8023';
Shouldn't that not need the B? Any letter A through K.0 -
its indeed any letter, i typed 'A','B' and then got bored so just added the K at the end.
Oh and you could leave the 'S' out of the line above. (IKF RepMarker IN THEN REMITTEXT10 := '123-456-7893';)
It doesnt really do any harm as it gets filled in later on but just in case there is a combination with S that isn't expected in the code.0 -
Understood.. I was actually going to attempt what you did exactly.. figuring it was a shortcut.. so I see I need to actually add every letter.0
-
Savatage wrote:is there another field on the customer card that distinguishes the rep differences instead of the characters in the name? perhaps salesperson code? or a custom field? location code?0
-
geronimo wrote:its indeed any letter, i typed 'A','B' and then got bored so just added the K at the end.
Oh and you could leave the 'S' out of the line above. (IKF RepMarker IN THEN REMITTEXT10 := '123-456-7893';)
It doesnt really do any harm as it gets filled in later on but just in case there is a combination with S that isn't expected in the code.
Just a small trickIF RepMarker IN ['R'..'Z']
Normal filters does work as long as you remember the '' to indicate that it's a text.0 -
I can't go by Salesperson Code.. Reason being is because salespersons handle territory, such as Southeast, Midwest, etc. The people who handle the credit go by company name alphabet letter.
I could create a custom field maybe if you think that's a better way of going about things, but that will add one more step to whoever enters the customer card and if they do that step wrong then it'll print wrong.Savatage wrote:Savatage wrote:is there another field on the customer card that distinguishes the rep differences instead of the characters in the name? perhaps salesperson code? or a custom field? location code?0 -
Wondering where I shall add this new code and thought of two more questions.
1 -
I am in the C/AL CODE. In there I can see code I previously entered. There is RemitText1 through RemitText9 that can print currently. For some of the Payment Terms Code I do not use 7-9.. do I need to specify them?
Here's an example of one I've entered:IF "Payment Terms Code" = 'N30' THEN BEGIN RemitText1 := 'PLEASE REMIT PAYMENT TO:'; RemitText3 := 'OUR COMPANY'; RemitText4 := '## XXXX DRIVE'; RemitText5 := 'SUITE XXX'; RemitText6 := 'CITY, NJ #####'; RemitText7 := ''; RemitText8 := ''; RemitText9 := ''; END;
As you can see 7-9 are blank. Do I even need those three lines? Other times it's used, not in this case.
2 -
Where am I to enter this new code? For example I have the following code:IF "Payment Terms Code" = 'NET+30F' THEN BEGIN RemitText1 := 'MAKE AND MAIL CHECKS PAYABLE TO:'; RemitText3 := 'SOME CORPORATION'; RemitText4 := 'P.O. BOX ####'; RemitText5 := 'MIDTOWN STATION'; RemitText6 := 'NEW YORK, NY 10018'; RemitText7 := 'THIS ACCOUNT AND ALL THE MERCHANDISE CONSTITUTING THE SAME HAVE BEEN ASSIGNED AND ARE'; RemitText8 := 'OWNED BY, AND PAYABLE EXCLUSIVELY TO SOME CORPORATION. IF INCORRECT, IN'; RemitText9 := 'ANY PARTICULAR, COMMUNICATE DIRECTLY TO SOME CORPORATION.'; END; IF "Payment Terms Code" = 'NET10EOMF' THEN BEGIN RemitText1 := 'MAKE AND MAIL CHECKS PAYABLE TO:'; RemitText3 := 'SOME CORPORATION'; RemitText4 := 'P.O. BOX ####'; RemitText5 := 'MIDTOWN STATION'; RemitText6 := 'NEW YORK, NY 10018'; RemitText7 := 'THIS ACCOUNT AND ALL THE MERCHANDISE CONSTITUTING THE SAME HAVE BEEN ASSIGNED AND ARE'; RemitText8 := 'OWNED BY, AND PAYABLE EXCLUSIVELY TO SOME CORPORATION. IF INCORRECT, IN'; RemitText9 := 'ANY PARTICULAR, COMMUNICATE DIRECTLY TO SOME CORPORATION.'; END;
.. there's more of them following that one for other Payment Terms Code. We're going to add RemitText10 to say 'For assistance call ###-###-####'.
The other two questions - there's 12 of those.. is there a way to add all of them into one? likeIF "Payment Terms Code" = 'NET+30F' OR 'NET10EOMF' THEN BEGIN
I know you probably cannot have more than one OR, but maybe there's another way to do it. Then I can at least shorten my C/AL CODE.
Also, where I am going to add in the code for RemitText10.. will I need to add that every time after RemitText9?0 -
Yes you should definitely always set all of those variables.
Instead of using multiple IF statements, you should be using a CASE statement.CASE "Payment Terms Code" OF 'N30': BEGIN RemitText1 := 'PLEASE REMIT PAYMENT TO:'; RemitText3 := 'OUR COMPANY'; RemitText4 := '## XXXX DRIVE'; RemitText5 := 'SUITE XXX'; RemitText6 := 'CITY, NJ #####'; RemitText7 := ''; RemitText8 := ''; RemitText9 := ''; END; 'NET+30F','NET10EOMF': BEGIN // insert code for those two in here END; END;
The difference is that with IF statements, it has to evaluate the same value in every IF statement. With a CASE statement it only needs to evaluate the value once, so it is more efficient.
If you're dead set on using multiple IF statements, go like this:IF ("Payment Terms Code" = 'NET+30F') OR ("Payment Terms Code" = 'NET10EOMF') THEN BEGIN
You can have as many OR statements as you want.
Yes you will have to add the Remit10 value to all of them, unless the value is the same for all of them.0 -
DenSter wrote:IF ("Payment Terms Code" = 'NET+30F') OR ("Payment Terms Code" = 'NET10EOMF') THEN BEGIN
or useIF "Payment Terms Code" IN ['NET+30F','NET10EOMF','third code','forth code','etc.'] THEN
sometimes it's easier to do it the other way aroundIF NOT ("Payment Terms Code" IN ['NET+30F','NET10EOMF']) THEN
0 -
Just wanted to say it worked perfectly.0
-
EDIT: Wrong post.0
-
EDIT: Wrong post.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions