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

record changes after script runs

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

    record changes after script runs

    i have posted some code below which causes an issue after it has run. i wondered if someone could see an obvious problem.

    user runs this script using an onchange event in a combo box. after the code which changes the advisers name in another table has run, the current record is dropped and the form displays the first record in the database.

    Code:
    'Conditional code follows. Executes only if the condition expression is True.
    IF a5_eval_expression("=Stage=\"Lead\"") THEN 
    'chane case onwer to new adviser if adviser changed and case not written
    DIM form_name as c
    if is_object(topparent.this) then 
    	form_name = topparent.name()+".this"
    else
    	form_name = ""
    end if 
    
    DELETE expression_result
    expression_result =  eval("Adviser",form_name)
    parentform:Case_owner.value = expression_result
    END IF
    
    'Displays a message box (style:'OK Button', image: 'Information symbol', id: 'd_adviser_change').
    DIM SHARED  dadviserchange_result as N
    DIM SHARED  dadviserchange_OK_Button as L 
    dadviserchange_OK_Button = .F.
    
    title_var = "Change Adviser"
    message_text_var = <<%text%
    Changing the Adviser for this case will change all future reviews to the adviser.
    
    The new adviser assumes all responsibility for advice given from this date.
    %text%
    dadviserchange_result=ui_msg_box(title_var,message_text_var,UI_OK+ UI_FIRST_BUTTON_DEFAULT+ UI_INFORMATION_SYMBOL)
    'Test to see which button on the message box was pressed....
    SELECT
    	CASE dadviserchange_result = UI_OK_SELECTED
    		dadviserchange_OK_Button= .t.
    END SELECT
    
    'Conditional code follows. Executes only if the condition expression is True.
    IF a5_eval_expression("=Var->varC_result=\"OK\"") THEN 
    'change adviser in any open reviews for this case
    dim tc as P 
    dim tbl as P
    dim new_adv as c
    
    tc = table.current()
    tbl = table.open("treview")
    new_adv = casefile->adviser
    
    query.filter = "Caseref=" + quote(tc.caseref)
    query.order = ""
    query.options  = ""
    
    qry = tbl.query_create()
    nrecs = qry.records_get()
    
    IF nrecs = 1 then
        tbl.change_begin()
        tbl.R_adviser= new_adv
        tbl.change_end(.T.)
    End if
    
    qry.drop()
    query.filter = ""
    query.order = ""
    query.options  = ""
    
    tbl.close()
    
    END IF
    
    'Conditional code follows. Executes only if the condition expression is True.
    IF a5_eval_expression("=Var->varC_result=\"OK\"") THEN 
    'enter note to confirm adviser changed
    dim tbl as P
    dim v_trns_adv as c
    
    
    
    
    tbl = table.open("tnotes")
    
    tbl.enter_begin(.T.)
    tbl.caseref=casefile->caseref
    tbl.noteaddedby=user_name()
    tbl.notedate=date()
    tbl.notecategory="Change Adviser"
    tbl.noteinfo="Adviser changed to" + " " + casefile->adviser + " " + " who assumes repsonsibility for all advice from this date"
    tbl.Notereason="Adviser Changed"
    tbl.enter_end(.T.)
    
    tbl.close()
    END IF
    
    'Save record in current form at parent level.
    topparent.commit()
    thanks

    richard

    #2
    Re: record changes after script runs

    Richard what does

    "record changes after script runs" mean? Your script changes lots of records. You know what you're talking about, but for the rest of us more details will help <grin>.

    Without knowing more I'd suggest you check the combobox. Is it bound to a live field in the table? If so, when the user selects a different item won't the user be editing the current record? Maybe you need to bind the combo to a variable so the current record won't be changing...

    Comment


      #3
      Re: record changes after script runs

      sorry tom, i tried to be as explicit as possible.

      the combo is bound to a record as it also needs to change. maybe this is my issue changing the current record and then changing a record in a related table.

      the action is - user changes the value in the combo box (values are sale persons), then the following happens

      1. change value of the record to which the combo is bound.
      2. message to user.
      3. if user clicks ok to message box then a record in a related table is changed with the same value selected in the combo box
      4. a record added to another table (notes)
      5. save current record of table with bound combo box.

      hope this helps make it a little clearer

      Comment


        #4
        Re: record changes after script runs

        Thanks, Richard. Where is it misbehaving? What's happening that you don't want?

        If this were me I would not tie all the external table activity to the OnChange event of your combo box. My combo onchange would verify that the user actually wants to change the value in all the related tables, and then it would set a flag variable true. My CanSave event for the form would check to see if that flag variable has been raised. If so, then it would update the related tables. Naturally, the flag variable must lowered (set false) when the form opens, and after the external tables have been updated.

        As things stand now you're updating records in external tables before the current record is saved. And, while the user can still go back and make a different selection using the combo. I think the cart is before the horse, if you see what I mean.

        Still... I don't understand the "mis_behavior" you're getting.

        Comment


          #5
          Re: record changes after script runs

          tom,

          that all makes sense. i did have a couple of other combos with similiar actions which were causing the same problem, i removed those actions and did them a different way, but i still get the issue with this one.

          i will try your method.

          the behaviour is, once the script has stopped running, the form shows the very first record in the table replacing the record which was being worked on.

          thanks for your help.

          Comment


            #6
            Re: record changes after script runs

            the behaviour is, once the script has stopped running, the form shows the very first record in the table replacing the record which was being worked on.
            Very strange that you should wind up with two records with the same information. i.e. duplicates. Is this what you meant to say? Or are you trying to say that the original record, that was just edited. is saved just fine, but the form navigates to the very first record of the table instead of remaining on the record just edited? When a record is "replaced" that means (to me, at least) the old field values have been overwritten with new data. Perhaps you mean something else?

            Comment


              #7
              Re: record changes after script runs

              Or are you trying to say that the original record, that was just edited. is saved just fine, but the form navigates to the very first record of the table instead of remaining on the record just edited?
              this is the behaviour i am seeing.

              Comment


                #8
                Re: record changes after script runs

                Richard,
                Do you have a Form OnFetch event sorting/filtering the form/form browse, or some code somewhere on the form that uses topparent.refresh_layout()?
                Mike W
                __________________________
                "I rebel in at least small things to express to the world that I have not completely surrendered"

                Comment


                  #9
                  Re: record changes after script runs

                  mike,

                  the only action is on activate

                  Code:
                  A5.Window_title= "Mortgage Manager, making mortgages easy..."

                  Comment


                    #10
                    Re: record changes after script runs

                    Don't know. One thing I don't see is the need for a topparent.commit() at the end of the script. I do not see any form event to change the current form into enter/change mode, so I don't see the needed for that command.

                    Later: I take that back, I see it at the top. Maybe switch the topparent.commit() to get the form into view mode as the script runs further and see if that makes a difference.
                    Mike W
                    __________________________
                    "I rebel in at least small things to express to the world that I have not completely surrendered"

                    Comment


                      #11
                      Re: record changes after script runs

                      for now, i have added a
                      Code:
                      topparent.commit()
                      to the script before its changes the related tabkes and it has resolved the issue.

                      whether it is the right thing to do or not im not sure, i will still give toms method a go and see how that works out.

                      thanks for the help.

                      Comment

                      Working...
                      X