Lock/Unlock a Form using Boolean Field

IrishGiriIrishGiri Member Posts: 61
I want to make a boolean field available to a subset of users to allow them to control access to a form. At the moment my cod is the following:
Form - OnAfterGetRecord()

IF xBool = TRUE THEN BEGIN
   CurrForm.EDITABLE(FALSE);
   //TestUser;
   //CurrForm.xBool.EDITABLE(TRUE);
END;
IF xBool = FALSE THEN
   CurrForm.EDITABLE(TRUE);


The problem occurs when a user blocks the form. Now I can't unblock the form. I need to make this booelan field editable - I tried putting the commented code above to solve this problem but nothing happens. Once I block the form, it can't be unblocked.

Any suggestions?

Answers

  • diptish.naskardiptish.naskar Member Posts: 360
    Yeaps you can do this....

    If you have an extra codeunit/report with you, then write a new function, pass the record variable as a parameter to this function Modify the boolean filed to true and exit. Now allow permission to only few users who will be able to execute the report/codeunit.

    Hope this works for you.
    Diptish Naskar
    For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
  • IrishGiriIrishGiri Member Posts: 61
    well, maybe I should clarify...I'm not worried about permissions just yet. First, I want to be able to unblock this form, I can't even do this. How can this be so difficult to program? ](*,)
  • IrishGiriIrishGiri Member Posts: 61
    Solved this by creating a menu button with 2 menu items: Block and Unblock, in addition to my earlier code. The code in the OnPush trigger of each is as follows:
    xBool := TRUE;
    MODIFY;
    


    and....
    xBool := FALSE;
    MODIFY;
    

    and...
    IF xBool = TRUE THEN
       CurrForm.EDITABLE(FALSE);
    
    IF xBool = FALSE THEN
       CurrForm.EDITABLE(TRUE);
    

    In addition to my earlier code in the Form - OnAfterGetRecord() trigger this works a treat!
  • kinekine Member Posts: 12,562
    Your problem is that if you set EDITABLE = false for whole form, you cannot "disable" this property through control. As IrishGiri wrote, your solution is to use button and not checkbox to unlock the form. Buttons are working even if the form is uneditable...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.