Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 1392 - New items are always created with the default content type if the list has multiple content types #1626

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/controls/dynamicForm/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ export class DynamicForm extends React.Component<
} else {
objects[columnInternalName] = null;
}
} else {
}
else {
objects[columnInternalName] = val.newValue;
}
}
Expand Down Expand Up @@ -332,10 +333,14 @@ export class DynamicForm extends React.Component<
else if (
contentTypeId === undefined ||
contentTypeId === "" ||
!contentTypeId.startsWith("0x0120")
!contentTypeId.startsWith("0x0120")||
contentTypeId.startsWith("0x01")
) {
// We are adding a new list item
try {
const contentTypeIdField = "ContentTypeId";
//check if item contenttype is passed, then update the object with content type id, else, pass the object
contentTypeId !== undefined && contentTypeId.startsWith("0x01") ? objects[contentTypeIdField] = contentTypeId : objects;
const iar = await sp.web.lists.getById(listId).items.add(objects);
if (onSubmitted) {
onSubmitted(
Expand All @@ -351,7 +356,8 @@ export class DynamicForm extends React.Component<
}
console.log("Error", error);
}
} else if (contentTypeId.startsWith("0x0120")) {
}
else if (contentTypeId.startsWith("0x0120")) {
// We are adding a folder or a Document Set
try {
const idField = "ID";
Expand Down