web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / data is not saving pro...
Power Apps
Suggested Answer

data is not saving properly

(0) ShareShare
ReportReport
Posted on by 24
Button onselect:
If(
    CountRows(
        Filter(
            colRowMonthData,
            UnitType = 0
        )
    ) = 0,
ForAll(
        colRowMonthData As Alpha,
         With(
        { isNumberUnit: Alpha.Unit <> Unit.text,
           isTextUnit: Alpha.Unit = Unit.text,
           tempObjRecord: LookUp(colMyTempObjective, 'Objective ID' = Alpha.'Objective ID'),
           ResultJanText:Alpha.ResultJan.Text,
           YTDJanText:Alpha.YTDJan.Text,
           ResultFebText:Alpha.FebResult.Text,
           YTDFebText:Alpha.FebYTD.Text,
           ResultMarText:Alpha.ResultMar.Text,
           YTDMarText:Alpha.YTDMar.Text,
           ResultAprText:Alpha.ResultApr.Text,
           YTDAprText:Alpha.YTDApr.Text,
           ResultMayText:Alpha.ResultMay.Text,
           YTDMayText:Alpha.YTDMay.Text,
           ResultJuneText:Alpha.ResultJun.Text,
           YTDJunText:Alpha.YTDJun.Text,
           ResultJulyText:Alpha.ResultJul.Text,
           YTDJulText:Alpha.YTDJul.Text,
           ResultAugText:Alpha.ResultAug.Text,
           YTDAugText:Alpha.YTDAug.Text,
           ResultSepText:Alpha.ResultSep.Text,
           YTDSepText:Alpha.YTDSep.Text,
           ResultOctText:Alpha.ResultOct.Text,
           YTDOctText:Alpha.YTDOct.Text,
           ResultNovText:Alpha.ResultNov.Text,
           YTDNovText:Alpha.YTDNov.Text,
           ResultDecText:Alpha.ResultDec.Text,
           YTDDecText:Alpha.YTDDec.Text},
        Patch(
            Objectives,
           LookUp(colMyTempObjective, 'Objective ID' = Alpha.'Objective ID'),
            {
               
            'Result jan': If(
                Alpha.Unit <> Unit.text,
                Value(ResultJan.Text),
                Blank()
            ),
            'Result jan t': If(
                Alpha.Unit = Unit.text,
                ResultJan.Text,
                Blank()
            ),
       
            'YTD jan': If(
                Alpha.Unit <> Unit.text,Value(YTDJan.Text),
                Blank()
            ),
            'YTD jan t': If(
                Alpha.Unit = Unit.text,
               YTDJan.Text,
                Blank()
            ),
            'Comment (itobj_jan_comment)':ComJan.Text,
            Frequency: Alpha.Frequency,
Textinput onchange:
If(
    CountRows(Filter(colRowMonthData, 'Objective ID' = ThisItem.'Objective ID')) = 0,
    // Add new record if it doesn't exist
    Collect(
        colRowMonthData,
        AddColumns(
            Gallery2_4.Selected,
            IsChanged,
            1,
            UnitType,
            If(
                IsNumeric(Self.Text) && Text(ThisItem.Unit) <> "text" ,
                1,
                Text(ThisItem.Unit) = "text",
                1,
                IsBlank(Self.Text),
                1,0
            )
        )
    ),
    // Use Patch to update the record if it exists
    Patch(
        colRowMonthData,
        LookUp(colRowMonthData, 'Objective ID' = ThisItem.'Objective ID'),
        AddColumns(
            Gallery2_4.Selected,
            IsChanged,
            1,
            UnitType,
            If(
                IsNumeric(Self.Text) && Text(ThisItem.Unit) <> "text" ,
                1,
                Text(ThisItem.Unit) = "text",
                1,
                IsBlank(Self.Text),
                1,0
            )
        )
    )
);
Patch(colObjectivesData,
ThisItem,
{
    'Result jan': If(
                ThisItem.Unit <> Unit.text,
                Value(Self.Text),
                Blank()
            ),
            'Result jan t': If(
                ThisItem.Unit = Unit.text,
                Self.Text,
                Blank()
            )
}
);
If(
    ThisItem.Unit = Unit.text,true, IsNumeric(Self.Text) || IsBlank(Self.Text),true,UpdateContext({varwarningPopup:true})
);
Default of textinput:
 
If(IsBlank(LookUp(colRowMonthData, 'Objective ID' = ThisItem.'Objective ID').ResultJan.Text),
If(
    ThisItem.Unit=(Unit.text),
    ThisItem.'Result jan t',
   ThisItem.'Result jan'    ),LookUp(colRowMonthData, 'Objective ID' = ThisItem.'Objective ID').ResultJan.Text)
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    What is not working properly? That is a lot of code to analyse, but the first thing that jumps out for me is this
    Patch(
       Objectives,
       LookUp(
          colMyTempObjective, 
          'Objective ID' = Alpha.'Objective ID'
       ),
    You need to look up the target list to identify the record you want to Patch
    Patch(
       Objectives,
       LookUp(
          Objectives, 
          'Objective ID' = Alpha.'Objective ID'
       ),
     You are also using AddColumns inside a Patch - I am not sure what you are trying to achieve there.
     
     Please âœ… Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like â™¥
    Visit my blog 
    Practical Power Apps    LinkedIn  
  • WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for. Happy to assist further if not.
     
    Please ✅ Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like â™¥
    Visit my blog
    Practical Power Apps    LinkedIn   
  • Suggested answer
    oyepanky Profile Picture
    537 on at

    Hi,

    Your data is not saving properly because:

    • You are storing control references like ResultJan.Text inside the collection.
    • You are using AddColumns() inside Patch() (which returns a table, not a record).
    • Your Default property is again referencing .Text from a collection record.

    Collections must store values only, not controls.

    • Stores only values in collection
    • Supports numeric & text unit
    • Saves correctly to datasource
    • Handles default properly
    TextInput – OnChange
    If(
        IsBlank(
            LookUp(colRowMonthData, 'Objective ID' = ThisItem.'Objective ID')
        ),
    
        Collect(
            colRowMonthData,
            {
                'Objective ID': ThisItem.'Objective ID',
                Unit: ThisItem.Unit,
                ResultJan: Self.Text,
                IsChanged: true
            }
        ),
    
        Patch(
            colRowMonthData,
            LookUp(colRowMonthData, 'Objective ID' = ThisItem.'Objective ID'),
            {
                ResultJan: Self.Text,
                IsChanged: true
            }
        )
    );
    
    If(
        ThisItem.Unit <> Unit.text &&
        !IsNumeric(Self.Text) &&
        !IsBlank(Self.Text),
        UpdateContext({ varwarningPopup: true })
    );

    TextInput – Default Property
    Coalesce(
        LookUp(
            colRowMonthData,
            'Objective ID' = ThisItem.'Objective ID'
        ).ResultJan,
    
        If(
            ThisItem.Unit = Unit.text,
            ThisItem.'Result jan t',
            ThisItem.'Result jan'
        )
    )

    Save Button – Final Patch (ForAll)
    If(
        CountRows(Filter(colRowMonthData, IsChanged = true)) > 0,
    
        ForAll(
            colRowMonthData As Alpha,
    
            Patch(
                Objectives,
                LookUp(Objectives, 'Objective ID' = Alpha.'Objective ID'),
                {
                    'Result jan':
                        If(
                            Alpha.Unit <> Unit.text,
                            Value(Alpha.ResultJan),
                            Blank()
                        ),
    
                    'Result jan t':
                        If(
                            Alpha.Unit = Unit.text,
                            Alpha.ResultJan,
                            Blank()
                        )
                }
            )
        )
    );
     

    Why This Works

    • No .Text stored in collection
    • No AddColumns() misuse
    • No control references
    • Only values stored and patched
    • Clean numeric vs text handling

    24/7 Power Platform Support - Click Here
    Best regards,
    Pankaj Jangid (OyePanky)
    Power Platform Developer
    YouTube: https://www.youtube.com/@oyepanky
    Website: https://www.dialforit.com
     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard