Skip to content

Commit 5c8afd7

Browse files
Fix Issue 1392
1 parent 04f3e60 commit 5c8afd7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/controls/dynamicForm/DynamicForm.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ export class DynamicForm extends React.Component<
287287
} else {
288288
objects[columnInternalName] = null;
289289
}
290-
} else {
290+
}
291+
else {
291292
objects[columnInternalName] = val.newValue;
292293
}
293294
}
@@ -332,10 +333,14 @@ export class DynamicForm extends React.Component<
332333
else if (
333334
contentTypeId === undefined ||
334335
contentTypeId === "" ||
335-
!contentTypeId.startsWith("0x0120")
336+
!contentTypeId.startsWith("0x0120")||
337+
contentTypeId.startsWith("0x01")
336338
) {
337339
// We are adding a new list item
338340
try {
341+
const contentTypeIdField = "ContentTypeId";
342+
//check if item contenttype is passed, then update the object with content type id, else, pass the object
343+
contentTypeId !== undefined && contentTypeId.startsWith("0x01") ? objects[contentTypeIdField] = contentTypeId : objects;
339344
const iar = await sp.web.lists.getById(listId).items.add(objects);
340345
if (onSubmitted) {
341346
onSubmitted(
@@ -351,7 +356,8 @@ export class DynamicForm extends React.Component<
351356
}
352357
console.log("Error", error);
353358
}
354-
} else if (contentTypeId.startsWith("0x0120")) {
359+
}
360+
else if (contentTypeId.startsWith("0x0120")) {
355361
// We are adding a folder or a Document Set
356362
try {
357363
const idField = "ID";

0 commit comments

Comments
 (0)