locked
How to create a temporary collection property to hold many-to-many related items until all form data entered. RRS feed

  • Question

  • I have been fighting this all day and cant seem to find a solution.

    For sake of argument please imagine a issue logging screen. Where each issue may affect 0 or more services.

    I have a mapping table with columns: id, issueId, serviceId.

    I have a screen for adding an issue.  This has various required properties.

    on this screen I have a popup which allows the selection of multiple services.  This popup uses check boxes to allow for multi-selection of all affected services: I achieved this by following:

    The problem I have is that I need a place to store the selected services (displaying a list of their names on the main Add Issue screen)  so that the user can verify their selection and continue adding the additional required properties to the Issue being logged.

    Then when saving the data I would want to save the Issue data, then create the entries in the mapping table that relates the new issue to the affected services.

    So in the before apply changes method of the add issue screen I would want to iterated over the selected services and do the following:

    for (var i = 0; i < selectedServices.count
    ; i++){
    var mapping = myapp.activeDataWorkspace.ApplicationData.IssueRelatedAffectedServicesMapping.addNew();
        mapping.setIssue(screen.Issue);
        mapping.setSelectedService(selectedServices[i]);
    }
    
    myapp.commitChanges();

    How can I create a temporary store for the affected services?



    ltheONEl

    Friday, June 5, 2015 5:23 PM

Answers

  • How can I create a temporary store for the affected services?

    what do you want to use this temporary store for the affected services? Don't use commitChanges() method before you save it.
    • Proposed as answer by Xpert360 Monday, June 8, 2015 1:37 PM
    • Marked as answer by Angie Xu Monday, June 22, 2015 9:09 AM
    Monday, June 8, 2015 1:13 PM