cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hasini
Helper II
Helper II

Display Error message on bulk insertion in powerapps

Hello all,

 

My scenario:

Selected records from the collections are inserted into D365FO Dataentity using Patch function.

Question:

1. When there is an error in my record, i am using notify function to show the error message which doesnot include the "Server response" and "Infolog warnings" .It just return the text "The request operation is invalid".Kindly help me to display the error message as displayed in powerapp studio

2. If there is error in bulk insertion some of the records are inserted in target datasource. can we rollback all the created records

      example: i have selected 5 records for insertion , there is an error in 3rd record, where first 2 records are inserted into the target datasource. how to rollback the inserted records from target datasource.

 

 

Question 1 Reference

a. Error in application while running the app

Error message in app.png

b. Error in power apps studio

When i see the screen in power app studio it gives me the detailed message as below. I need to return the below message. How to achieve this.

 

Error message.png

My Source code:

ForAll(
colSelectedItems,
Patch(
InventoryCountingJournalLines,
Defaults(InventoryCountingJournalLines),
{
JournalNumber: cmbJournalHeader.Selected.Journal,
ItemNumber: ItemId,
WorkerPersonnelNumber: PersonnelNumber,
InventorySiteId: InventSiteId,
WarehouseId:InventLocationId,
CountedQuantity:Counted,
LineNumber:0,
dataAreaId:dataAreaId
}
)
);
If(
IsEmpty(Errors(InventoryCountingJournalLines)),
Notify(
"Success",
NotificationType.Success
);Navigate(HomeScreen),
Notify(
First(Errors(InventoryCountingJournalLines)).Message,
NotificationType.Error
)
)

3 REPLIES 3
v-xida-msft
Community Support
Community Support

Hi @Hasini ,

Do you want to rollback records from your Target data source when you face error during your Patch processing?

 

Firstly, if you want to rollback records from your Target data source when you face error during your Patch processing, I afraid that there is no way to achieve your needs in PowerApps currently.

 

Currently, rollback mechanism is not supported between PowerApps and available data sources. If you would like this feature to be added, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

Based on the error message that you mentioned, it seems to tell that there are some columns in your data source are locked, which is prevented from updating.

Before you writing data back to your data source, please make sure each field in your data source is un-locked. In addition, please also change your formula as below:

ForAll(
       colSelectedItems,
       Patch(
             InventoryCountingJournalLines,
             Defaults(InventoryCountingJournalLines),
             {
                JournalNumber: cmbJournalHeader.Selected.Journal,
                ItemNumber: colSelectedItems[@ItemId],
                WorkerPersonnelNumber: colSelectedItems[@PersonnelNumber],
                InventorySiteId: colSelectedItems[@InventSiteId],
                WarehouseId: colSelectedItems[@InventLocationId],
                CountedQuantity: colSelectedItems[@Counted],
                LineNumber: 0,
                dataAreaId: colSelectedItems[@dataAreaId]
             }
      )
);
If(
    IsEmpty(Errors(InventoryCountingJournalLines)),
    Notify(
           "Success",
           NotificationType.Success
    );Navigate(HomeScreen),
    Notify(
           First(Errors(InventoryCountingJournalLines)).Message,
           NotificationType.Error
    )
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Kris,

 

Thanks for the response.

 

-----------------------------------------------------------------------------------------------------------------------------------------------

From Kris:

Based on the error message that you mentioned, it seems to tell that there are some columns in your data source are locked, which is prevented from updating.

------------------------------------------------------------------------------------------------------------------------------------------

My question is how to display the whole error message as the screen shot below while running the app. I know why am getting this locked error message. I want to display the full message which is displayed in the powerapps studio as below..I can display the first line in the error message instead of full content of the error message,while running the app.

 

The message i want to display

Error message.png

 

The message that i am getting

 

Error message in app.png

Hi @Hasini ,

Do you want to get the Whole Error Message content rather than just the first line one within your app?

 

The Message property under the returned Errors Table is a brief description of the error. This error string can be displayed for the end user. Be aware that this message may be generated by the data source and could be long and contain raw column names that may not have any meaning to the user.

Please check the following article for more details:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-errors#description

 

According to the screenshot that you mentioned, if you want to get the Whole Error Message content rather than just the first line one using First(Errors(InventoryCountingJournalLines)).Message formula, I afraid that there is no way to achieve your needs in PowerApps currently.

 

You could take a try to modify your formula as below:

ForAll(
       colSelectedItems,
       Patch(
             InventoryCountingJournalLines,
             Defaults(InventoryCountingJournalLines),
             {
                JournalNumber: cmbJournalHeader.Selected.Journal,
                ItemNumber: colSelectedItems[@ItemId],
                WorkerPersonnelNumber: colSelectedItems[@PersonnelNumber],
                InventorySiteId: colSelectedItems[@InventSiteId],
                WarehouseId: colSelectedItems[@InventLocationId],
                CountedQuantity: colSelectedItems[@Counted],
                LineNumber: 0,
                dataAreaId: colSelectedItems[@dataAreaId]
             }
      )
);
If(
    IsEmpty(Errors(InventoryCountingJournalLines)),
    Notify(
           "Success",
           NotificationType.Success
    );Navigate(HomeScreen),
    Notify(
           Concat(Errors(InventoryCountingJournalLines), Message & " "),   // Modify here
           NotificationType.Error
    )
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

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

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (93,014)