VALIDATE in OnAssistEdit

ervaroervaro Member Posts: 17
For a field I use the OnAssistEdit trigger in C/AL. In this trigger I also put a VALIDATE command but it seems the validation is not executed at all.
Action Date - OnValidate()
IF "Action Date" > TODAY() THEN BEGIN
     ERROR('Date is after today');
   END;


Action Date - OnAssistEdit()
calendar.AssistEdit("Action Date",FIELDCAPTION("Action Date"),'');
VALIDATE("Action Date","Action Date");

Can somebody please help me to fix this problem.

Thanks.

Erik

Comments

  • kapamaroukapamarou Member Posts: 1,152
    ervaro wrote:
    calendar.AssistEdit("Action Date",FIELDCAPTION("Action Date"),'');
    VALIDATE("Action Date","Action Date");

    Between those two lines add a MESSAGE('!!!!!') to see if the VALIDATE is called before you choose a date. I Had a similar issue in a different case where RUN was used instead of RUNMODAL. Maybe it's something similar here.
  • ervaroervaro Member Posts: 17
    Thanks for your reply.
    The MESSAGE between these lines is executed but still no validation.

    Any suggestions?
  • krikikriki Member, Moderator Posts: 9,110
    Try this:
    Action Date - OnAssistEdit()
    datActionDate := "Action Date";
    calendar.AssistEdit(datActionDate,FIELDCAPTION("Action Date"),'');
    VALIDATE("Action Date",datActionDate);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • JPHSCJPHSC Member Posts: 67
    calendar.AssistEdit("Action Date",FIELDCAPTION("Action Date"),'');

    What code is there in this function, because I don't think the "Action Date" value is updated when you validate...
  • ervaroervaro Member Posts: 17
    @Kriki: Unfortunately it did not work.
    @JPHSC: It is a calendar form to pick a date (also downloaded from this site). When I put a message after the calendar form the picked date is shown.
  • SavatageSavatage Member Posts: 7,142
    from your first post - Does the validate work on Validate-Action Date?

    So you want to add some code on the assist edit to stop a blank? What is actually your problem?
  • kinekine Member Posts: 12,562
    I assume that the OnValidate trigger you mentioned is on form and not on table. VALIDATE() calls only table validation, not form field validation...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ervaroervaro Member Posts: 17
    You are right, I used it as form validation. Will try it as table validation.
    Update: Moving the validation to the table works fine. Thanks to all.
Sign In or Register to comment.