Color Change For Credit Memo's

SavatageSavatage Member Posts: 7,142
edited 2010-03-18 in Navision Attain
When I pay a Vendor I go to the Payment Journal,
Enter the vendor #, blah blah & hit apply entries.

In which all that vendors OPEN enties appear.
I hit f9 to select which Invoices & credits I want to Pay & Use.

Some Vendors Have A ton of Entries. How can I make the Apply Vendor Enties Form show the credits in red?

01/01/01 - Invoice - 200
01/02/01 - Invoice - 201
01/03/01 - Invoice - 202
01/01/02 - Credit - 100
01/04/01 - Payment - 150

Answers

  • SavatageSavatage Member Posts: 7,142
    OK if I put it on

    OnFormat(VAR Text : Text[1024];)
    CASE "Document Type" OF 
      "Document Type"::"Credit Memo" : 
      CurrForm.Amount.UPDATEFORECOLOR(255);
      "Document Type"::Payment :
      CurrForm.Amount.UPDATEFORECOLOR(32768);
    ELSE 
      CurrForm.Amount.UPDATEFORECOLOR(0);
    END;
    

    But How Can I Get The Whole Line To Be colored Without having to put this code on every field?

    Code Above Makes
    Credit=Red
    Payment=Green
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Savatage wrote:
    [...] But How Can I Get The Whole Line To Be colored Without having to put this code on every field? [...]
    You can't. You have to duplicate this code on every column of the form.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Timo_LässerTimo_Lässer Member Posts: 481
    Savatage wrote:
    [...]
    But How Can I Get The Whole Line To Be colored Without having to put this code on every field?
    [...]
    There is no chance. You have to write code in all OnFormat-Triggers of all fields which you want it.
    You can make it easier if you put your code in a function and only calls the function in the OnFormat-Trigger. This function then returns the color value.

    OnFormat(VAR Text : Text[1024]):
    CurrForm.YourControlName.UPDATEFORECOLOR(SetForeColor);
    
    SetForeColor() : Integer
    CASE "Document Type" OF 
      "Document Type"::"Credit Memo" : EXIT(255);
      "Document Type"::Payment : EXIT(32768); 
      ELSE 
        EXIT(0); 
    END;
    
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • SavatageSavatage Member Posts: 7,142
    Savatage wrote:
    [...] But How Can I Get The Whole Line To Be colored Without having to put this code on every field? [...]
    You can't. You have to duplicate this code on every column of the form.

    That's what I was Afraid of. Oh Well.
  • SavatageSavatage Member Posts: 7,142
    out of all the changes I have made in Navision - this one has gotten one of the best responses.

    I've added it to several forms and even did the little

    if unit price = 0 change to red on sales orders thing.

    I guess when staring at a screen for 8 hrs a day - little changes like this really make the users happy.
  • FrabsFrabs Member Posts: 12
    hi,

    sorry for reactivate this :roll:
    How would the code look like if I would like to have unit price = 0 in the sales line ?
  • DenSterDenSter Member Posts: 8,304
    IF "Unit Price" = 0 THEN EXIT(ColorThatYouWant)
    
  • FrabsFrabs Member Posts: 12
    Thanks,
  • SavatageSavatage Member Posts: 7,142
    Now we're allowed to add images :mrgreen:
  • DenSterDenSter Member Posts: 8,304
    Endless beauty Harry, endless beauty... :mrgreen:
  • SavatageSavatage Member Posts: 7,142
    Unfortunately Endless Beauty is out of business :lol:
  • AlexWileyAlexWiley Member Posts: 230
    Savatage wrote:
    OnFormat(VAR Text : Text[1024];)
    CASE "Document Type" OF 
      "Document Type"::"Credit Memo" : 
      CurrForm.Amount.UPDATEFORECOLOR(255);
      "Document Type"::Payment :
      CurrForm.Amount.UPDATEFORECOLOR(32768);
    ELSE 
      CurrForm.Amount.UPDATEFORECOLOR(0);
    END;
    

    colorset.jpg

    Debugger is pointing at ELSE... I was just trying to use this as a starting point to play around with this and I immediately got nailed with this error I don't understand.

    I put this in the OnFormat(VAR Text : Text[1024];) of Document Type of Customer Ledger Entries, not Amount.
  • SavatageSavatage Member Posts: 7,142
    AlexWiley wrote:
    Savatage wrote:
    OnFormat(VAR Text : Text[1024];)
    CASE "Document Type" OF 
      "Document Type"::"Credit Memo" : 
      CurrForm.Amount.UPDATEFORECOLOR(255);
      "Document Type"::Payment :
      CurrForm.Amount.UPDATEFORECOLOR(32768);
    ELSE 
      CurrForm.Amount.UPDATEFORECOLOR(0);
    END;
    
    That code is only good for the AMOUNT column. You probbay have it on another column that isn't Amount and you can't change the color of one field from another - hence the error...
    You have to change your code slightly for each column you want to change
    for example for the "Document No" column you would put this:
    OnFormat(VAR Text : Text[1024];)
    CASE "Document Type" OF 
      "Document Type"::"Credit Memo" : 
      CurrForm."Document No.".UPDATEFORECOLOR(255);
      "Document Type"::Payment :
      CurrForm."Document No.".UPDATEFORECOLOR(16711680);
    ELSE 
      CurrForm."Document No.".UPDATEFORECOLOR(0);
    END;
    

    For Posting Date this:
    OnFormat(VAR Text : Text[1024];)
    CASE "Document Type" OF 
      "Document Type"::"Credit Memo" : 
      CurrForm."Posting Date".UPDATEFORECOLOR(255);
      "Document Type"::Payment :
      CurrForm."Posting Date".UPDATEFORECOLOR(16711680);
    ELSE 
      CurrForm."Posting Date".UPDATEFORECOLOR(0);
    END;
    
    etc etc
  • AlexWileyAlexWiley Member Posts: 230
    Yar, I can't believe I missed that, I got focused on 'CASE "Document No." OF and thought that was the call, I didn't even pay attention to the CurrForm call. Thank you Savatage, works perfectly now!
  • grofsgrofs Member Posts: 53
    Hy All,

    I read this topic, but I couldn't do line color change. :(
    I understand the code, but in case sales line color, where have to write the code?
    I couldnt find it! :(

    thx
  • SavatageSavatage Member Posts: 7,142
    It's pretty clear if you back over the posts that the ON FORMAT trigger of the FORM is where the code goes.

    You have to put the code on every field you want to change - it will not do the whole line in one shot (I Know ](*,) )

    the only thing you have to change in the code as you go field by field isto change this part.
    CurrForm.Amount.UPDATEFORECOLOR(255); <<-- Use this on the Amount Field

    CurrForm."Posting Date".UPDATEFORECOLOR(255); <<--You would alterthe code to this if you are putting on the posting date field

    CurrForm."Document Type".UPDATEFORECOLOR(255); <<--You would alterthe code to this if you are putting on the document type field

    CurrForm."ETC, etc etc etc".UPDATEFORECOLOR(255);
Sign In or Register to comment.