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

Client Side Conditional Format Syntax To Obtain File Extension

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

    #16
    Re: Client Side Conditional Format Syntax To Obtain File Extension

    Whether it's the label control or a dynamic image, the condition still must evaluate to true,
    and in this case, needs to identify what the file extension is.
    I've attached images to show the definition of the dynamic image , it's results, and the
    component I'm using to do the testing.

    2019-08-20_10-47-34.png
    2019-08-20_10-48-25.png
    Attached Files
    Gregg
    https://paiza.io is a great site to test and share sql code

    Comment


      #17
      Re: Client Side Conditional Format Syntax To Obtain File Extension

      Originally posted by jgrannis View Post
      Something like
      data.Notes.slice(-3)=='PDF'
      should work.
      Jeff, you would think so but it doesn't.

      Originally posted by jgrannis View Post
      Another option:
      data.Notes.indexOf('PDF')!=-1
      Neither does this.

      Originally posted by jgrannis View Post
      If neither work, maybe place a console.log of the data in the list's onBeforePopulate event to see if the values of the Notes fields really look like you are expecting. Compare to the values in the data after the list is populated to see if some built-in Alpha code is transforming the filename at some point after onBeforePopulate (are the filenames in the Notes field just some simple static text representing filenames or are they involved in some file synch mechanism of the list control?).
      The list does return the expected referenced file path. I can put the field in the list and the path is there.

      Originally posted by jgrannis View Post
      Additional remark:
      I believe if you go the route of calling a function, the function should determine equality or whatever and then simply return true or false; not have the function return a value to then later try to perform some equality test.
      Thanks, I never thought of this, I'll have to look further into this option.
      Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

      Comment


        #18
        Re: Client Side Conditional Format Syntax To Obtain File Extension

        Originally posted by madtowng View Post
        Just in case you're using MS Sql, I've tested this code, although
        you will need to make obvious adjustments.
        The image shows the results I got from the query.
        Out of curiosity I ran this on all 36 columns of the table, and requested the top 50000 rows to see
        how long the query would take. The image shows just under 3 seconds, which is about the same as
        it takes without the "virtual" column.
        Code:
        select top 1 filename, right(filename,CHARINDEX('.', reverse(filename))-1) AS fileExt
        from files
        where  doctypeid=1
        [ATTACH=CONFIG]46158[/ATTACH]
        [ATTACH=CONFIG]46159[/ATTACH]
        Gregg, this might be the way to go. I'm still playing around with this, I've had to tweak the MS-SQL query a bit but this gives me the extension correctly:

        Code:
         ,RIGHT(Notes,LEN(Notes)-CHARINDEX('.',Notes)) AS FileExt
        I might still need to play with it a bit to make sure filenames containing more than one '.' are considered.

        Thank you both for the suggestions, this has been way more difficult than I expected but I think I'm getting there
        It is so easy using server-side code.
        Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

        Comment


          #19
          Re: Client Side Conditional Format Syntax To Obtain File Extension

          Stephen,
          Glad to hear we got things on the right track. I absolutely agree that server-side is so much easier,
          and to be honest, the primary reason I've been willing to sacrifice speed.
          If you need help or explanation of anything I've provided, feel free to contact me. This obviously
          gets me to generate solutions for problems I hadn't considered.
          Gregg
          https://paiza.io is a great site to test and share sql code

          Comment


            #20
            Re: Client Side Conditional Format Syntax To Obtain File Extension

            Simple all client-side example.

            dynImage.a5wcmp

            Comment


              #21
              Re: Client Side Conditional Format Syntax To Obtain File Extension

              Jeff,
              You obviously know more about javascript than most of us.
              With that said, how would you write it to get that actual extension of
              a filename 'c:/aafiles/invoice.xlsx.pdf' ?
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


                #22
                Re: Client Side Conditional Format Syntax To Obtain File Extension

                Originally posted by jgrannis View Post
                Simple all client-side example.

                [ATTACH]46164[/ATTACH]
                Jeff, this works in your simple component but generates a script error when the data is being pulled from SQL.

                Script Error.png
                Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                Comment


                  #23
                  Re: Client Side Conditional Format Syntax To Obtain File Extension

                  Okay, I have this working using Gregg's virtual SQL column method.

                  To Summarize:

                  1. In the SQL Query create a virtual column to extract the file extension. ie) 'FileExt'

                  Query.png

                  2. Add the virtual column to the list layout and hide it.

                  3. For the list dynamic image, reference the 'FileExt' field directly in the client-side conditional image code.

                  Conditional Image.png

                  Result:

                  Result.png


                  Thanks Gregg & Jeff for your ideas and your help. Wouldn't have got it without your help!
                  Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                  Comment


                    #24
                    Re: Client Side Conditional Format Syntax To Obtain File Extension

                    As a quick follow up,

                    I found a SQL Query method on Stack Overflow that handles filenames with multiple '.' ie) my.filename.pdf ==> returns pdf
                    I've tested this and it works great for MS-SQL.

                    Code:
                    (CASE WHEN Notes like '%.%'
                             THEN REVERSE(left(REVERSE(Notes), CHARINDEX('.', REVERSE(Notes))- 1))
                             ELSE ''
                    END) AS FileExt


                    Turn off Portable SQL in Alpha
                    Last edited by iRadiate; 08-21-2019, 09:02 AM. Reason: Correction
                    Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                    Comment


                      #25
                      Re: Client Side Conditional Format Syntax To Obtain File Extension

                      Hi Stephen,

                      That's essentially the code I put in post #12, the biggest difference being the Top 1 I forgot to take
                      out from my test (I didn't want 15 years worth of results).
                      Gregg
                      https://paiza.io is a great site to test and share sql code

                      Comment


                        #26
                        Re: Client Side Conditional Format Syntax To Obtain File Extension

                        Gregg,

                        Yes, it is. Sorry, the thread is getting a bit long and my mind is getting a bit short
                        Alpha Anywhere v12.4.6.5.2 Build 8867-5691 IIS v10.0 on Windows Server 2019 Std in Hyper-V

                        Comment

                        Working...
                        X