1 Reply Latest reply on Aug 28, 2013 3:04 PM by philmodjunk

    If not all fields are empty then cannot use drop down.

    jwshelton22

      Title

      If not all fields are empty then cannot use drop down.

      Post

           In FM12 Advanced.

           I have a field with a drop down. And about 120 other fields on the layout. All fields are Text.

            

           The drop down is Custom Values.

           How is the best way so the User cannot change the drop down if any of the 120 fields have data?

            

           thanks,

           Jim

        • 1. Re: If not all fields are empty then cannot use drop down.
          philmodjunk

               That's a lot of fields in one record. That may indicate that different data model may be a better option.

               Using what you have, you'd need a very lengthy calculation expression to determine that all fields are empty;

               Either:

               Not IsEmpty ( Field1 & Field2 & .....Field120)

               or

               Not IsEmpty (Field1) and IsEmpty (Field2) and ....IsEmpty(Field120)

               or

               count ( Field1 ; field2 ; field3 ; field4 .... field120 )

               But maybe there's a better way. Put a tab control on your layout. Put your drop down list field on one tab. Put the same field, but without drop down formatting on the other and use behavior settings in the inspector to deny browse mode access. Give each tab panel an object name. Use the OnObjectSave trigger on all 120 fields with this script to set field 121 to a value if there is data in the field:

               If [ Not Isempty ( Get ( ActiveFieldContents ) ) ]
                  Set FIeld [YourTable::Field121 ; YourTable::Field121 + 1 ]
               Else If [ Get ( ActiveFIeldContents )  ≠ $$PriorValue ]
                   Set Field [ YOurTable::Field121 ; YourTable::Field121 - 1]
               End IF
               Go to Object [ If ( YOurTable::Field121 ; "ObjectNameForLockedTab" ; "objectnameforDropDownTab" )]

               You also need to set up the OnObjectEnter trigger with the entered field passed to it as a script parameter. (If this is the trigger for Field1, put YourTable::Field1 in the optional script parameter box) with this script:

               Set Variable [$$PriorValue ; Get ( ScriptParameter ) ]