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

Submitting new (customized) form displays data from another record

I am customizing a SharePoint list's form (my first time doing this).  The following occurs when creating new data but not when editing existing data:  

1. User selects 'New' option from SharePoint list

2. Types new data into form

3. Selects SharePoint's 'Save' button

4. The typed data is replaced by data from last row of list

5. Success screen displays; A label contains value from last row: AssocNameValue.Selected.DisplayName

6. Data that user typed is saved as new row in list

So the correct data is saved but steps 4 & 5 give the impression to user that something is wrong.

I have added a Submit button which is what I intend for user's to select instead of Save.  When selecting Submit, the same behavior is seen except on 4th/5th step above, the data from *first* row of list is displayed.

 

- In attempt to fix problem, I have changed the form's Item formula to (suggested in another post for different problem): First(Filter('Track Associate Testing', ID = SharePointIntegration.SelectedListItemID))

- vMode variable is set in App's OnStart (used in OnSuccess): Set(vMode,SharePointForm1.Mode);

- Submit button's OnSelect: Set(vSelectedButton,"Submit");SubmitForm(SharePointForm1);

- Form's OnSuccess (have excluded ELSE portions of IF statement because they are executed only when editing existing row):

Set(
vSPLink,
SharePointForm1.LastSubmit.'Link to item'
);
//If new form, submit to HR group else if Submit selected, send to the HR Rep/Bus. Partner who is working form
If(
vMode = FormMode.New,
Set(
HREmail,
HRGroup.Text
);Set(
Subj,
"New: "
),
vSelectedButton = "Submit",
Set(
HREmail,
HREmailValue.Text
);Set(
Subj,
"Re-submit: "
)
);
If(
Or(
vMode = FormMode.New,
vSelectedButton = "Submit"
),
Patch(
'Track Associate Testing',
SharePointForm1.LastSubmit,
{
MgrName: User().FullName,
MgrEmail: User().Email,
MgrPhone: First(Office365Users.UserProfileV2(User().Email).businessPhones).Value,
Status: {Value: "Approver"}
}
);
Office365Outlook.SendEmailV2(
HREmail,
Subj &"Covid-19 Associate Testing form for " & SharePointForm1.LastSubmit.Associate.DisplayName & ", " & SharePointForm1.LastSubmit.Location,
"You may view the form by selecting the following link: " & vSPLink,
{Importance: "High"}
);
Navigate(
SuccessScreen,
ScreenTransition.None
);
,//END NEW/SUBMIT
...
)

1 ACCEPTED SOLUTION

Accepted Solutions
kcarver
Frequent Visitor

If the HideRequest() is removed from a default (no changes) customized form's OnSuccess event and you select New from the list then Save, the same behavior is seen.  In my situation, a new row will not be created from the list (only from a link supplied on intranet) so HideRequest can't be used.  (Maybe I should have created a real Power App instead of customizing form - newbie mistake) However, I've found a solution that satisfies me.  In the Submit button's OnSelect, check for valid form then navigate to success screen BEFORE SubmitForm.  The form still submits and code in form's OnSuccess executes.  Following is code in Submit button's OnSelect:

If(
SharePointForm1.Valid,
Navigate(
SuccessScreen,
ScreenTransition.None
)
);
SubmitForm(SharePointForm1);

View solution in original post

1 REPLY 1
kcarver
Frequent Visitor

If the HideRequest() is removed from a default (no changes) customized form's OnSuccess event and you select New from the list then Save, the same behavior is seen.  In my situation, a new row will not be created from the list (only from a link supplied on intranet) so HideRequest can't be used.  (Maybe I should have created a real Power App instead of customizing form - newbie mistake) However, I've found a solution that satisfies me.  In the Submit button's OnSelect, check for valid form then navigate to success screen BEFORE SubmitForm.  The form still submits and code in form's OnSuccess executes.  Following is code in Submit button's OnSelect:

If(
SharePointForm1.Valid,
Navigate(
SuccessScreen,
ScreenTransition.None
)
);
SubmitForm(SharePointForm1);

View solution in original post

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,951)