cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kilaj1
Helper III
Helper III

Print screen not showing updates

I have a power app that has a review page that initiates from a gallery. This review page has several Forms and a few repeating tables.  i also have a print function which takes you to another page with the A4 layout and labels displaying data.  back on my review screen I have a edit record option that works fine, the problem is that when i make changes and submit them, the forms update, but the print function still holds the previous records.  the only way to get the updated entries is to go back to the gallery and select the record again.  not the best user experience.

 

 

this is the code on the print button

If(SelectedItem.HM_Account.Value = "Other Receipts",
Navigate('Completed - A/C Group - Choice 1',ScreenTransition.CoverRight, {item: SelectedItem})
,
SelectedItem.HM_Account.Value = "Other Income fun",
Navigate('Completed - A/C Group - Choice 1_1',ScreenTransition.CoverRight, {item: SelectedItem})
,
SelectedItem.HM_Account.Value = "Other Income - acc",
Navigate('Completed - A/C Group - Choice 1_2',ScreenTransition.CoverRight, {item: SelectedItem})
,
SelectedItem.HM_Account.Value = "Regional",
Navigate('Completed - A/C Group - Choice 1_3',ScreenTransition.CoverRight, {item: SelectedItem})
,
SelectedItem.HM_Account.Value = "Donation",
Navigate('Completed - A/C Group - Choice 1_4',ScreenTransition.CoverRight, {item: SelectedItem})
,
Notify("Hello", NotificationType.Success)
)

this is an example of what's on the Print screen

 

$"Currency: {If(item.HM_Currency1 = true, "CAD", "USD")}    Total : {Text(Value(item.HM_Total),"[$-en-US],$#,###.00")}   Type: {item.Source.Value}"

Im trying to figure out how to refresh the records.

1 ACCEPTED SOLUTION

Accepted Solutions

@kilaj1 

Ok, seems you are missing a ')' to close out your Set() function, ie

 

If(
    vEditRecord = true,
    Set(
        CurrentSelectedItem,
        Patch(
            'Master List',
            LookUp(
                'Master List',
                ID = CurrentSelectedItem.ID
            ),
            Home_1.Updates,
            DonForm_1.Updates,
            FEForm_1.Updates,
            PayForm_1.Updates,
            AdForm_1.Updates,
            InformaForm_1.Updates,
            DonForm_1.Updates,
            StewardForm_1.Updates,
            SupportingDocForm_1.Updates,
            AttachmentsForm_1.Updates
        )); // <--- missing ')' is here

 

View solution in original post

12 REPLIES 12
EddieE
Solution Sage
Solution Sage

@kilaj1 

If you are moving between a number of screens after selecting from a gallery the best approach is to use a variable instead of the generic Gallery1.Selected method. This way you can reference and update the variable as things change throughout your app. A simple example process would be:

 

1. User selects gallery item

2. OnSelect of gallery

   Set( vMyRecord, ThisItem); Navigate( screen2 )

3. On screen2 there is a Form

   Form.Item = vMyRecord

4. User updates form details and Submits

5. OnSuccess property of form (Form1)

   Set( vMyRecord, Form1.LastSubmit)

6. vMyRecord holds the update item details

 

By moving around and updating the variable the record will always be accessible to various controls.

kilaj1
Helper III
Helper III

Thanks for the response, I actually had a variable already set like this called CurrentSelectedItem, repurposing that however doesn't seem to work, it does have the records within it, but it doesn't seem to be taking the Form1.lastsubmit.

@kilaj1 

Change Form1 to the name of your Form/s getting submitted. 'Form1' is a generic name.

kilaj1
Helper III
Helper III

yep did that, sorry did put it in my reply, I even updated the Print button to use my variable. One thing to note as well is that the edits are resaved using a patch function. 

@kilaj1 

Ah ok, in that case do this for the Patch function/s instead of using the OnSuccess of your form

 

Set( vMyRecord, Patch( ... add your current patch statement here ... ) )
kilaj1
Helper III
Helper III

that didn't seem to work, if I'm reading this correctly its treating that variable (in my patch button)

If(
    vEditRecord = true,
    Set(
        Item,
        Patch(
            'Master L',
            LookUp(
                'Master L',
                ID = SelectedItem.ID
            ),
            HomeForm_1.Updates,
            DonForm_1.Updates,
            FEForm_1.Updates,
            PayForm_1.Updates,
            AddForm_1.Updates,
            InfoForm_1.Updates,
            DonorIForm_1.Updates,
            StewardForm_1.Updates,
            SupportForm_1.Updates,
            AttachmentsForm_1.Updates
        );
        Set(
            varCurrency2,
            Text(
                RoundUp(
                    Value(Total.Text),
                    2
                ),
                "[$-en-US]$#,###.00"
            )
        );
        Notify(
            "Record Saved",
            NotificationType.Success
        );
    );
    If(
        vEditRecord = false,
        Set(
            vEditRecord,
            true
        ),
        Set(
            vEditRecord,
            false
        )
    )
)

as a Boolean.  I've switch around the variable used and its the same result

 

on the print page this is the code

$"Currency: {If(Item.HM_Currency1 = true, "CAD", "USD")}    Total Revenue: {Text(Value(item.HM_Total),"[$-en-US],$#,###.00")}   Depo Type: {item.ReSource.Value}"

@kilaj1 

Did you adjust the OnSelect code of your Print button to reflect this new variable we created?

kilaj1
Helper III
Helper III

yep I did adjust that, I'm going to try a few things again today...took a few days off from it.

 

Edit:

 

So my "save" button has this code now, which isn't too different from the one above.

 

If(
    vEditRecord = true,
    Set(
        SelectedItem,
        Patch(
            'Master List',
            LookUp(
                'Master List',
                ID = SelectedItem.ID
            ),
            Home_1.Updates,
            DonForm_1.Updates,
            FEForm_1.Updates,
            PayForm_1.Updates,
            AdForm_1.Updates,
            InformaForm_1.Updates,
            DonForm_1.Updates,
            StewardForm_1.Updates,
            SupportingDocForm_1.Updates,
            AttachmentsForm_1.Updates
        );
        Set(
            varCurrency2,
            Text(
                RoundUp(
                    Value(TotalRevenueTxt.Text),
                    2
                ),
                "[$-en-US]$#,###.00"
            )
        );
        Notify(
            "Record Saved",
            NotificationType.Success
        );
    );
    If(
        vEditRecord = false,
        Set(
            vEditRecord,
            true
        ),
        Set(
            vEditRecord,
            false
        )
    )
)

 

the "Set(SelectedItem,***" part is what would presumably hold the updated data, but If I'm understanding this correctly, the updates are within the Patch, before the selecteditem "update".

 

When I check on the selectedItem records (before going to print) its showing the old value.  So that means the selected items isn't even taking the updates.

 

@kilaj1 

You appear to be confusing / mixing up some of the variables in your process. Firstly, you had

Set( Item, Patch (...) ) then 

Set( SelectedItem, Patch(...) )

 

Which is it? Also, I'm pretty sure 'SelectedItem' is a reserved word in PowerApps meaning you cannot use it as a variable name. Variable names must be unique and not be any of the reserved words.

 

What is the variable name you are setting when an item is selected in your gallery?

 

Also, when navigating, you are setting context variable inside of the Navigate() function. These are not needed if you follow my process and will also hold old, non-updated data, so they can be removed.

 

EDIT:

I meant to add, Patch has a return function as well as a 'send' function. Where you say the variable isn't getting the updates that shouldn't be the case because

 

The return value of Patch is the record that you modified or created. <link>

 

I've never tried

Set( vRecord, Patch(...) ) 

with a bunch of Form1.Updates, Form2.Updates ... but it should work.

 

Another way to do this if it still doesn't work after changing the name of your variable (don't use SelectedItem) is this

 

// set to record ID
Set( vRecordID, Patch( ... current patch ...).ID );

// lookup that record
Set( vRecord, Lookup( yourData, ID = vRecordID) );

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,984)