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

Notify message displays even when no data is changed in the Edit Form

Hi All,

 

I have an embedded canvas app placed on the CRM Form. 
I am using an Edit Form within the canvas app to display data of the form and have Save button on the form to update the values entered in the canvas app.

 

Formula applied -

onselect property of the Save button -

SubmitForm(Form)

 

onSuccess property of the button -
Notify("Record saved sucessfully",NotificationType.Success)

Issue :
The notify message appears even when nothing is changed on the form and Save button is clicked.


1 ACCEPTED SOLUTION

Accepted Solutions
v-xiaochen-msft
Community Support
Community Support

Hi @Poweruser1101 ,

 

If the Unsaved property does not work properly, you could try another method.

 

  1. Firstly, use a variable to save the value of the record.
  2. Secondly, use another variable to save the value entered in the form control.
  3. Finally, use the button control to compare the two variables. If they are the same, the form is not allowed to be submitted. If they are different, the form is allowed to be submitted.

 

I did a simple test for you. (I embedded a canvas in the model driven)

1\ This is my form . There are two fields in the form that can be modified.( Maybe your form has more fields that can be modified)

v-xiaochen-msft_0-1612922802818.png

 

 

2\ Set the onselect property of the submit Icon control to:

Set(Thevar1,Concatenate(ModelDrivenFormIntegration.Item.Id,ModelDrivenFormIntegration.Item.Name));Set(Thevar2,Concatenate(DataCardValue1.Text,DataCardValue2.Text));If(Thevar1<>Thevar2,SubmitForm(Form1))

 

// ModelDrivenFormIntegration.Item is the Item property of my form control. (Maybe your Item property is another value, such as : Gallery. selected)

DataCardValue1 is the control of Id card.

DataCardValue2 is the control of Name card.

 

3\ Set the OnSuccess property of the Edit form control to:

Notify("Record saved sucessfully",NotificationType.Success)

 

Best Regards,

Wearsky

If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

5 REPLIES 5
Digital
Super User
Super User

This is supposed to happen. Even though no data has changed the form has still submitted and triggered the OnSuccess code.

 

Maybe you could add the current selected form item to a variable. For example in the gallery that navigates to a form Set(varRecord, ThisItem).

 

You could then use LastSubmit in OnSuccess to get the updated record. Set(varSubmitted, Form.LastSubmit). Then it would be a case of comparing the contents of both variables to determine if there has been a change.

 

You could then use this as a condition for whether the banner displays.

@Digital Hey thank you for your reply.

Since i am using embedded canvas app, i can set the varRecord in the onvisible property of the screen

 

Set(varRecord, ModelDrivenFormIntegration.Item)

 

and can also set the OnSuccess property with Set(varSubmitted, Form.LastSubmit)

But where and how do i compare these values 
because the notify message is on "onsuccess" property of the form.

Kindly advice

v-xiaochen-msft
Community Support
Community Support

Hi @Poweruser1101 ,

 

I suggest you use the Unsaved property of the Edit form control.

 

When the user modifies the data in the form, the value of this property is true.

At this time, the user is allowed to submit the form and use the Notify() function on the OnSuccess property.

 

When the user does not modify the data, the value of this property is false.

At this time, users are not allowed to use the SubmitForm() function, and the OnSuccess property will not be triggered.

 

You could try the following steps:

1\ Set the OnSelect property of the submit button control to:

If(Form1.Unsaved= true, SubmitForm(Form1))

 

2\ Set the OnSuccess property of the Edit form control to:

Notify("Record saved sucessfully",NotificationType.Success)

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

@v-xiaochen-msft Hey For me the Form.Unsaved property is always true. I tried displaying in a label.
Not sure why? is it one of my field is getting dirty on load? is there a way i can field which field?
Also can i modify Form.unsaved within canvas apps like setting the value to false once the form is submitted?

v-xiaochen-msft
Community Support
Community Support

Hi @Poweruser1101 ,

 

If the Unsaved property does not work properly, you could try another method.

 

  1. Firstly, use a variable to save the value of the record.
  2. Secondly, use another variable to save the value entered in the form control.
  3. Finally, use the button control to compare the two variables. If they are the same, the form is not allowed to be submitted. If they are different, the form is allowed to be submitted.

 

I did a simple test for you. (I embedded a canvas in the model driven)

1\ This is my form . There are two fields in the form that can be modified.( Maybe your form has more fields that can be modified)

v-xiaochen-msft_0-1612922802818.png

 

 

2\ Set the onselect property of the submit Icon control to:

Set(Thevar1,Concatenate(ModelDrivenFormIntegration.Item.Id,ModelDrivenFormIntegration.Item.Name));Set(Thevar2,Concatenate(DataCardValue1.Text,DataCardValue2.Text));If(Thevar1<>Thevar2,SubmitForm(Form1))

 

// ModelDrivenFormIntegration.Item is the Item property of my form control. (Maybe your Item property is another value, such as : Gallery. selected)

DataCardValue1 is the control of Id card.

DataCardValue2 is the control of Name card.

 

3\ Set the OnSuccess property of the Edit form control to:

Notify("Record saved sucessfully",NotificationType.Success)

 

Best Regards,

Wearsky

If my post helps, then please consider Accept it as the solution to help others. Thanks.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,051)