cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dregan
Frequent Visitor

Patching to Sharepoint List using Radio On Change Intermittently Failing

I have a PowerApps used to add to and update a Sharepoint list.  The user chooses between two options in the PowerApps. The Radio's Default property is set to a Lookup in the Sharepoint list for the specific Department/Category/Date combination that the screen is intended for.  If no record is found, the radio is blank.  The On Change property is setup to patch the Sharepoint list and either add to or update the record. 

 

This code works about 80% of the time, but sometimes the patch just doesn't work.  If I change the selection a couple times, it will eventually patch, but it doesn't do it consistently on the first try.  I saw this thread on a similar issue Solved: Radio button OnSelect sometimes not working - Power Platform Community (microsoft.com), but it seems like the user retracted the solution (plus it seemed like a lot of extra work).  Could this be a bug with using both the Default and On Select properties?

1 ACCEPTED SOLUTION

Accepted Solutions

I think I might've solved my problem using: Radio button onchange doesn't trigger following a ... - Power Platform Community (microsoft.com)

 

I think since I was using a dynamic Default, the OnChange function wasn't always working.  I changed to using the OnSelect function and it seems to have been working. 

View solution in original post

16 REPLIES 16
WarrenBelz
Super User III
Super User III

Hi @dregan ,

Go to your Advanced Settings and turn on Formula Level Error Management and see if that helps.

 

Please click Accept as solution 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 giving it Thumbs Up.

@WarrenBelz  - Thanks! So that seemed to help immensely, until I change the date.  When I change the date, I reset all of the Radios, but the Patch function doesn't work for most of the radios.  And a lot of them already have a radio selected.  Maybe I need to add something to my code. 

Hi @dregan ,

Intermittent problems are always the most difficult and are generally bugs of some sort (including writing back to some blank values, which required the fix I suggested). You have not supplied any code - if you do this in Text (formatted in a text box if you can) , I will have a look at it.

 

Please click Accept as solution 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 giving it Thumbs Up.

dregan
Frequent Visitor

@WarrenBelz - Sure, thank so much.  Please see attached document.  Note: at the app's "On Start" I set variables for Department1, Department2, etc.

 

 

@dregan ,

I cannot open the document - can you please either convert to PDF or paste the code on the thread. Please confine the code to only what is directly relevant to the issue.

dregan
Frequent Visitor

@WarrenBelz Sorry about that, here's the PDF.

dregan
Frequent Visitor

Or this might be easier:

Sharepoint List Columns:

Title, Status, Department, Category, Date, Comments

 

OnSelect for the Button that Navigates to the Screen:


Navigate('scrDept1_Safe&Sustainable');

Set(SelectedDepartment, Department1);

 


OnVisible for the Screen that Contains the Radio:


Reset(radioDept1Safe);

Reset(textDept1SafeComments);

Set(SelectedDepartment, Department1)

 

OnChange for the Date:


Set(varRedGreenDate,Self.SelectedDate);

 

Default for the Radio:


LookUp(

    'Tier Red Green',

    Department = SelectedDepartment && Date = varRedGreenDate && Category = "Safe & Sustainable",

    Status

)

 

OnChange for the Radio:


If(

    IsBlank(

        LookUp(

            'Tier Red Green',

            Department = SelectedDepartment && Date = varRedGreenDate && Category = "Safe & Sustainable"

        )

    ),

    Patch(

        'Tier Red Green',

        Defaults('Tier Red Green'),

        {

            Status: Self.Selected.Value,

            Date: varRedGreenDate,

            Department: SelectedDepartment,

            Category: "Safe & Sustainable",

            Title: "1"

        }

    ),

    Patch(

        'Tier Red Green',

        LookUp(

            'Tier Red Green',

            Department = SelectedDepartment && Date = varRedGreenDate && Category = "Safe & Sustainable"

        ),

        {Status: Self.Selected.Value}

    )

Hi @dregan ,

Firstly Date is not a good name for a field - it is a Reserved Word in Power Apps, but putting that aside, I would approach this slightly different (but that is just my way of doing things) - this might be worth a try

With(
   {
      wRecord:
      LookUp(
         'Tier Red Green',
         Department = SelectedDepartment && 
         Text(Date,ShortDate) = Text(varRedGreenDate,ShortDate) && 
         Category = "Safe & Sustainable"
      ).ID
   },
   If(
      IsBlank(wRecord),
      Patch(
         'Tier Red Green',
         Defaults('Tier Red Green'),
         {
            Status: Self.Selected.Value,
            Date: varRedGreenDate,
            Department: SelectedDepartment,
            Category: "Safe & Sustainable",
            Title: "1"
         }
      ),
      Patch(
         'Tier Red Green',
         {ID:wRecord},
         {Status: Self.Selected.Value}
      )
   )
)

 

Please click Accept as solution 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 giving it Thumbs Up.

 

This unfortunately didn't seem to make a difference.  On my first select, it doesn't patch.  But if I change my selection, it does seem to work.  Do you know of a way to see patch success/fail?

 

BTW, I also changed the "Date" column name in the Sharepoint list, thanks for the heads up.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (40,518)