Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

Item saved missing after going next screen/previous screen

Like (1) ShareShare
ReportReport
Posted on 6 Oct 2024 15:10:39 by 90
Hello everyone,
 
I’m experiencing an issue in PowerApps where the button used to save a newly added item doesn't seem to work as expected when navigating back to the previous page or the next page. After adding the item, it doesn't appear to be saved or displayed correctly when revisiting the screen.
There are six screens responsible for handling the display of the item:

- `galCAR/OFI` – To display after adding a new item
- `galCAR/OFI_New`
Patch(
    colNCR,
    Defaults(colNCR),
    {      
        Re_x002d_Occurence: DataCardValue12.Selected.Value,
        Remarks:DataCardValue96.Text,
        NCFound: DataCardValue5.Selected.Value,
        Clause: Dropdown1.Selected.Result,
        Sub2: Dropdown3.Selected.Result,
        Sub3: Dropdown2.Selected.Result,
        Nonconformity: DataCardValue23.Text,
        FindingsForNonConformity: DataCardValue59.Text,
        EvidenceForNonConformity: DataCardValue24.Text,
        NCRNo: DataCardValue70.Text
    }
);
Patch(
    colNCRProcess,
    Defaults(colNCRProcess),
    {
        NCFound: DataCardValue5.Selected.Value,
        Clause: Dropdown1.Selected.Result,
        NCRNo: DataCardValue70.Text
    }
);
Set(
    varIncrement,
    varIncrement + 1
);
ResetForm(frmIQA4);
Navigate('galCAR/OFI')

- `galCAR/OFI_addafteraSave`
Patch(
    'Create NC Report',
    Defaults('Create NC Report'),
    {
        Department: DataCardValue50.Selected.Value,
        Clause: Dropdown1_4.Selected.Result,
        MasterID: Gallery1.Selected.ID,
        'Re-Occurence': {Value: DataCardValue12_4.Selected.Value},
        'NC Found': {Value: DataCardValue5_4.Selected.Value},
        'NCR No': DataCardValue70_4.Text,
        'Sub 2': Dropdown3_4.Selected.Result,
        'Sub 3': Dropdown2_4.Selected.Result,
        NonconformityObserved: DataCardValue23_4.Text,
        FindingsForNonConformity: DataCardValue59_4.Text,
        EvidenceForNonConformity: DataCardValue24_4.Text, 
        'Re-OccurenceRemarks': DataCardValue96_2.Text,
            Section: DataCardValue170.Text,
            'QMS No': Concat(
                DataCardValue78.SelectedItems,
                Value & ","
            ),
            Team: DataCardValue76.Text,
            Status: {Value: "Save as Draft"}
            

    }
);


Set(varSpin, true);
'PowerAppsbutton-2'.Run(Gallery1.Selected.ID); Refresh('Create NC Report'); 

- `scrDetailsCAR/OFI1_Eff`
Patch(
    'Create NC Report',
    LookUp(
        'Create NC Report',
        ID = galNCR2.Selected.ID
    ),
    frmIQA4_2.Updates,
    {
        Clause: Dropdown1_2.Selected.Result,
        'Re-Occurence': {Value: DataCardValue12_2.Selected.Value},
        'Re-OccurenceRemarks': DataCardValue96_1,
        'NC Found': {Value: DataCardValue5_2.Selected.Value},
        'NCR No': DataCardValue70_2.Text,
        'Sub 2': Dropdown3_2.Selected.Result,
        'Sub 3': Dropdown2_2.Selected.Result,
        NonconformityObserved: DataCardValue23_2.Text,
        FindingsForNonConformity: DataCardValue59_2.Text,
        EvidenceForNonConformity: DataCardValue24_2.Text
    }
);


Navigate('galCAR/OFI1_EffandAuditee')

- `galCAR/OFI_Edit`
Patch(
    'Create NC Report',
    LookUp('Create NC Report',  MasterID = Gallery1.Selected.ID And 'NCR No' = galNCR.Selected.'NCR No'),

     {Clause:Dropdown1_1.Selected.Result,
     'Re-Occurence': {Value: DataCardValue12_1.Selected.Value},
     'Re-OccurenceRemarks': DataCardValue8.Text,
     'NC Found':{Value: DataCardValue5_1.Selected.Value},
     'NCR No': Replace(LookUp('Create NC Report',  MasterID = Gallery1.Selected.ID And 'NCR No' = galNCR.Selected.'NCR No').'NCR No', 1, 3, DataCardValue5_1.Selected.Value),
     'Sub 2': Dropdown3_1.Selected.Result,
     'Sub 3': Dropdown2_1.Selected.Result,
     NonconformityObserved: DataCardValue23_1.Text,
     FindingsForNonConformity: DataCardValue59_1.Text,
     EvidenceForNonConformity: DataCardValue24_1.Text 
     }
);
Patch(
    'Create NC Report - AM',
    LookUp('Create NC Report - AM',  MasterID = Gallery1.Selected.ID And 'NCR No' = galNCR.Selected.'NCR No'),
    //galNCR.Selected,
     {Clause:Dropdown1_1.Selected.Result,
     NCRFound:{Value: DataCardValue5_1.Selected.Value},
     'NCR No': Replace(LookUp('Create NC Report - AM',  MasterID = Gallery1.Selected.ID And 'NCR No' = galNCR.Selected.'NCR No').'NCR No', 1, 3, DataCardValue5_1.Selected.Value)
     }
);

ResetForm(frmIQA4_1);
Navigate('galCAR/OFI')

- `scrCAR/OFI_EditBfrSubmit`
Patch(
    colNCR,
    LookUp(colNCR, NCRNo = galNCR.Selected.'NCR No'), {
        Re_x002d_Occurence: Dropdown5.Selected.Value,
        Remarks:DataCardValue8_1.Text,
        NCFound: Dropdown6.Selected.Value,
        Clause: Dropdown1_3.Selected.Result,
        Sub2: Dropdown3_3.Selected.Result,
        Sub3: Dropdown2_3.Selected.Result,
        Nonconformity: DataCardValue23_3.Text,
        FindingsForNonConformity: DataCardValue59_3.Text,
        EvidenceForNonConformity: DataCardValue24_3.Text,
        NCRNo: DataCardValue70_3.Text }
);
Patch(
    colNCRProcess,
    LookUp(colNCRProcess, NCRNo = galNCR.Selected.'NCR No'),
    {
        NCFound: Dropdown6.Selected.Value,
        Clause: Dropdown1_3.Selected.Result,
        NCRNo: DataCardValue70_3.Text
    }
);


ResetForm(frmIQA4_1);
Navigate('galCAR/OFI')
 
 
The code for Finding after user added an item is below for all screen but the DataCardValue5 will be changing for each screen
If(DataCardValue5_1.Selected.Value = "CAR", "CAR" & varIncrement & "/22", If(DataCardValue5_1.Selected.Value = "OFI", "OFI" & varIncrement & "/22" ))
But different for scrCAR/OFI_EditBfrSubmit
If(Dropdown6.Selected.Value = "CAR", "CAR" & varIncrement & "/22", If(Dropdown6.Selected.Value = "OFI", "OFI" & varIncrement & "/22" ))
 
I'm wondering if the issue might be related to how the button is connected, possibly to Power Automate. Is it possible that the flow isn't being triggered, or is there a step missing in the process? 
 
Thank you in advance!
 
  • azni Profile Picture
    azni 90 on 07 Oct 2024 at 02:04:33
    Item saved missing after going next screen/previous screen
    Item property use in this case is a SharePoint list 'Create NC Report' after they click the Save button
     
     
    Then, the item saved will be on this gallery and the data will be store in a collection
    If(Entry = "New", colNCR, Filter('Create NC Report', MasterID = Gallery1.Selected.ID))
     
    ColNCRProcess

    colNCR
    - Will appear if I am not navigating to the next page

     
    I am sorry if the information given is incorrect, feel free to ask for me, I am not familiar with Power Apps. Thank you!
     
  • Suggested answer
    FLMike Profile Picture
    FLMike 29,371 on 06 Oct 2024 at 16:49:55
    Item saved missing after going next screen/previous screen
    Hi
     
    What is the data in the Form Item property? Where does it come from? A variable? a gallery? etc.
    It appears to me that you are overwriting the value you are using in the Items property once you move forward, so that it will then not do a lookup properly on it when you go back.
     
    Please share that
    Thanks!
  • mmbr1606 Profile Picture
    mmbr1606 10,071 on 06 Oct 2024 at 15:23:52
    Item saved missing after going next screen/previous screen
    hey
     
    i havent gone thru all the code of your, but nearly every code snippet includes ResetForm() function at the bottom. This will result in a Reset.
     
    Maybe it would be better to only use the Reset function at the very end (or maybe before you navigate to the screens with the forms)?
     
     
    if it helped please mark as verified answer
     
    thanks in advance

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,238

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,290

Leaderboard
Loading complete