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

Add Object/Field name to SQL table - UX

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

    Add Object/Field name to SQL table - UX

    Hi all
    I want to audit any and all changes on a table (staff_info) into another table (staff_audit). I am using a SQL insert statement and that is working well, but rather than have a specific Insert command for every object or field, I want to be able to insert the object name into one of the columns in the audit table. There are five columns in the audit table, user, date/time, object name, old details and new details.
    Is there a way of referencing the objects name where the data is being entered into ?

    Cheers
    Paul

    #2
    Re: Add Object/Field name to SQL table - UX

    Hi Paul,
    Not sure I understand exactly what you mean but some possible methods are
    -the UX server side event dialogValidate has access to the new and also original values. It also has access to the field names amended via user in e.dirtyColumns
    -You might be able to setup an SQL trigger to automatically update staff_audit when records are inserted into staff_info
    Last edited by mumfie; 12-19-2014, 05:15 AM.
    https://appsbydesign.co.uk/

    Comment


      #3
      Re: Add Object/Field name to SQL table - UX

      HI Mumfie
      I want to actually add the the field or objects name that is presently being edited - so if I change the object labelled as staff first name from Mickey Mouse to Donald Duck then I want to add this plus the name of the object that the name was changed in and in this way, I can have one xbasic structure that can be applied to all objects in the UX if that makes sense (I have a habit of not explaining well :(
      Cheers
      Paul

      Comment


        #4
        Re: Add Object/Field name to SQL table - UX

        the changed fields or the control names will be available in e.dirtyColumns, probably as a crlf limited string. you may be able to use it. take a look.
        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: Add Object/Field name to SQL table - UX

          Originally posted by paulyp View Post
          HI Mumfie
          I want to actually add the the field or objects name that is presently being edited - so if I change the object labelled as staff first name from Mickey Mouse to Donald Duck then I want to add this plus the name of the object that the name was changed in and in this way, I can have one xbasic structure that can be applied to all objects in the UX if that makes sense (I have a habit of not explaining well :(
          Cheers
          Paul
          please see http://msgboard.alphasoftware.com/al...=e.dirtyFields

          This should get you started

          Code:
          for each field in e.DirtyColumns
          	oldData = eval("e.OldDataSubmitted." + field)
          	newData = eval("e.dataSubmitted." + field)
          'todo assign SQL args and insert details in table staff_audit
          next
          https://appsbydesign.co.uk/

          Comment


            #6
            Re: Add Object/Field name to SQL table - UX

            I am using same function in all my applications, where I am updating an sql table with the old and the new value and at the same time sending a mail with the changed values to the administartor of the system. the function is liek this:

            FUNCTION InsertChangelog AS C (e AS P, tabname AS C )
            dim cn as sql::connection
            dim args as sql::Arguments
            dim arg1 as sql::arguments
            dim sql as c
            dim fname as c
            dim getdata as c
            dim newdata as c
            dim x1 as c
            dim x2 as c
            dim errortext as c
            dim Username as c
            dim UserID as c
            dim pUser as p
            dim message as p
            dim body as c
            dim filter as c
            dim res_exp as c

            on error resume next
            if eval_valid("session.fullname") = .f.
            Username = "Testuser"
            else
            Username = Session.fullname
            end if
            cn.Open("::Name::ticdb")
            cn.PortableSQLEnabled = .t.
            body = "<h1>Changelog fields " + "</h1><br>"
            body = body + "<table border=" + "3" + "width=" + "800" + ">"
            body = body + "<caption><strong>Task change log fields</strong></caption>"
            body = body + "<tr bgcolor=" + "#CCFFCC" + " border>"
            body = body + "<td>Fieldname</td><td>Changed from</td><td>Changed to</td>"
            body = body + "<tr bgcolor=" + "#CCFFFF" + " border=" + "1" + "></tr>"
            FOR each foo in e.dirtyColumns
            if foo.value <> "CHGBY" .and. foo.value <> "CHGDAT" then
            newval = "e.DataSubmitted." + foo
            prevval = "e.OldDatasubmitted." + foo
            Newvalue = eval(newval)
            Oldvalue = eval(prevval)
            args.add("logtime",convert_type(a5_eval_expression("=Now()",local_variables()),"T"))
            args.add("new_creby",username)
            args.add("new_tabname",tabname)
            args.add("new_fieldname",foo.value)
            args.add("new_oldvalue",Oldvalue)
            args.add("new_newvalue",Newvalue)
            args.add("new_recid",e.DataSubmitted.taskid)
            body = body + "<td>" + foo.value + "</td><td>" + Oldvalue + "</td><td>" + Newvalue + "</td></tr>" + crlf()
            sql = "INSERT into changelog (logtime, Creby, Tabname, Fieldname, oldvalue, newvalue, Recid) values (:logtime, :new_creby, :new_tabname, :new_fieldname, :new_oldvalue, :new_newvalue, :new_recid)"
            cn.execute(sql,args)
            end if
            NEXT
            body = body + "</table>"
            cn.close()
            message.Subject = tabname + " Changed for recid: " + e.DataSubmitted.taskid
            message.to = "[email protected]"
            message.Html_Message = body
            email_send2(message, "",.t.,.t.)
            END FUNCTION

            Comment


              #7
              Re: Add Object/Field name to SQL table - UX

              Hi Guys

              thanks for the reply. I tried what Jim put down and it is EXACTLY what I was looking for, works like a charm. The code I finally used is:

              dim cn as sql::connection
              dim args as sql::Arguments
              dim sql as c
              cn.Open("::Name::CCS")
              cn.PortableSQLEnabled = .t.
              FOR each foo in e.dirtyColumns
              if foo.value <> "CHGBY" .and. foo.value <> "CHGDAT" then
              newval = "e.DataSubmitted." + foo
              prevval = "e.OldDatasubmitted." + foo
              Newvalue = eval(newval)
              Oldvalue = eval(prevval)
              args.add("logtime",convert_type(a5_eval_expression("=Now()",local_variables()),"T"))
              args.add("new_logged_in_user",session.userid)
              args.add("new_fieldname",foo.value)
              args.add("new_oldvalue",Oldvalue)
              args.add("new_newvalue",Newvalue)
              args.add("new_user_edited",e.dataSubmitted.cont_name+ "_" + e.DataSubmitted.cont_contact_first + "_" + e.DataSubmitted.cont_contact_last)
              sql = "INSERT into z_staff_audit (zsa_date_added, zsa_user_name, zsa_column_updated, zsa_old_data, zsa_new_data, zsa_record_edited) values (:logtime, :new_logged_in_user, :new_fieldname, :new_oldvalue, :new_newvalue, :new_user_edited)"
              cn.execute(sql,args)
              end if
              NEXT
              cn.close()

              Cheers
              Paul

              Comment


                #8
                Re: Add Object/Field name to SQL table - UX

                Paul or Jim, where and how did you call the function?
                Could use this myself, but kind of lost on where to put what and calling the function.

                Comment


                  #9
                  Re: Add Object/Field name to SQL table - UX

                  I am using the server-side: AfterDialogValidate for the UX xcomponent Udklip.PNG, and on the grid it is normally the server-side event CanUpdateRecord I am using

                  Comment


                    #10
                    Re: Add Object/Field name to SQL table - UX

                    Well that worked like a charm!! Thank you. I tried to create something like this quite a while back but finally gave up on it before I lost all my marbles.
                    This is great Jim, thank you very much.

                    Comment


                      #11
                      Re: Add Object/Field name to SQL table - UX

                      It saves even new values, so it shows blank on the oldvalue, is there an easy way to only record values which had an old value and not ones that are receiving an initial value?
                      I even got the email, so even that portion is working...so cool!

                      Comment

                      Working...
                      X