cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TesDA
Level: Powered On

Error creating new row: This item has already been created on the server

I have a form which writes to SQL Server with various employee information. The ID field/card uses the default: ICWOEntry_Form.LastSubmit.ID in order to maintain the join from the prior screen (this is set to not visible).

 

When you click the "Submit Employee & Add Another" I'm getting the error: This item has already been created on the server

The button uses this with OnSelect: SubmitForm(ICWOResource_Form);Navigate(EditEmp_Screen);NewForm(ICWOResource_Form)

 

Id like pressing the button to complete the below actions, how do I do this?

1) Submits employee data to table in SQL Server

2) Refreshes form to blanks (except the ID Card which will stay the same based on LastSubmit) so that another employee can be added to the table

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support Team
Community Support Team

Re: Error creating new row: This item has already been created on the server

Hi @TesDA ,

Could you please share a bit more about the ID column in your SQL Table? Is it a Primary Key column or Unique type column?

 

If the ID column is a Primary Key column or a Unique type column in your SQL Table, I think the issue you faced is related to it. the Primary Key column or Unique type column could not be populated with repeated values.

 

If the ID column is not Primary Key column or a Unique type column in your SQL Table, I have made a test on my side, and don't have the issue that you mentioned. Please consider take a try with the following workaround:

Set the OnSelect property of the "Submit Employee & Add Another" button to following:

SubmitForm(ICWOResource_Form)

Set the OnSuccess property of the ICWOResource_Form to following:

Set(CurrentSubmitted, ICWOResource_Form.LastSubmit);
Navigate(EditEmp_Screen);
NewForm(ICWOResource_Form)

Set the Default property of the Text Input box within the ID Data card to following:

CurrentSubmitted.ID

Please take a try with above solution, then check if the issue is solved.

 

Note: Please make sure that the ICWOEntry_Form.LastSubmit.ID formula has returned a proper value within your ID data card. On your side, please consider visible the ID data card within your Edit form, check if the ID data card is populated with proper value.

 

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.

View solution in original post

Super User
Super User

Re: Error creating new row: This item has already been created on the server

@TesDA 

So you definitely don't want to change the ID of your second form!  That is the primary key of that record and is automatically created.  Changing that on new records will cause issues.

What you need to change is the value of the field you have to the foreign key.  What is that field?  That is the one you will change the default property on to be the last submit ID...but definitely not the primary ID of that second form.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

6 REPLIES 6
Super User
Super User

Re: Error creating new row: This item has already been created on the server

@TesDA 

Can you share a little more about how you are using the LastSubmit ID?  It seems like you are stating that you are using that ID as the ID for the Resource Form.  If that is the primary ID for the table of the Resource table, then you are definitely going to run into problem.  I believe you want the last submit ID to go into some field in your Resource table that will identify the Employee record in the other table?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Community Support Team
Community Support Team

Re: Error creating new row: This item has already been created on the server

Hi @TesDA ,

Could you please share a bit more about the ID column in your SQL Table? Is it a Primary Key column or Unique type column?

 

If the ID column is a Primary Key column or a Unique type column in your SQL Table, I think the issue you faced is related to it. the Primary Key column or Unique type column could not be populated with repeated values.

 

If the ID column is not Primary Key column or a Unique type column in your SQL Table, I have made a test on my side, and don't have the issue that you mentioned. Please consider take a try with the following workaround:

Set the OnSelect property of the "Submit Employee & Add Another" button to following:

SubmitForm(ICWOResource_Form)

Set the OnSuccess property of the ICWOResource_Form to following:

Set(CurrentSubmitted, ICWOResource_Form.LastSubmit);
Navigate(EditEmp_Screen);
NewForm(ICWOResource_Form)

Set the Default property of the Text Input box within the ID Data card to following:

CurrentSubmitted.ID

Please take a try with above solution, then check if the issue is solved.

 

Note: Please make sure that the ICWOEntry_Form.LastSubmit.ID formula has returned a proper value within your ID data card. On your side, please consider visible the ID data card within your Edit form, check if the ID data card is populated with proper value.

 

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.

View solution in original post

TesDA
Level: Powered On

Re: Error creating new row: This item has already been created on the server

The ID column is a foreign key to the other screen/ table, I've laid this out a bit better below.  I'll try @v-xida-msft 's method and let you know.

 

I have two screens:

 

Screen 1 - Writes to SQL Table General_Requests, primary key ID (auto increment)

EditEmp_Screen - Writes to SQL Table Employee_Requests, primary key ID_Emp (also has Foreign Key ID to join back to General_Requests)

The requester fills out screen 1 about the request and then EditEmp_Screen, to specifiy which employees they would like on their project.

When the requester moves from screen 1 to EditEmp_Screen - EditEmp_Screen should write the ID from screen 1 into the Employee_Requests table.

TesDA
Level: Powered On

Re: Error creating new row: This item has already been created on the server

I'm getting an error with ID, "An entry is required or has an invalid value. Please correct and try again." This is what should happen:

 

Screen 1 - User fills out general information about their request which writes to the General_Requests table (Primary Key ID), then presses button to add employees to the request to move to the EditEmp_Screen

 

EditEmp_Screen - User adds all of the employees they would like to add to their request. Each employee they add should include the foreign key ID, so that the employee requests can be tied to the general information about the request on Screen 1. ICWOEntry_Form.LastSubmit.ID

I tried switching the default on ID back to ICWOEntry_Form.LastSubmit.ID and it errored out again when I tried to add the second employee

Super User
Super User

Re: Error creating new row: This item has already been created on the server

@TesDA 

So you definitely don't want to change the ID of your second form!  That is the primary key of that record and is automatically created.  Changing that on new records will cause issues.

What you need to change is the value of the field you have to the foreign key.  What is that field?  That is the one you will change the default property on to be the last submit ID...but definitely not the primary ID of that second form.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

TesDA
Level: Powered On

Re: Error creating new row: This item has already been created on the server

Yup, I took a look and I set the primary key up wrong as you can see below. I just deleted the table and corrected/ recreated it. Thanks again!

 

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PS_ICWO_Resource](
	[ICWO_Form_Number] [int] IDENTITY(1,1) NOT NULL,
	[ID] [int] NOT NULL,
	[Resource_USID] [nvarchar](50) NULL,
	[Resource_Name] [nvarchar](100) NULL,
	[Resource_LOB] [nchar](10) NULL,
	[Resource_Dept] [nvarchar](100) NULL,
	[Resource_Hours] [float] NULL,
	[Resource_Rate] [float] NULL,
	[Resource_Start_Date] [smalldatetime] NULL,
	[Resource_End_Date] [smalldatetime] NULL,
 CONSTRAINT [PK_PS_ICWO_Resource] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,987)