The form that I created requires the creator to assign a person "Reviewer 1" before they can save and trigger the workflow to begin. Once Reviewer 1 accesses the item to review (Edit Form), they have to approve/reject the item, and then assign a 2nd reviewer.

Is there a way to make the Reviewer 2 field required to where it must be entered in order to complete the form. It is too simple to go past this field and save, which messes the workflow process up.

  • You can make a custom check using jQuery in the form to check if the field is empty on form submission – Gintas K Feb 23 '17 at 15:27
  • I am very new to javascript, so any references or further explanation would be helpful. – cbbrown Feb 23 '17 at 15:38
  • @GintasK is there anyway I can use this script, but modify it to make the field required? SPUtility.GetSPField('Reviewer 2').MakeReadOnly(); – cbbrown Feb 23 '17 at 19:27
  • 2
    Or perhaps use a PreSaveAction to require the field be filled before the form can be saved. If field is empty, user will be alerted. – cbbrown Feb 23 '17 at 21:40

EDIT: Had some time to mock this up on a task edit form and it works as expected. It will not allow you to submit the form if Reviewer 1 and Reviewer 2 fields are blank. Reviewer 1 should have been supplied previously as I understand it. This is more of a redundancy check and could be omitted if you'd like. That would make the if block simply if(rev2).

It could work with a PreSaveAction function on your edit form. It would look something like this (assumes jQuery, if you aren't using jQuery or want a pure Javascript solution, lmk):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">
function PreSaveAction(){
    //these look for the display name values in the associated people pickers

    var rev2 = $("input[Title='Reviewer 2']").attr("aria-label");

        return true;
        alert("You must supply a Reviewer 2 person.");
        return false;
  • So, in order to plug this into a script editor web part, would I just put the <script></script> in front and behind it, or just place as is? Sorry, I'm a newbie at this. – cbbrown Feb 27 '17 at 2:39
  • Updated. And I wanted to make sure I had this right, the submitter supplies Reviewer 1, and it is Reviewer 1 that is coming to the edit form and that person must supply Reviewer 2 correct? If so, then the rev1 part is not necessary and I can update accordingly. – Eric Alexander Feb 27 '17 at 3:19
  • Yes, that is correct. Reviewer 1 assigns reviewer 2 in the edit form. Reviewer 2 does access the edit form, but only to approve/reject. I can always use the extra variable to require another field. Thanks for the script part. Is that standard for any javascript used, or just for this example? – cbbrown Feb 27 '17 at 13:07
  • 1
    The PreSaveAction is a standard function you can use anywhere in SharePoint to apply any validation or preprocessing of the form data prior to it being submitted. If you want the processing to continue and save the change, you must return true, if you return false, the item cannot be submitted. – Eric Alexander Feb 27 '17 at 13:13
  • I just thought of this, but what if Reviewer 1 were to reject the invoice? Then the reviewer 2 field wouldn't have to be filled. Is there a way we can include this? – cbbrown Feb 28 '17 at 21:23

Previous answer (Eric A) is definitely untested and should be downvoted for being incorrect. It assumes both Reviewer fields need to be filled out at the same time. Do not waste your time there.

To restate & understand the problem you have 3 users: Creator, Reviewer 1, Reviewer 2.

Creator: submits item and assigns Reviewer 1.

Reviewer 1: approves and assigns Reviewer 2.

Reviewer 2: approves.

1) Workflow Solution:

This is a typical Multi Stage Approval Workflow. Enable Approval, add a copy of the approval workflow with two stages (Reviewer 1 & 2). Capture Reviewer 2 info on custom approval workflow task form & save to the Reviewer 2 field as part of approval workflow. Benefit here is no custom code. List workflow & done. You can even hide the Reviewer 2 field on the EditForm.aspx.

2) JavaScript EditForm.aspx Solution:

If you really wanted to do this via custom code the pseudo code would look like:

0) Get the current user information.


1) Query the current list item using CSOM or REST to get the current "Reviewer 1" and "Created By" user values (server dataset).

Get Current list item

ListID JS:


ItemID JS:

var itemId = null;
   function(i,d){ return d.startsWith("ID") ? (itemId = d.split("=")[1]) : false ; }

2) If "Created By User" & "Reviewer 1" in server dataset BOTH have values AND current user is "Reviewer 1" then "Reviewer 2" is a required field.

var reviewer2Required = true;

3) Add validation using a PreSaveAction to enforce that (assumes classic forms).

function PreSaveAction(){

    var fieldName = "Reviewer 2",           // the name of the field 
        msg = fieldName + " is a required field";   // the error message

    // ensure reviewer 2 is required and that the person field contains a valid person object.
    if(reviewer2Required && $("input[type=hidden]", "[title='" + fieldName + "']").val() == "") {

      // write a modern validation error to the display
      $("[title='" + fieldName + "']")
         .text(msg).css("color", "red");

      /* alert(msg); // FYI legacy validation error  */

      return false;  // invalidate


    return true; // validate


I hope this helps. Please let us know which direction you

  • Thanks so much for your help! I wish I had 2 bounties to give. Both answers were very helpful. – cbbrown Feb 27 '17 at 14:55

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.