Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Power App Patch with Success or Error message

Hi

I have created a PowerApp write back that works well, but now i am trying to make it better with error or success messages. I am not a coder, i cut paste and try different actions.

 

I have a function that allows selection to recognize if an item exists on the Sharepoint table to use an "update form" or if no record exist use a "create Form"

 

If(IsBlankOrError(LookUp('ACTION_&_COMMENT_LIST2',ThisItem.'ID.1'="")), Navigate(IssueUpdateForm ),Navigate(CreateRecordForm))

  

I use a standard Update Form if a record exist on my sharpoint Table, with Success Message, this works fine

 

I created a form to address "if no record exist on sharepoint", so it creates a new record

The "Invoice _No" which is the "Unique key" will create an error if it already exists, this happens if you press Create Record button multiple times or go to update the same record before a scheduled refresh occurs (Hourly).

Because i have the unique key activated in sharepoint an error occurs that doesnt show on the Dashboard, i would like to create a success or error messgae for this function.

 

Base code that works is .

 

Patch('ACTION_&_COMMENT_LIST2',Defaults('ACTION_&_COMMENT_LIST2'),{Invoice_Number:TextCanvas2_6.Text,COMMENT:CommentTXT.Value,FILTER:FilterTXT.Value,ACTION:ActionCombo.SelectedItems}),

Navigate(('Comment List Dispaly')

 

Code that has an error

 

Set(varRecord,Patch('ACTION_&_COMMENT_LIST2',Defaults('ACTION_&_COMMENT_LIST2'),{Invoice_Number:TextCanvas2_6.Text,COMMENT:CommentTXT.Value,FILTER:FilterTXT.Value,ACTION:ActionCombo.SelectedItems});If(IsError(varRecord),Notify("Your request has been submitted!",NotificationType.Success),Notify("Your request was not submitted",NotificationType.Error),Navigate(('Comment List Dispaly')
 
I think i have a comment or argument in the wrong order

 

Status: Investigating
Comments
Anonymous
Not applicable

Hi,@Carl143 .I am glad to help you.
According to your description, when creating a new record in a SharePoint table, if “Invoice_No” already exists, an error is generated due to the unique key limitation, but this error is not displayed on the dashboard.
Perhaps you can use the error function to display a more detailed error message:
You can use the Errors function to get more detailed error information and display it in the notification message. For example:

If(
    IsError(varRecord),
    Notify("Error: " & Errors('ACTION_&_COMMENT_LIST2').Message, NotificationType.Error),
    Notify("Your request has been submitted!", NotificationType.Success)
);


It might be a good idea to modify the display logic to avoid this problem:
When the “Create Record” button is clicked, disable it until the operation is complete. This might prevent the user from clicking the button multiple times and causing duplicate submissions.

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian

Carl143
Frequent Visitor

Hi Carson

 

Thanks this seems close

I added the code to the "On Select", however i get a error

 

Set(varRecord,Patch(
    'ACTION_&_COMMENT_LIST2',
    Defaults('ACTION_&_COMMENT_LIST2'),
    {
        Invoice_Number: TextCanvas2_6.Text,
        COMMENT: CommentTXT.Value,
        FILTER: FilterTXT.Value,
        ACTION: ActionCombo.SelectedItems
    }
);
If(
    IsError(varRecord),
    Notify("Error: " & Errors('ACTION_&_COMMENT_LIST2').Message, NotificationType.Error),
    Notify("Your request has been submitted!", NotificationType.Success)
))
 
Message reads "Invalid argument type. Expecting one of the following: Text, Number, Decimal, Date, Time, DateTimeNoTimeZone, DateTime, Boolean, ViewValue, UntypedObject." It does not recognize the word .Message
 
Also i could not work out how to trigger DisableMode till error handling was complete