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

Recalculating calculated field rules via grid component

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

    Recalculating calculated field rules via grid component

    Hi all and thanks in advance for any comments, (helpful ones, that is).

    I want to replicate this functionality on an aw5 web page, i.e., run a recalc on some tables, either automatically when a new record is posted or manually via a button. The xbasic code runs like so:

    Dim tbl as P

    Tbl = table.open("Installations")
    Tbl.recalc_calcFields()
    Tbl.close()

    and this works fine on a desktop form button, but how to get same from a button on a grid component? Fields on the master table, 'Installations' are posted to via fields from other tables and while this seems to work fine in the desktop app, it doesn't in the web app, such that I have to regularly run the recalc field rules manually. I'd also like to run the update indexes procedure from the web app. I'm using dbf tables, encrypted, so the old maintenance dialog doesn't work either.

    #2
    Re: Recalculating calculated field rules via grid component

    I don't do desktop apps, so I don't know your code, but it sounds like you want to create an xbasic script to do the calculations, then refresh the grid. {grid_Object}.refresh()

    Comment


      #3
      Re: Recalculating calculated field rules via grid component

      This is not a desktop app, it is a web app. I refer to the xbasic code for a desktop app as an example, however I need to run the recalc from the web app - any ideas?

      Thanks

      Comment


        #4
        Re: Recalculating calculated field rules via grid component

        if you want to run this on a button click then
        create an ajaxcallback function call it any name you want ( for example xb), let alpha create the template and copy it paste it.
        then go to the xbasic functions on the left side, add exact same code below the function declaration.
        this assumes the db is in the same computer as the server.
        i don't use native dbf, instead mySql. so this may need verification.
        you can also do it on saving new record, that is for another day.
        thanks for reading

        gandhi

        version 11 3381 - 4096
        mysql backend
        http://www.alphawebprogramming.blogspot.com
        [email protected]
        Skype:[email protected]
        1 914 924 5171

        Comment


          #5
          Re: Recalculating calculated field rules via grid component

          The web apps also use xbasic. There are some differences, but you can add the xbasic to either a button or an event, as needed.

          Comment


            #6
            Re: Recalculating calculated field rules via grid component

            Thank you all, though on second thoughts it would be more efficient to have the recalc run on the saving of a new record. The issue is that the recalc would run on a separate table from the one in which the new record is being created. For example, maintable keeps a note on when next service is due, or next contrat is due; so when a new record is entered in the sercices or contracts table, it posts an increment to the serv#/contract# in the maintable. The calculated field then calculates when the next service or contract is due; this doesn't happen automatically when posting from the web form, but if I could incorporate it into the creation of the new records, that would be a much better solution than asking the users to periodically run the recalc fields routine manually or from a button. So, how to do this bearing in mind I'm posting all new records from the web form?

            Rgds

            Comment


              #7
              Re: Recalculating calculated field rules via grid component

              If you were using sql, you could write a trigger.

              From in the grid, though, look at the server side event "afterinsertrecord".

              This event fires after the user has inserted a record. If the user inserts multiple records at once, this event will be called multiple times - once for each record that was inserted. Contrast with the AfterUpdateRecords event..
              so you can use it to make things happen after you insert a record.

              Comment


                #8
                Re: Recalculating calculated field rules via grid component

                Regarding the suggestions above, in relation to using xbasic, I find that each time i try to design anything on the web forms with xbasic code, it doesn't work. For example I designed a button to carry out the update indexes and recalc field rules functions, and while the development environment allows me to work right through and complete the task, when I then go to test/ run the routine I get the error msg - indicating that the web app doesn't recognise xbasic, only javascript. Just to minimise confusion and throw an example out there, how come this snippet of code works seamlessly in the desktop environment, but not in the web app domain, the code being:

                Dim tbl as P
                Tbl = table.open("customers")
                Tbl.recalc_calcFields()
                Tbl.close()

                I can't find anywhere that explains this or offers alternatives. I'd go further and suggest that all readymade xbasic scripts for manipulating tables and records and maintenance should be available from the action scripting interface in the web app environment - I mean, why not? If they are deemed necessary for the desktop apps then surely its a bit remiss to leave them out of the web app environment?

                Comment


                  #9
                  Re: Recalculating calculated field rules via grid component

                  I don't do dbf files, I only use SQL.

                  However, I believe you have to connect to the files first in a web app which is different from how it works on the desktop. The web app does not know anything about your data - so you have to explicitly tell it where the files in your xbasic function.

                  You should review the help files on how to connect to a dbf file from the web. (Or you can probably find something here on the forum that will help.)

                  Comment


                    #10
                    Re: Recalculating calculated field rules via grid component

                    I'd probably put a hidden field on the client side and put the future date there. Then I'd have a (Next Service Due View) and I'd pull the last one by date for each customer to see when the next service was due.

                    Comment


                      #11
                      Re: Recalculating calculated field rules via grid component

                      Originally posted by jfg View Post
                      Thank you all, though on second thoughts it would be more efficient to have the recalc run on the saving of a new record. The issue is that the recalc would run on a separate table from the one in which the new record is being created. For example, maintable keeps a note on when next service is due, or next contrat is due; so when a new record is entered in the sercices or contracts table, it posts an increment to the serv#/contract# in the maintable. The calculated field then calculates when the next service or contract is due; this doesn't happen automatically when posting from the web form, but if I could incorporate it into the creation of the new records, that would be a much better solution than asking the users to periodically run the recalc fields routine manually or from a button. So, how to do this bearing in mind I'm posting all new records from the web form?

                      Rgds
                      you are always talking about recalculating, better yet do you want to know how to insert the data into related table such as when you enter data into some table you want to insert data into your main table, then your table will automatically insert the calculated result.

                      example:
                      https://www.screencast.com/t/dSeiVXnZac
                      this is not what you are looking for post back with proper description one of will help you.
                      thanks for reading

                      gandhi

                      version 11 3381 - 4096
                      mysql backend
                      http://www.alphawebprogramming.blogspot.com
                      [email protected]
                      Skype:[email protected]
                      1 914 924 5171

                      Comment


                        #12
                        Re: Recalculating calculated field rules via grid component

                        Thank you all, again, for your comments. I've resolved my initial issues by using the field rules - a mix of posting from one table to another, and onsave record events. That said, I feel that this way the coding/ scripting or whatever is all over the place as it is scattered over the various tables and fields involved. But just to clarify an issue I raised above: can any of you suggest a way of using a simple piece of xbasic code in a button on a standard grid component: here is the code, as stated above:

                        Dim tbl as P
                        Tbl = table.open("customers")
                        Tbl.recalc_calcFields()
                        Tbl.close()

                        I can't get that to work in a button on a grid, though if I could rewrite it in javascript, then probably it would be ok. Likewise I have used the 'onsave record event' in field rules to run an action script that updates the indexes, but cannot replicate that within the web app itself. So, two examples of issues that have forced me to use field rules rather than coding, which would be cleaner and more efficient. Any solutions? I'd be interested in your comments.
                        Rgds

                        Comment


                          #13
                          Re: Recalculating calculated field rules via grid component

                          Like Gandhi said you need to put it in an ajaxcallback. However, it will only work after you save the record.

                          Comment


                            #14
                            Re: Recalculating calculated field rules via grid component

                            yeah, I get that and thank you again Gandi for taking the time to go through that. I am new to v12 and was hoping to achieve something like the maintenance dialog on older versions. I wanted to be able to give the user a page with different buttons for different functions, independent of any particular record or table even, so that the user could hit the button and execute the code, for instance:

                            Dim tbl as P
                            Tbl = table.open("customers")
                            Tbl.recalc_calcFields()
                            Tbl.close()

                            I just wanted a simple database level button action for carrying out routine maintenance/ troubleshooting.

                            Rgds

                            Comment


                              #15
                              Re: Recalculating calculated field rules via grid component

                              sure you can do that, it is not that hard.
                              i don't use dbf so i won't know recalc etc., but the concept is the same.
                              create a dialog, put as many buttons as you want and each button will call an ajaxcallback and there you call your xbasic code as you have.
                              thanks for reading

                              gandhi

                              version 11 3381 - 4096
                              mysql backend
                              http://www.alphawebprogramming.blogspot.com
                              [email protected]
                              Skype:[email protected]
                              1 914 924 5171

                              Comment

                              Working...
                              X