6 Replies Latest reply on Feb 4, 2015 6:00 AM by davidjdunn

    Get (ConditionalFormattingState)…????


      Is there a calculation/function for determining if a field or layout object is conditionally formatted. In other words, something like “Get (ConditionalFormattingState ; Field A )” that would return a 1 or a 2.


      Here is why this would be really cool:


      Picture a multi-layout form. At the top of each page is a row of buttons that navigates to different layouts. In effect, it looks a bit like a web page menu bar. (I find this solution is less of a resource suck for WebDirect users.)


      This multi-layout form is complicated. Some fields are only required if certain conditions are met. The best way I have found to make sure I get everything I need is to create a script that does two things:


      1. The script sets a field in the table called “z_Evaluate.” Required fields are conditionally formatted to “IsEmpty (Self) and not IsEmpty (z_Evaluate).”


      2. This is followed by a lot of “If/Else” if statements that notifies the user if data are missing and points the user to the layout it is on.


      This works well. However, not only does the extensive conditional logic summon the gremlins of developer error, but it also means that the user may have to run the script three times if data are missing on three different layouts.


      Then the thought occurred to me to conditionally format the header buttons too. That way the user will know that required data are missing on other layouts. But it also occurred to me that I might be able to use this method to simplify the script. Instead of thirty If/Else If statements, I could have one for each button. It would look something like


      If [ Button A conditional formatting is “true”]

      Show custom dialog; “Required info missing.”

      Else if [Button B conditional formatting is “true]

      Show custom dialog; “Required info missing.”




      The only problem is, I cannot figure out how to “Get” the conditional formatting state of a layout object/field. Help!

        • 1. Re: Get (ConditionalFormattingState)…????

          You have access to the Calculation dialog in conditional formatting. Set a global variable in your calc.

          • 2. Re: Get (ConditionalFormattingState)…????

            One problem with this idea, is that Conditional Formatting doesn't have one test. It can have many! Which one is evaluating true?


            Now related to your actual issues...I don't recommend this, but you *could* put all your logic into custom functions. Whatever calc you use in the conditional formatting, but into a custom function instead. Put that custom function in the conditional formatting and in the script.

            • 3. Re: Get (ConditionalFormattingState)…????
              Benjamin Fehr

              I doubt that there's any way to achieve this. I was just going thru the GetLayoutObjectAttribute function where, if exists, it would belong.

              I think there's room to expand this function anyway though I recommend to have this forwarded to FMI as a feature request!

              • 4. Re: Get (ConditionalFormattingState)…????

                The purpose of conditional formatting, as I see it, is to give visual guidance to users—some sort of highlighting of fields that require data, revealing a button that can be used because some condition exists, etc. You determine the formulas that govern the conditional formatting; you can also use those same formulas to control other behaviour also, such as custom dialogs.

                • 5. Re: Get (ConditionalFormattingState)…????

                  I'm with keywords on this: since you have to specify a test to format a field or leave it alone, it should be straightforward to use the same test in your branching logic.

                  Otherwise you are burying some logic on your layout instead of in your scripted workflow.


                  To avoid duplicating calculations you can use custom functions like David mentioned.

                  • 6. Re: Get (ConditionalFormattingState)…????

                    Thanks for the tips everybody!


                    First of all, I realized that I meant 1 or 0, not 1 or 2.


                    Second, I realized I was overthinking it. You are right, @wimdecorte, about the problem of burying some logic in the layout. Bad idea. The long if/then chain is obnoxious but probably the best thing. However, rather than exiting the script every time it encounters missing info, it occurred to me that I will just have it change the data in the z_ Evaluate field. That will make all the layout objects light-up and tell the user which layouts contain missing required data.