SBX - Search With Button

SBX - Forum Post Title

Boolean Control check/uncheck through code in Posted documents.

Microsoft Dynamics NAV Forum

NAV Beginners asked a question on 10 Jun 2019 3:51 AM
My Badges

Question Status

Verified

Dear Experts,

How to check and unchecked the Boolean control used the code in Posted document page.
I have added the check box in General ledger entry. When I press the button then Boolean control is checked. How to uncheck it with same button, what I need to add extra logic in my code. Please suggest me.


Audit Done - OnAction()
"Audit Done":=TRUE;
GLEntry1."Audit Check Date":=CURRENTDATETIME;

GLEntry1.RESET;
GLEntry1.SETRANGE(GLEntry1."Document No.","Document No.");
IF GLEntry1.FIND('-') THEN BEGIN
REPEAT
GLEntry1."Audit Done":=TRUE;
GLEntry1."Audit Check Date":=CURRENTDATETIME;
GLEntry1.MODIFY;
UNTIL GLEntry1.NEXT=0
END;

Please help me to resolve my issue. I have attached the screenshot

Reply
I Gusti Made Ari Permadi responded on 10 Jun 2019 4:42 AM
My Badges
Verified Answer
//removed "Audit Done":=TRUE;
//removed GLEntry1."Audit Check Date":=CURRENTDATETIME;

GLEntry1.RESET;
GLEntry1.SETRANGE(GLEntry1."Document No.","Document No.");
IF GLEntry1.FIND('-') THEN BEGIN
REPEAT
IF GLEntry1."Audit Done" THEN BEGIN
   GLEntry1."Audit Done" := FALSE;
   GLEntry1."Audit Check Date":= CREATEDATETIME(0D,0T);
END ELSE BEGIN
   GLEntry1."Audit Done":=TRUE;
   GLEntry1."Audit Check Date":=CURRENTDATETIME;
END;

GLEntry1.MODIFY; 
UNTIL GLEntry1.NEXT=0
END;
Reply
I Gusti Made Ari Permadi responded on 10 Jun 2019 4:42 AM
My Badges
Verified Answer
//removed "Audit Done":=TRUE;
//removed GLEntry1."Audit Check Date":=CURRENTDATETIME;

GLEntry1.RESET;
GLEntry1.SETRANGE(GLEntry1."Document No.","Document No.");
IF GLEntry1.FIND('-') THEN BEGIN
REPEAT
IF GLEntry1."Audit Done" THEN BEGIN
   GLEntry1."Audit Done" := FALSE;
   GLEntry1."Audit Check Date":= CREATEDATETIME(0D,0T);
END ELSE BEGIN
   GLEntry1."Audit Done":=TRUE;
   GLEntry1."Audit Check Date":=CURRENTDATETIME;
END;

GLEntry1.MODIFY; 
UNTIL GLEntry1.NEXT=0
END;
Reply

SBX - Two Col Forum

SBX - Migrated JS