3

On Sitecore 9.2.0, I have created a custom field, based on the relevant tutorial (https://doc.sitecore.com/developers/92/sitecore-experience-manager/en/walkthrough--creating-a-custom-rating-element-with-property-editor.html).

When I try to add this field into a form via the Forms UI, I see in the network tab that the relevant API call fails with a status code of 400 (bad request). All OOTB fields work fine. Sitecore logs report absolutely nothing, event viewer reports absolutely nothing.

I am obviously missing something. Any insights on where to look?

5
  • Can you turn on the Sitecore logs to DEBUG and see if it reports any error?
    – Ahmad Zia
    Dec 13, 2019 at 0:53
  • @AhmadZia Tried that. No data related to the action. It seems that for some reason this request doesn't register on IIS. Tried a OOTB field addition. The url structure is exactly the same (obviously, different fieldTypeId and TemplateId), so I am guessing there's something wrong in the processing itself.
    – Yiangos
    Dec 13, 2019 at 13:50
  • for the 400 request , open chrome dev tools and check the response in Preview tab
    – Abhay Dhar
    Dec 16, 2019 at 6:19
  • Which browser do you use? Try Firefox or other one if you are using Chrome Dec 16, 2019 at 9:23
  • 1
    To all that provided insight, I found the root cause by decompiling the relevant DLL, I've answered my own question below.
    – Yiangos
    Dec 18, 2019 at 20:10

2 Answers 2

7

It turns out that for the Form editor to work, all field type templates must have a standard values. By decompiling the DLL that contains the action for the API controller for the SPEAK interface of the form editor, I found that internally it runs a pipeline, and the first processor has an Assert that throws if the template for the field type does not have a (empty) standard values. Adding standard values made the error go away.

A bit more informative error than just 400 Bad Request would have been more helpful, methinks.

1
  • Many thanks. Saved my hours to go through sitecore support!
    – Dash
    Mar 23, 2021 at 9:05
2

For anyone who is coming from Upgrade route

I upgraded Sitecore 8.2 to 9.2 via sitecore upgrade but couldn't use form fields - note that in my case I was able to see the form items both in Forms & Content editor but couldn't edit/save them(400-Bad request error while adding form fields). Following steps fixed it:

  1. While upgrading the _Standard Value of Form template items aren't created properly and essentially the Forms pipeline needs the Standard Values. Got the templates from a fresh sitecore instance to fix it. The location in content tree is sitecore/templates/System/Forms
  2. If you have custom processors interfering HttpRequest pipeline e.g. Custom MarkupProcessor, check them out if they are stopping the Form field rendering

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.