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

get value from dialog field into variable

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

    get value from dialog field into variable

    Ok I seem to be stuck once again. I need to get a value from a dialog field into a variable so it can be written to an external table. My code to write to the external table is in an on-click button on the dialog window, in the server-side XB. The code I have writes to the proper table correctly except I need to get the value from a field that is bound to the dialog into a variable to write to the external table.
    I have tried the code: var eventid = "{dialog.object}.getValue('event_id');" but this doesn't seem to work. I tried putting it in the server side events as well under ondialoginitialize with no luck.
    Now the event_id field on the dialog is populated upon opening. Maybe my logic is wrong, or maybe someone can show me how to write that field to the external db.
    Below is my code to write to the external table.

    var eventid = "{dialog.object}.getValue('event_id');"
    dim tbl as p
    tbl = table.open("link_table")
    tbl.enter_begin()
    tbl.Person_Id = session.userid
    tbl.Event_Id = eventid
    tbl.enter_end(.t.)
    tbl.close()

    My dialog is linked to my events table, with the Event_Id field, and other fields in the dialog. I am taking the Event_Id and the logged on user and writing to the link_table. The userid is getting written correctly, and the event id is not getting the correct event_id, it is just writing 0 to the table instead of the correct id # no matter what event is selected. The event_id shows correctly on the dialog.

    Thanks for the help.

    #2
    Re: get value from dialog field into variable

    Hi Greg,

    It seems that you are using a javascript function on the serverside, so I'm not sure that will work for you.
    If you are on the server side, and want to manually update you table you could use an ajax callback and define a function for this.
    You could also submit the code and then you would end up in the server side event "afterDialogValidate", there you can place your code also.
    This event also has a lot of comments on how to get values from fields in the dialog, all the fields or controls are in the variable called "e.dataSubmitted".

    So your code could look something like this.
    Code:
    dim eventid as N = e.dataSubmitted.event_id  'Assuming that your event_id is a numeric value, if not maybe charactor then dim as C 
    dim tbl as p
    tbl = table.open("link_table")
    tbl.enter_begin()
    tbl.Person_Id = session.userid
    tbl.Event_Id = eventid
    tbl.enter_end(.t.)
    tbl.close()
    Hope this helps you, if not let me know.
    Kind regards
    David H-S

    Using: Alpha Anywhere V12

    Comment


      #3
      Re: get value from dialog field into variable

      My dialog is linked to my events table, with the Event_Id field, and other fields in the dialog
      something is not clear, may be I could be wrong.
      you have a dialog and it is connected to a table, correct? if yes why you need to write a code to insert/update that table? the dialog will do that for you with serverside event.
      where is the event_id coming from? is that a field from another area passed onto this dialog? if that is correct that field needs to dirtied in order to be saved.
      My code to write to the external table is in an on-click button on the dialog window
      this will be your submit button, right?
      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


        #4
        Re: get value from dialog field into variable

        The Dialog is linked to the "events" table and I need to write to a different table, "link_table". The Dialog is a information only(read only), but the event_id is coming from the record displayed in the dialog. This was easy to do these type of things in the desktop side, but this web interface is a bit more tricky.
        Here is a jist of what happens in the db....simplified version of what goes on.

        Person logs in and is presented with a list of events.
        Person selects a event and is presented with information about the event (read only).
        If person wants to sign up for event they click a button and a new record is created in the "link_table" with the information to bind the event to the person. Record created has event_id, and person_id and link_id.
        If person is not interested in the event, no record is created and the person is either directed back to the list of events or can log off.

        I hope that this explains a little better.

        As I mentioned in another post, the desktop version works perfectly and I am trying to build a web interface to do similar function (if possible).

        Comment


          #5
          Re: get value from dialog field into variable

          Hi Greg,
          So your dialog needs to have a 'SIGN-UP' button on it, and you need to set your onClick event to a callback. Your callback will write the record to the link table.
          You need to make sure that the data you need is being passed to the callback function, or is accessible otherwise.
          You will not need to use a SUBMIT button.
          If you're still stuck, specify how and where.
          Regards,
          Andy.

          Comment


            #6
            Re: get value from dialog field into variable

            I understand the part of having the callback but if I understand correctly that would write the record to the bound table. This is an external table that the record is being created in. I may just do something different and look into reading the specified record into java script variables or something. There has got to be a way to accomplish what I need it to do, I just haven't found it yet.

            Greg

            Comment


              #7
              Re: get value from dialog field into variable

              A generic callback is simply a way of triggering the running of a server-side function from the browser. Nothing to do with table bindings or anything. Check the v11 videos as there are callback examples there. You are simply using the click of a button to trigger the ajax call to server (while passing a bunch of record-specific data that may be useful and easily manipulated using xBasic).

              Comment


                #8
                Re: get value from dialog field into variable

                I am still having issues with this. The dialog is populated with the data and i need to access the one field of data to write to another table. The field is the primary key, if that helps. The dialog is a read only fields, they do not get the info changed or written back to the bound table. I just need to get the data from the one primary key field and write that data to a table with the other information that was collected.
                Every example I have seen of trying to get the value of that field has failed. The dialog is populated from a grid, and I am unable to figure out the field that passes that corresponding record to the dialog window.

                Comment


                  #9
                  Re: get value from dialog field into variable

                  Hi Greg,
                  I think the following should work,
                  On OnDialogValidate event do the following
                  1) use e._currentRowDataNew.<fieldname> to get dialog field value.
                  2) write xbasic sql insert command to insert into link_table table.

                  Kind Regards

                  Comment


                    #10
                    Re: get value from dialog field into variable

                    Greg, have a look at video D39
                    http://news.alphasoftware.com/v11preview/videos_v11.htm

                    Similar to what Mohammed mentioned above, you can place your DB code in afterDialogValidate as well if you like.
                    Instead of a Submit button, you might have a ADD LINK button or whatever.

                    Or just use a standard ajax callback in the onclick event (similar to video D21).

                    As you can see, there are many ways to achieve what you wish.

                    Comment


                      #11
                      Re: get value from dialog field into variable

                      Ok that e._currentRowDataNew.<fieldname> worked. Altho I did not use it as described. Here is the way I got it to work.
                      Not sure if all this is required in the action but it is working and i'm not messing with it :)
                      Under the "Register Button"
                      I went into text mode which has this code under the Javascript Function:

                      /* serversidexbasic */
                      {dialog.object}.ajaxCallback('','{Grid.RowNumber}:all','serverside_374b29fae53746b8917c1bf8dd264f67','','_getData=true');
                      {dialog.object}.submit()

                      Then under the xbasic functions I have:

                      dim tbl as p
                      tbl = table.open("link_table")
                      tbl.enter_begin()
                      tbl.Person_Id = session.userid
                      tbl.Event_Id = e._currentRowDataNew.EVENT_ID
                      tbl.enter_end(.t.)
                      tbl.close()

                      I have not checked if changing the fields on the dialog will write back to the original table, that is the next test. They should not be updateable if the person tries to change the info. I will see, and if I have an issue with that, I will be back for more help :)

                      Thanks everyone.

                      Comment

                      Working...
                      X