0

I have a custom new form that I've implemented SPServices SPCascade on. The cascade functionality is working beautifully, but now when the form is saved and any required fields are not filled out, it takes the user to a "Something went wrong" page rather than give the OOTB experience of not allowing the save and indicating the required fields. Is there a way to bring the OOTB validation experience while using SPCascade?

The code for the fields:

<tr>
    <td width="190px" valign="top" class="ms-formlabel">
        <H3 class="ms-standardheader">
            <nobr>Directorate</nobr>
        </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
        <SharePoint:FormField runat="server" id="ff16{$Pos}" ControlMode="New" FieldName="Directorate" __designer:bind="{ddwrt:DataBind('i',concat('ff16',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Directorate')}"/>
        <SharePoint:FieldDescription runat="server" id="ff16description{$Pos}" FieldName="Directorate" ControlMode="New"/>
    </td>
</tr>
<tr>
    <td width="190px" valign="top" class="ms-formlabel">
        <H3 class="ms-standardheader">
            <nobr>Division<span class="ms-formvalidation"> *</span>
            </nobr>
        </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
        <SharePoint:FormField runat="server" id="ff17{$Pos}" ControlMode="New" FieldName="Division" __designer:bind="{ddwrt:DataBind('i',concat('ff17',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Division')}"/>
        <SharePoint:FieldDescription runat="server" id="ff17description{$Pos}" FieldName="Division" ControlMode="New"/>
    </td>
</tr>
<tr>
    <td width="190px" valign="top" class="ms-formlabel">
        <H3 class="ms-standardheader">
            <nobr>Branch<span class="ms-formvalidation"> *</span>
            </nobr>
        </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
        <SharePoint:FormField runat="server" id="ff18{$Pos}" ControlMode="New" FieldName="Branch" __designer:bind="{ddwrt:DataBind('i',concat('ff18',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Branch')}"/>
        <SharePoint:FieldDescription runat="server" id="ff18description{$Pos}" FieldName="Branch" ControlMode="New"/>
    </td>
</tr>

And this is the javascript:

<script type="text/javascript">

           $(document).ready(function () {
               $().SPServices.SPCascadeDropdowns({
                   relationshipList: "Divisions",
                   relationshipListParentColumn: "Directorate",
                   relationshipListChildColumn: "Title",
                   parentColumn: "Directorate Required Field",
                   childColumn: "Division Required Field",
                   debug: true
               });
               $().SPServices.SPCascadeDropdowns({
                   relationshipList: "Branches",
                   relationshipListParentColumn: "Division",
                   relationshipListChildColumn: "Title",
                   parentColumn: "Division Required Field",
                   childColumn: "Branch Required Field",
                   debug: true
               });
           });

</script>

Update: I DO get OOTB required field validation as long as the three lookup fields are filled in. Other required fields are called out with "You must specify a value..." as expected. However, the "Something went wrong" error page does load if values are not selected for the three lookup fields.

  • Have you made the SPCascade dropdown fields mandatory? It would be better if you share your code and put the screenshot of error – Niranjan Kulkarni Dec 26 '19 at 15:24
  • Edited to add the code. – Jehiel238 Dec 26 '19 at 19:22
0

Based on your JavaScript code, I test in my environment, the column validate works as expected. You can check if the steps are same with you, if not, please tell us and we can try to reproduce:

Firstly, create four lists as below:

enter image description here

enter image description here

enter image description here

enter image description here

Then I insert the JavaScript code in the New Item form page and check the result as below:

enter image description here

| improve this answer | |
  • Thanks, Hellofiona. I have my lists set up the same way as you do. I am using a content editor web part for the JavaScript on the custom form page. Are you placing the JavaScript directly on the form itself? If so, where on the form did you place it? Is it a custom form? – Jehiel238 Dec 27 '19 at 14:56
  • I use the default new/edit form in the list. And insert a content editor web part in the form page and insert the code in it. – Hellofiona_MSFT Dec 30 '19 at 1:25
  • I'm doing it the same way, but for a custom form. – Jehiel238 Dec 30 '19 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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