locked
Copying records from one query to another query in the same entity results in the new record showing up in both queries RRS feed

  • Question

  • I am trying to copy records from the same entity.  I am pulling up records in one query, then clicking a button to copy the highlighted record to the 2nd query (on the same entity).  When I do the secondquery.addNew(), the new record shows up in both queries.

    Once I save the record and refresh the queries, the new record shows up in the proper query and disappears from the new one.  There's only one record being created, but it's showing up in both queries.  I'm assuming that's because the queries are bound to the base object and when creating a new object, it just shows up in any widget bound to that base object.

    I'm using the listbox object, and even clicking the little + on either query produces a new record in both query boxes.  I'll attach a screenshot so you can see.

    I think the best option is to simply save the record everytime I copy one over, then refresh both queries.  It's a little more time consuming, but won't confuse the user that way.


    Thursday, October 17, 2013 3:06 AM

All replies

  • Hi,

    Could you explain more about your scenario? what are you trying to accomplish here? maybe there is a better way other than copying the records from one query to the other? If not, then we can talk more about how to solve the problem you're facing.

    Monday, October 21, 2013 3:48 PM
  • Basically, I'm prompting the user to COPY existing Class sections into a new Session.  The classes don't really change, but they may move some into a new session (i.e. Fall 2013 session and Spring 2014 session).  That way they don't need to recreate the classes from scratch, but can change some of the info in them, like classroom, teacher, start and end time, etc if they need to.

    So I am literally copying records from one query into another.  The first query is the existing classes in a session and the 2nd one are new classes in the next session.

    I'm working around it by doing a save each time they copy over, then refreshing the queries.  It takes a little longer, but seems to work.

    I can't really use a many-to-many holding table between the sections and sessions because so many things may change in a class from session to session, so I need all the data in each classes section for each session as some of it may change.

    Monday, October 21, 2013 4:00 PM
  • Instead of copying the data to another query. Have you tried to first insert the data to the DB and then show it in the UI? why don't you try to:

    - when the user clicks copy, in the code: creates a new dataWorkspace and use it to insert a new record. I believe this will not affect the existing query which has the original data.

    - after inserting, refresh the query to grab one single record (the new created one).

    I did not try this so you may need extra steps to make it work.

    • Proposed as answer by Angie Xu Thursday, October 24, 2013 2:17 AM
    • Marked as answer by Angie Xu Thursday, October 24, 2013 2:20 AM
    • Unmarked as answer by EricAKrueger Thursday, October 24, 2013 3:10 AM
    Monday, October 21, 2013 6:19 PM