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

Can I call Xbasic function through javascript ?

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

    Can I call Xbasic function through javascript ?

    Can I call Xbasic function through javascript ?

    I want to retrieve data from database in xbasic when we click on button..And I want to use the retrieved data in javascript immediately..

    #2
    Re: Can I call Xbasic function through javascript ?

    Read all about ajax callbacks & see the videos; that is what you are looking for
    Frank

    Tell me and I'll forget; show me and I may remember; involve me and I'll understand

    Comment


      #3
      Re: Can I call Xbasic function through javascript ?

      This is what worked for me when doing an ajax callback from a Javascript Function. Maybe something about this will help?

      function jsFunctionName() {
      {Grid.object}.ajaxCallback('G','{grid.rownumber}','xbFunctionName');
      }
      Carol King
      Developer of Custom Homebuilders' Solutions (CHS)
      http://www.CHSBuilderSoftware.com

      Comment


        #4
        Re: Can I call Xbasic function through javascript ?

        Thank You very much.. I will go through it.

        Comment


          #5
          Re: Can I call Xbasic function through javascript ?

          I am trying to do something similar in a dialog within a repeating section. I tried using
          Code:
          {grid.Object}.ajaxCallback('G',rowNum,'GetPostalCode');
          and also
          Code:
          var rowNum = {Dialog.Object}._selectedRow;
          {dialog.Object}.ajaxCallback('','rowNum','GetPostalCode','','');
          I get errors on both. Is there a different way in dealing with this when working with a repeating section. If I hard code the rownumber I can make the xBasic function call. How do I define the rownumber (placeholder) in for the repeating sectin

          Comment


            #6
            Re: Can I call Xbasic function through javascript ?

            I remembered dealing with calling an Xbasic function on a repeating row dialog so looked in my notes and found the following. My issue had to do with trying to use the OnChange event on an Edit Combo lookup field on a repeating row, so I don't know if this will help you, but maybe there will be some clue in here...

            My Notes:
            The OnChange event is not good to use for a field with an Edit Combo lookup. Instead, use the AfterSelect property in the edit combo genie to call an Xbasic function (if that's what you are doing). Here is an example of calling an Xbasic function using AfterSelect:

            BIG NOTE!!! to use the value captured in the AfterSelect event, will need to use e._currentValue and NOT e.DataSubmitted !!!!!!

            {grid.Object}.ajaxCallback('G','{Grid.RowNumber}:all','AP_VENDOR_CODE_OnChange','','_currentvalue=' + this.value);
            Carol King
            Developer of Custom Homebuilders' Solutions (CHS)
            http://www.CHSBuilderSoftware.com

            Comment


              #7
              Re: Can I call Xbasic function through javascript ?

              omg...Carol, that last bit of advice is something I can use.

              I'm gonna play with afterSelect now.
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


                #8
                Re: Can I call Xbasic function through javascript ?

                Hello, I am new to alpha and so far I like it a lot.
                My issue is that, I have a UX called "payment", where each time I click on the "new record" button, I want to go to my table in SQL and get the max(reference) and add +1 to it and automatically fill the "reference" field in the UX.
                I created scripts, functions which I am sure they are working, however I cannot get the value after I run the function.
                Can anyone help me on this ?

                Comment


                  #9
                  Re: Can I call Xbasic function through javascript ?

                  two things:
                  1> why do you want to do that? the reference field probably has no use for the user, only to the programmer. you can always find it.
                  2> can you post your working script, so that it is possible to just tweak a little to get you where you want to be.
                  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


                    #10
                    Re: Can I call Xbasic function through javascript ?

                    Hello Gandhi, Thank you for your interest in helping.
                    the "reference" field is actually a field that the user would use in order to create payment receipts.
                    what I want to do is to create a function that goes to the table called "payment" and select the max(reference+1) and fill it in the "reference" field every time the user clicks on "new payment" button.
                    Here's the working function, however I can't get the resulting value to my UX.

                    FUNCTION max_ref AS N ( )
                    'Execute a query on a SQL database
                    'DIM a connection variable
                    DIM cn as SQL::Connection
                    dim flagResult as l
                    flagResult = cn.open("::Name::SQL")
                    if flagResult = .f. then
                    ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text)
                    end
                    end if

                    'Specify if you are using Portable SQL syntax, or not
                    cn.PortableSQLEnabled = .t.
                    dim sqlStatement as c
                    sqlStatement = <<%sql%
                    SELECT Max(reference + 1) AS max_ref FROM payment
                    %sql%
                    'Execute the Query
                    flagResult = cn.Execute(sqlStatement)
                    if flagResult = .f. then
                    ui_msg_box("Error",cn.CallResult.text)
                    cn.close()
                    end
                    end if
                    dim rs as sql::resultset
                    rs = cn.ResultSet
                    'Now, dump the contents of the ResultSet to a variable
                    dim max_ref as c
                    max_ref = rs.ToString()

                    'Now, close the connection
                    cn.close()

                    END FUNCTION

                    Comment


                      #11
                      Re: Can I call Xbasic function through javascript ?

                      okay i understand this.
                      if you are using sql and the id, if set to auto increment then, when you save the ux the auto increment will increment by 1, and you can always harvest that data without any problem. the user need not set it.
                      but if you want to do your way, for some reason, then you have the value in max_ref, then in order to set the value in the dialog/ux
                      you use the command
                      on the button onClick event you create an ajaxcallback let's call that xb
                      that xb will have a command
                      e._set.reference.value = max_ref()
                      test it and see if it works.
                      edit:
                      see below:

                      https://www.screencast.com/t/iMlczwaZx
                      Last edited by GGandhi; 04-04-2017, 09:21 AM.
                      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: Can I call Xbasic function through javascript ?

                        i see you wanted to call the function via javascript then
                        var j1 = {Dialog.Object}.ajaxCallback('','','max_ref','','');
                        {dialog.object}.setValue('reference', j1);
                        should work
                        Last edited by GGandhi; 04-04-2017, 11:48 AM.
                        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


                          #13
                          Re: Can I call Xbasic function through javascript ?

                          Hello Gandhi,
                          I tried your piece of code, it didn't work its giving me the error :" 'max_ref' is undefined "
                          Any comments about that?
                          Btw thanks for helping.

                          Comment


                            #14
                            Re: Can I call Xbasic function through javascript ?

                            your xbasic construct is wrong
                            here is a screen cast to show how it needs to be.
                            https://www.screencast.com/t/hIHZPs4wJ

                            Code:
                            FUNCTION max_ref AS c (e as p )
                            'Execute a query on a SQL database
                            'DIM a connection variable
                            DIM cn as SQL::Connection
                            dim flagResult as l 
                            flagResult = cn.open("::Name::SQL")
                            if flagResult = .f. then 
                            ui_msg_box("Error","Could not connect to database. Error reported was: " + crlf() + cn.CallResult.text)
                            end 
                            end if
                            
                            'Specify if you are using Portable SQL syntax, or not
                            cn.PortableSQLEnabled = .t. 
                            dim sqlStatement as c 
                            sqlStatement = <<%sql%
                            SELECT Max(reference + 1) AS max_ref FROM payment
                            %sql%
                            'Execute the Query
                            flagResult = cn.Execute(sqlStatement)
                            if flagResult = .f. then 
                            ui_msg_box("Error",cn.CallResult.text)
                            cn.close()
                            end 
                            end if 
                            dim rs as sql::resultset
                            rs = cn.ResultSet
                            'Now, dump the contents of the ResultSet to a variable
                            dim max_ref as c 
                            max_ref = rs.ToString()
                            
                            'Now, close the connection 
                            cn.close()
                            e._set.reference.value = max_ref
                            END FUNCTION
                            this is corrected code, see if it works.
                            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


                              #15
                              Re: Can I call Xbasic function through javascript ?

                              THANK YOU so much Gandhi, It worked, but now I am facing a different problem which I thought about and I will be glad to share with you.
                              What I want to do was, to get the max(reference) ACCORDING TO THE YEAR, which means I probably must send an argument in my function in order for the argument to be replaced in the where clause of the sql query and get me back the max(reference) according to the year which the user has entered.
                              Can you help?

                              Comment

                              Working...
                              X