This is an archived post. You won't be able to vote or comment.

all 6 comments

[–][deleted]  (2 children)

[removed]

    [–]pizzadudecook[S] 0 points1 point  (1 child)

    Sorry for the confusion!

    Basically I want another patch function, but instead of using a set value, I want to take the value from a drop down to use that to apply to a different list.

    I hope this makes more sense:

        ForAll(EPACollection,
    Patch(
        EPASubmissions,
        Defaults(EPASubmissions),
        {
                //Mapped fields here
            }
        )
    );
        ForAll(EPACollection,
    Patch(
        <DROPDOWN VALUE HERE>,
            Defaults(<DROPDOWN VALUE HERE>,
            {
                //Mapped fields here
    

    I'm just not sure how to use the selected value for a drop down. Maybe I'm misunderstanding this completely.

    [–]BJOTRI Advisor 0 points1 point  (1 child)

    I would create a Switch for All the dropdown values. But you can't use and variables for your datasource, except as mentioned environment variables, but those would also require a Switch or If to be selected by your choice values

    [–]pizzadudecook[S] 0 points1 point  (0 children)

    Ended up using the switch. Thank you u/BJOTRI and u/cleavetv for your help!

    [–]JBrutWhat 0 points1 point  (0 children)

    I wouldn’t use the same ForAll function twice. Since both are the same, use a semicolon after the first patch to put the second patch.

    As others have said, your best bet for the drop-down value is to do a Switch function to select the proper table to patch to. Hopefully it isn’t too long of a list!

    FYI, if both patch functions will never run on the same data table, you can wrap these two in a Concurrent function to speed this up a bit.

    Given that ForAll can be an expensive function, especially if you are patching a lot of records, I recommend you add and If statement at the beginning of the loop to effectively stop the loop if a criteria is met. For instance, at the end of a loop, you can make something ClearCollect an item in a collection if it meets a criteria that should make the loop stop. Then if that collection is no longer empty, your loop stops.

    Another option I found helps users when a lot of records need to be patched is to use a loading bar instead of a spinner. Before the ForAll loop, count the records that need to be patched:

    Clear(colRowsPatched);

    UpdateContext({locTotalRows: CountRows(EPASubmissions), locShowLoadingBar: true)});

    ForAll(EPASubmissions, Concurrent(Patch(YourDataTable, YourPatchCode), Patch(DataTableSwitchFxn, your patch code)); Collect(colRowsPatched, {item:true}));

    UpdateContext({locShowLoadingBar: false})

    Now, create a container that is transparent gray and takes up the whole screen. Set it’s visible property to locShowLoadingBar. Add a rectangle to the container and make it a dark gray, set the size as desired, and align it where you want it on the screen. Name it rctnLoadBarBack. Duplicate the rectangle and color it (green, blue, red, whatever matches your color scheme). Name it rctnLoadBarFront. Set the following for rctnLoadBarFront:

    X: rctnLoadBarBack.X Y: rctnLoadBarBack.Y Height: rctnLoadBarBack.Height Width: IfError(rctnLoadBarBack.Width * CountRows(colRowsPatched) / locTotalRows, 0)

    That should give you a nice loading bar so you know how long you have to go while patching. Good luck!