Options

How to allow user to only select boolean once per record?

alex6789alex6789 Member Posts: 9
edited 2022-05-16 in NAV Three Tier
How would you approach the following example...

A list page has been created where the user can create a description (e.g. blue paint) and select a series of checkboxes (i.e. gloss/matt/satin/special). For entry 1 the user has created a description and selected the checkbox 'gloss'. For the next entry, the user will create another description and should not be able to select gloss (they should only be able to select the remaining options).

Best Answers

  • Options
    StarvingForLearnStarvingForLearn Member Posts: 6
    Answer ✓
    hello alex,

    it's simple, you should put a code in the OnValidate trigger of your checkboxes that will setrange an instance of your table with the field checked and put 'true' as value, if findfirst then put an error message else let him check that checkbox.
  • Options
    StarvingForLearnStarvingForLearn Member Posts: 6
    Answer ✓
    if you put this code in the OnValidate trigger of every checkbox field that you have

    if Rec.YourCheckBoxFieldName = true then begin
    YourTableInstanceName.Reset()
    YourTableInstanceName.setrange(YourTableInstanceName.YourCheckBoxFieldName,true)
    if YourTableInstanceName.findfirst() then Error("You are not allowed to check this one because it is already checked by another user.")
    end

    everything will be work fine.


Answers

  • Options
    StarvingForLearnStarvingForLearn Member Posts: 6
    Answer ✓
    hello alex,

    it's simple, you should put a code in the OnValidate trigger of your checkboxes that will setrange an instance of your table with the field checked and put 'true' as value, if findfirst then put an error message else let him check that checkbox.
  • Options
    alex6789alex6789 Member Posts: 9
    forgot to mention if the user was to untick this, they should also be allowed. how would you get around that?
  • Options
    StarvingForLearnStarvingForLearn Member Posts: 6
    Answer ✓
    if you put this code in the OnValidate trigger of every checkbox field that you have

    if Rec.YourCheckBoxFieldName = true then begin
    YourTableInstanceName.Reset()
    YourTableInstanceName.setrange(YourTableInstanceName.YourCheckBoxFieldName,true)
    if YourTableInstanceName.findfirst() then Error("You are not allowed to check this one because it is already checked by another user.")
    end

    everything will be work fine.


Sign In or Register to comment.