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

How to determine if a dialog is for a new or update record action...

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

    How to determine if a dialog is for a new or update record action...

    I use the same dialog to both create a new record and update an existing record. I would like the ability to do some pre-processing when I open the dialog for existing records. I am trying to find a way to determine how the dialog is being used (new/update) when it opens.

    I noticed this in the latest pre-release:
    "Dialog Component - Action Javascript - Open a Dialog to Edit Current Record in Grid Action - When you use this action and the mode is set to 'EditExistingRecord' the Dialog component will now populate a dot variable called 'e.rtc._data' that can be used in the Dialog's 'onDialogInitialize' event to get access to the data that is being loaded into the Dialog Component. "

    Gave me the idea that there is some kind of dot variable like 'e.rtc._data' for me to find out if it is a new or existing record. Does anybody have any hints or idea's on how to find the purpose of the dialog once it is opened?

    #2
    Re: How to determine if a dialog is for a new or update record action...

    I'm doing it by passing in an argument value. If it's a new record, it's 0, it it's an existing record, it greater than 0.

    So, in the grid, for the button that opens the dialog to enter a new record, set the argument value to 0. And for the button that opens for editing, set the argument value to the primary key in the grid.

    Then, in the dialog, in properties, set the argument to "Set value at run-time".

    And finally, in the onDialogInitialize event, put in this code,

    Code:
    dim vRecID as n = e.rtc.args[1].data
    if (vRecID > 0) then
    'existing record,
    ... do your pre-processing ...
    end if
    Hope this helps.
    - Dan Hooley
    - Custom Desktop or Web database development -

    Comment


      #3
      Re: How to determine if a dialog is for a new or update record action...

      if you look at the javascript that is returned to the browser when you populate a dialog with existing data you will see code like this:

      Code:
      var _o = DLG1_DlgObj.stateInfo;
       _o.keys = {};
       var _d = {};
       
      _d['CUSTOMER_ID'] = '5';
       _d['FIRSTNAME'] = 'Evan';
       _d['LASTNAME'] = 'Feldstein';
       _d['COMPANY'] = 'Abrams and Sons';
       _d['BILL_ADDRESS_1'] = '327 Joseph Chadderdon Rd';
       _d['BILL_CITY'] = 'Acra';
       _d['BILL_STATE_REGION'] = 'NY';
       _d['BILL_POSTAL_CODE'] = '12405';
       _d['BILL_COUNTRY'] = 'USA';
       
      _o.keys.CUSTOMER = {};
       _o.keys.CUSTOMER._key = ['5'];
       
      
      DLG1_DlgObj.populate(_d);
       DLG1_DlgObj.prepare();
      the portion of interest here is:

      Code:
      var _o = DLG1_DlgObj.stateInfo;
       _o.keys = {};
      _o.keys.CUSTOMER = {};
       _o.keys.CUSTOMER._key = ['5'];
      this portion stores the primary key of the records in all of the bound tables inside a javascript object in the dialog object.

      when the dialog is submitted, if this primary key info is submitted, we know that you are doing an update.

      on the other hand, if there is no primary key information, then we know you are doing an insert.

      so, you could look inside the dialog object to see if there is a primary key.

      Comment


        #4
        Re: How to determine if a dialog is for a new or update record action...

        Originally posted by danh View Post
        I'm doing it by passing in an argument value. If it's a new record, it's 0, it it's an existing record, it greater than 0.

        So, in the grid, for the button that opens the dialog to enter a new record, set the argument value to 0. And for the button that opens for editing, set the argument value to the primary key in the grid.
        Follow up question. I am using the Action Javascript command "Open a Dialog component to Edit Current Record in Grid, or add a new Record". Are you setting the argument value in that genie or are you doing it in "Text Mode" or "Server-side Xbasic"? I have looked at the genie in the Action Javascript but can't locate where you would set arguments....

        Comment


          #5
          Re: How to determine if a dialog is for a new or update record action...

          It's in the genie, in Target Dialog Definition there is an option called "Argument bindings". I believe you need to name the argument in the dialog first, and then it will show up here for you to give it a value.
          - Dan Hooley
          - Custom Desktop or Web database development -

          Comment


            #6
            Re: How to determine if a dialog is for a new or update record action...

            Outstanding. That works great. I was able to declare it on the dialog and then use the arguement binding to set it during run time. Very, very handy. Thank you so much for your guidance!

            Comment


              #7
              Re: How to determine if a dialog is for a new or update record action...

              This is a great discussion, helped me understand more about the UX,
              and sorry to revive an old topic but I thought I'd post a variation on this theme
              (new record or update existing in a UX)

              My scenario is:

              Parent UX has primary key named JobID

              Have a List on the parent UX that looks like "tabs" that triggers navigation to panelcards in the body of the page
              (I used the MenuList Genie that builds a List with those funky font-awesome icons)
              and each Panel Card has an embedded UX

              Child UX is embedded in a panel card, with argument binding on the JobID
              the embedded object has properties
              show mode = when page is loaded (and delay render til visible = true)

              So when the appropriate "tab" in the menu list is clicked,
              and the child UX is shown, I wanted to either
              - show the existing record related to the parent
              - if there was no record yet, create and insert a few (conditional) default data fields from other tables into the child record, based items related to the parent JobID

              So in the Child UX, in the onDialogInitialize I simply added a call to run a stored procedure which attempts to insert a related record based on the JobID key

              On the SQL Server side I defined the primary key of the child table with attribute
              IGNORE_DUP_KEY = ON
              (which means if a record already exists, the stored procedure insert will quietly do nothing)

              So essentially, the stored procedure creates the default child record, if none existed previously.

              The embedded UX then populates using either the pre-existing record or newly created record.
              Code:
              function onDialogInitialize as v (e as p)
              
              'get the JobID passed in by the parent UX
              dim varID as n = e.rtc.args[1].data
              
              dim cn as sql::connection
              cn.Open("::name::TEST")
              dim strSP as c
              strSP = "spWebInsertIntoTblJobWeb " + convert_type(varID,"C")
              cn.Execute(strSP)
              
              'this action requires varID above to populate the UX on the key
              ExecuteServerSideAction("Populate Dialog from Tables::Populate_a_Dialog_with_data_from_one_or_more_tables")
              
              end function
              And you guys above were doing this way back in 2011... the early vanguard of alpha web apps!

              Comment

              Working...
              X