OnFormat error in Sales Line

bluecat1972bluecat1972 Member Posts: 14
edited 2008-03-11 in Navision Financials
I'm trying to update the forecolor and bold on the OnFormat trigger for the Unit Price field in the Sales Quote Subform. I've used basically this code for other fields in this form with no problem. With this specific one only, however, I get an error saying that I cannot modify the font in this context. Does anyone have any idea what I could do differently to affect this change? I have not found a solution in any of the many topics about UPDATEFORECOLOR or UPDATEFONTBOLD. Any insight is much appreciated.

Here is my code:

IF "List Price Discrepancy" AND (NOT ("List/Discount Override")) THEN BEGIN
CurrForm."Unit Price".UPDATEFORECOLOR(255);
CurrForm."Unit Price".UPDATEFONTBOLD(TRUE)
END;

Answers

  • SavatageSavatage Member Posts: 7,142
    Works for me and your's isn't so different.

    Is the missing ; after TRUE in your code just a post typo?
    OnFormat(VAR Text : Text[1024];)
      IF "Unit Price" = 0
      THEN BEGIN
       CurrForm."Unit Price".UPDATEFORECOLOR(255);
       CurrForm."Unit Price".UPDATEFONTBOLD(TRUE);
      END;
    

    I assume those are custom booleans - when do they get assigned a value?
    perhaps that's your prob?
  • kinekine Member Posts: 12,562
    May be that you just overlooked the trigger name and you pass the code into another trigger that you want? I made this mistake many times... ;-)

    And yes, there is missing one semicolon...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • bluecat1972bluecat1972 Member Posts: 14
    Thanks for your help - I actually put the wrong field name in. It should have been "List Price" - in this case, "Unit Price" is the customer price and "List Price" is the MSRP. We're trying to flag the line if the list price or our discount is not the same as the item card.

    Interestingly, now that I've got the correct field name, I'm still getting an error. Now it says that I've specified an unknown variable "List Price" and to define it in the globals. But it's definitely part of my table.


    IF "List Price Discrepancy" AND (NOT ("List/Discount Override")) THEN BEGIN
    CurrForm."List Price".UPDATEFORECOLOR(255);
    CurrForm."List Price".UPDATEFONTBOLD(TRUE);
    END;

    As for the missing semi-colon, I was taught to omit it before an ELSE or an END.
  • kinekine Member Posts: 12,562
    As for the missing semi-colon, I was taught to omit it before an ELSE or an END.

    Before ELSE yes, before end it is not good practice, because in most cases you forgot to add it there if you enter some new line after it before end... :-) But just my opinion...
    Interestingly, now that I've got the correct field name, I'm still getting an error. Now it says that I've specified an unknown variable "List Price" and to define it in the globals. But it's definitely part of my table.

    One of these points can lead you to solution:
    1) Try to select the control name from Symbol Menu (F5)
    2) Check the name property of the editbox on your form.
    3) Check the control name which is showen in the Trigger name line.

    [/code]
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • bluecat1972bluecat1972 Member Posts: 14
    OK, thanks, that did the trick - my field was not registering as a control. Fixing that fixed everything.
  • ara3nara3n Member Posts: 9,256
    I've solved it with her doing a remote desktop session.

    The problem was that the text field did not have a control name.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.