Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Setting A Checkbox From Conditional Expression

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Setting A Checkbox From Conditional Expression

    Alpha never ceases to amaze me!

    I was trying to set a checkbox based on the value on a numeric control. I never noticed this before but you can call a javascript function from the condtional style of a control.
    This is what I mean:

    JavascriptCallPass.jpgConditionalStylePass.png

    ConditionalStyleFail.jpgJavascriptCallFail.jpg

    I've attached a small sample UX if anyone wants to look at it.


    As an aside, if anyone bothers to download and try the UX, please try to enable Pre-Rendering on the component and see if it gives an error. I have a problem with all attempts to enable Pre-Rendering. But this component is very simple and has no security that should cause issues. Just like to know if it works for anyone else?
    Attached Files
    Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

    #2
    Re: Setting A Checkbox From Conditional Expression

    Downloaded, imported, turned on prerender, ran in Live Preview.

    Entered number 2, got red. Entered number 1 got green. Entered number 0.5 got red.

    I don't see any errors.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant​​

    Comment


      #3
      Re: Setting A Checkbox From Conditional Expression

      Originally posted by iRadiate View Post
      Alpha never ceases to amaze me!

      I was trying to set a checkbox based on the value on a numeric control. I never noticed this before but you can call a javascript function from the condtional style of a control.
      This is what I mean:

      [ATTACH=CONFIG]43134[/ATTACH][ATTACH=CONFIG]43135[/ATTACH]

      [ATTACH=CONFIG]43136[/ATTACH][ATTACH=CONFIG]43137[/ATTACH]

      I've attached a small sample UX if anyone wants to look at it.


      As an aside, if anyone bothers to download and try the UX, please try to enable Pre-Rendering on the component and see if it gives an error. I have a problem with all attempts to enable Pre-Rendering. But this component is very simple and has no security that should cause issues. Just like to know if it works for anyone else?
      I did not see any errors running your component.

      It would be helpful if you post the exact error message that you're seeing. Does it display an error when you check the box? Run it in working preview? Run it in live preview? After publishing? When you save?
      Sarah Mitchell
      Director of Customer Success | [URL="https://www.alphasoftware.com"]Alpha Software Corporation[/URL]
      [B]Get in the know! [/B] Join us for our Weekly Webinars: [URL="https://www.alphasoftware.com/weekly-transform-tuesday-webinar"]TransForm Tuesday[/URL] and [URL="https://www.alphasoftware.com/weekly-alpha-anywhere-overview-webinar"]Wednesday's Alpha Anywhere Demo and Q&A[/URL]
      Connect with us: [URL="https://www.instagram.com/alpha_software_corp/"]Instagram[/URL] | [URL="https://twitter.com/AlphaSoftware"]Twitter[/URL] | [URL="https://www.facebook.com/AlphaSoftware/"]Facebook[/URL] | [URL="https://www.linkedin.com/company/alpha-software"]LinkedIn[/URL] | [URL="https://www.youtube.com/user/AlphaSoftwareInc"]YouTube[/URL]

      Comment


        #4
        Re: Setting A Checkbox From Conditional Expression

        Originally posted by Beta Spark View Post
        I did not see any errors running your component.

        It would be helpful if you post the exact error message that you're seeing. Does it display an error when you check the box? Run it in working preview? Run it in live preview? After publishing? When you save?
        Sarah, here is what I see ... https://www.screencast.com/t/3zoqKvoIn

        Running in working preview. I haven't tried publishing, I have yet to publish a component with pre-rendering that will work for me. I have security enabled on nearly all my components, but this one doesn't.
        Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

        Comment


          #5
          Re: Setting A Checkbox From Conditional Expression

          Originally posted by iRadiate View Post
          Sarah, here is what I see ... https://www.screencast.com/t/3zoqKvoIn

          Running in working preview. I haven't tried publishing, I have yet to publish a component with pre-rendering that will work for me. I have security enabled on nearly all my components, but this one doesn't.
          I can reproduce this only when running Working Preview using Internet Explorer. If you switch Working Preview to use Chrome, this error did not occur.

          This error did not occur in Live Preview or when published.

          Try switching your Working Preview to use Chrome or use Live Preview instead.
          Sarah Mitchell
          Director of Customer Success | [URL="https://www.alphasoftware.com"]Alpha Software Corporation[/URL]
          [B]Get in the know! [/B] Join us for our Weekly Webinars: [URL="https://www.alphasoftware.com/weekly-transform-tuesday-webinar"]TransForm Tuesday[/URL] and [URL="https://www.alphasoftware.com/weekly-alpha-anywhere-overview-webinar"]Wednesday's Alpha Anywhere Demo and Q&A[/URL]
          Connect with us: [URL="https://www.instagram.com/alpha_software_corp/"]Instagram[/URL] | [URL="https://twitter.com/AlphaSoftware"]Twitter[/URL] | [URL="https://www.facebook.com/AlphaSoftware/"]Facebook[/URL] | [URL="https://www.linkedin.com/company/alpha-software"]LinkedIn[/URL] | [URL="https://www.youtube.com/user/AlphaSoftwareInc"]YouTube[/URL]

          Comment


            #6
            Re: Setting A Checkbox From Conditional Expression

            Originally posted by Beta Spark View Post
            I can reproduce this only when running Working Preview using Internet Explorer. If you switch Working Preview to use Chrome, this error did not occur.

            This error did not occur in Live Preview or when published.

            Try switching your Working Preview to use Chrome or use Live Preview instead.
            Okay, thanks.
            Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

            Comment


              #7
              Re: Setting A Checkbox From Conditional Expression

              Note: there are at least two things to be aware of when using functions in your client-side conditional expressions:

              1) Unless Alpha has fixed this issue, if you use a function in the conditional expression(s) itself and you want to pass variables (values from the current row, for example) then you have to force Alpha to prepare local copies of these variables by inserting fake conditions at the top of your conditional expressions list. The 'fake' conditions do nothing, other than force alpha to init local variables that it will use when the JavaScript calls the function that is part of the conditional expression. For example, you might want to call a common function that determines if a user has access to edit values. If the function takes two parameters, like "limitUpdateByRole" and "allowedRolesList" and those values can be retrieved from the current record (the other value it needs, like current user's role, is assumed to be in the global name space), you can force alpha to init those vars by including two fake conditions at the top, like:
              limitUpdateByRole = "Force Alpha to init var"
              allowedRolesList = "Force Alpha to init var"

              Now in the real conditional expression you can call some function that uses those values, "CanEditRecord(limitUpdateByRole, allowedRolesList) == "N". You can either hard code style attributes or you can call a function to set the attributes, as in your example.

              2) If you set the control's style by calling a function then you have to be very careful about the function name. Maybe this has been corrected in Alpha, or perhaps there is a workaround, but originally I did not find anyway to use either the {Grid.ComponentName} or {Grid.Object} methods of declaring/naming functions that are called when the condition evaluates to true. This meant all the functions used here had to be declared in the global name space. I put all mine in the tabbedUI component - makes debugging difficult, unless you temporarily copy the javascript functions back to the component.

              Comment


                #8
                Re: Setting A Checkbox From Conditional Expression

                Stephen,
                Yes, I get an error if I run your component with "Pre-render" turned on, in working preview in Build 4119. But I also get the same javascript error if I create a new UX.

                Two things about your UX, though, the "<" and "<" characters in the first label field need to be "HTML escaped", to be safe.
                And, for the use of "Number" as a field Id, it might be better to choose something that is not a keyword in JavaScript. That way when you write the conditional expressions you won't run the possibility of confusing JavaScript. Although,it recognizes you are not using the function 'Number()', but instead using your own variable called, 'Number'. It just seems better to avoid the name conflict.

                Comment


                  #9
                  Re: Setting A Checkbox From Conditional Expression

                  Originally posted by RichCPT View Post
                  Note: there are at least two things to be aware of when using functions in your client-side conditional expressions:

                  1) Unless Alpha has fixed this issue, if you use a function in the conditional expression(s) itself and you want to pass variables (values from the current row, for example) then you have to force Alpha to prepare local copies of these variables by inserting fake conditions at the top of your conditional expressions list. The 'fake' conditions do nothing, other than force alpha to init local variables that it will use when the JavaScript calls the function that is part of the conditional expression. For example, you might want to call a common function that determines if a user has access to edit values. If the function takes two parameters, like "limitUpdateByRole" and "allowedRolesList" and those values can be retrieved from the current record (the other value it needs, like current user's role, is assumed to be in the global name space), you can force alpha to init those vars by including two fake conditions at the top, like:
                  limitUpdateByRole = "Force Alpha to init var"
                  allowedRolesList = "Force Alpha to init var"

                  Now in the real conditional expression you can call some function that uses those values, "CanEditRecord(limitUpdateByRole, allowedRolesList) == "N". You can either hard code style attributes or you can call a function to set the attributes, as in your example.

                  2) If you set the control's style by calling a function then you have to be very careful about the function name. Maybe this has been corrected in Alpha, or perhaps there is a workaround, but originally I did not find anyway to use either the {Grid.ComponentName} or {Grid.Object} methods of declaring/naming functions that are called when the condition evaluates to true. This meant all the functions used here had to be declared in the global name space. I put all mine in the tabbedUI component - makes debugging difficult, unless you temporarily copy the javascript functions back to the component.
                  Rich, thanks for the heads up. In my case, I'm not passing anything, just checking a control that does a calculation. Depending on the results of the calculation, I wanted to set the style. I also wanted to set the checkbox on or off. I didn't realize I could do this directly in the client-side conditional expression but I think it's pretty cool and thought I'd share in case anyone else wasn't aware of this.
                  Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                  Comment


                    #10
                    Re: Setting A Checkbox From Conditional Expression

                    Originally posted by RichCPT View Post
                    Stephen,
                    Yes, I get an error if I run your component with "Pre-render" turned on, in working preview in Build 4119. But I also get the same javascript error if I create a new UX.

                    Two things about your UX, though, the "<" and "<" characters in the first label field need to be "HTML escaped", to be safe.
                    And, for the use of "Number" as a field Id, it might be better to choose something that is not a keyword in JavaScript. That way when you write the conditional expressions you won't run the possibility of confusing JavaScript. Although,it recognizes you are not using the function 'Number()', but instead using your own variable called, 'Number'. It just seems better to avoid the name conflict.
                    Rich,

                    I've had no luck ever trying to use pre-rendering, it crashes on every component I use, but oh well.

                    Thanks for the great tips here. It was just a quick and dirty example but you're right about escaping the less-than signs and not using reserved names.
                    Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                    Comment


                      #11
                      Re: Setting A Checkbox From Conditional Expression

                      Originally posted by iRadiate View Post
                      Rich,... Depending on the results of the calculation, I wanted to set the style. I also wanted to set the checkbox on or off.....
                      Yes, I like being able to call a function to set the style; it is very helpful on composite (or "super") controls like the EditBox with Lookup. For disabling that type of control, I use a function to hide the dropdown button icon, change the background and foreground colors, set the control to "ReadOnly" and remove the control from the tabbing sequence.

                      Comment


                        #12
                        Re: Setting A Checkbox From Conditional Expression

                        helo

                        Comment

                        Working...
                        X