Hi,
thanks al ot to everyone who answered. I found my mistake and solved the problem with your help!
=D>
=D>
With best greetings from germany!!
csoch
Hi together,
i've got the problem, that the color don't want to change....
In form 516 "Sales Line" i wrote this code in section
"Sell-to customer No." - OnFormat(VAR TEXT : TEXT[1024]:):
SalesLine.RESET;
SalesLine.SETRANGE("Document Type",SalesLine."Document Type"::Order);
SalesLine.SETRANGE("Document No.","No.");
SalesLine.SETRANGE("Type",SalesLine."Type"::Item);
SalesLine.SETFILTER("Sell-to Customer No.",'190010|190020|190030|190040|190049|190072|190079|190080');
IF SalesLine.FIND('-') THEN
CurrForm."Sell-to Customer No.".UPDATEFORECOLOR(255);
My problem: It doesn't work..... :oops:
Thanks for help!!
Greetings from germany
cosch
Answers
So, better is a Setup table where you store the Customer No.. so you are flexible and you must not ever change the sourcecode if a new customer must be red.
Why do you need it red? Arre these blocked customers?
Regards
as above, instead of hard coding those customer numbers it's better to create a boolean field on the customer card called
"Salesline Alert" or whatever name or reason you need "Sell-to Customer No." red.
Customer->Record->Customer
OnFormat(VAR Text : Text[1024];)
Edit: "Salesline Alert" is a new field type boolean
http://www.BiloBeauty.com
http://www.autismspeaks.org
Since you're at the form already, there's no need to get it.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
http://www.BiloBeauty.com
http://www.autismspeaks.org
In the code I put up, I'm not getting the customer record at all. I'm just looking at the characters that is on the Sell-to Customer No. field.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
A code like that is used more to run thru the lines and make some kind of change.
there is actually no changing going on.
http://www.BiloBeauty.com
http://www.autismspeaks.org
- ok, we are getting lines for this document, for same document we are on....
- ok, all Item lines of the current document
- and if there is some Item line for the current document, which customer is in the filter, make the line red.
Result is> that you have field "Sell - to Customer No." colored into Red for all orders, which are for predefined set of customers, and have one or more Item lines. Of course, it is coloring other lines too, because you never set the color to black for other lines... ;-)
Question is, if you can do the Customer condition better. And yes, you can (or better - it will be VERY GOOD to make it in another way). E.g. in this way:
PRO of this solution:
- You can easilly add or remove customers for which the document will be colored just by changing value of the field (One check box on the customer card).
- You are checking the existence of the Item line only for customers, for which it is relevant, thus creating no performance issue for other customers
- You are not even reading the lines, you are just checking, if there is any or no. On SQL it means lower performance too
- All other lines are black
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Your Rec variable is a sales line.
SalesLine."Document No." is a Document Number
Rec."No." is an Item Number (or similar)
Never gonna work.
TVision Technology Ltd
Yes, I used the SalesHeader first, forgot to change it after I removed it... code was done from scratch without NAV... 8)
Thanks for correction... original post updated...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
You need only to check the condition (is a field set on the customer or is the customer in a setup table or what else) ....
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Oh, I see, Well I did say it was a rather common bug
TVision Technology Ltd
http://www.BiloBeauty.com
http://www.autismspeaks.org
The original code (if it will be corrected to work) will do this:
Order 1 Item CUST0001
Order 1 G/L Account CUST0001
Order 1 Resource CUST0001
(all colored red because there is one line of type Item)
Order 2 Resource CUST0001
Order 2 G/L Account CUST0001
Order 2 Resource CUST0001
(no item line, no coloring)
Your example will do:
Order 1 Item CUST0001
Order 1 G/L Account CUST0001
Order 1 Resource CUST0001
But what is correct must say cosch1, nobody else... 8)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
1) Sorry, I edited my post and corrected the mistake, if you still saw the original post, it is your cache which is wrong...
2) I didn't catch the second point... may be just my language barrier and limitation of written text... :-k
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
with adding flexibility & no hard coding. I didn;t try to fix that code.
http://www.BiloBeauty.com
http://www.autismspeaks.org
My original comment was to the message at the top of this topic by cosch1 and that was actually the line I quoted, he had exactly the same bug as you did.
TVision Technology Ltd