0

I have a SharePoint workflow with a "comments" field I would like to display when a user is completing a task. For my "Reviewer Comment" site content type, I have the ability to select one of the following options:

This column is:

  • Required (Must contain information)
  • Optional (May contain information)
  • Hidden (Will not appear in forms)

If I choose required, it is displayed without the user having to press "show more." But then it is required. I don't want the comments field to be required, but I want it to be displayed without the user selecting "show more." How can I do this?


Pictures to help with explaining:

enter image description here

This one doesn't show the comment field until I press "Show more"

enter image description here

This one shows the comment field which is good, but I don't want it to be a "required" field.

  • Are you ready to consider a solution with JavaScript? – user19105 Mar 6 '15 at 19:59
0

Tasks new and edit forms, use JavaScript code that embed inside these form to show non-required controls.

When click the “Show more” button, this will fire rlfiShowMore JavaScript function. Then if you want do disable this functionality, you can call this function after page loaded:

<script>
    (function () {
        _spBodyOnLoadFunctionNames.push("rlfiShowMore");
    })();
</script>

You can places this script inside CEWP/Script Editor web part on editform.aspx form.

  • I don't want to disable the "Show more" button, because I still want to hide several fields so the form is less confusing. I just want to always show the "reviewer comment" field. – etho201 Mar 6 '15 at 23:33
  • I may use this as my solution, but I am running into a problem. Now that the "show more" button is gone, my custom buttons (task outcome) at the bottom of my page are no longer buttons, instead they converted into a drop-down menu. How do I prevent this from happening? – etho201 Mar 9 '15 at 18:31
  • It turns out the buttons were being converted to drop down menus because I was hiding the %complete% column. You must show %complete% and "task status" in order for custom outcomes to display as buttons. – etho201 Mar 9 '15 at 20:39
0

You can keep the show more as it is, by default the form has multiple sections, one of them shown which is the upper one, and the one below is set to be hidden, until you click the "show more". You can move a row <tr> from one section and put it in the other using jQuery, you just need to know the id for your section. So you can use the following code to move the description field in tasks to the upper area:

$("div[id^='Body']").parent().closest("tr").appendTo(".ms-formtable");

What this will do is to get the field called description by it's HTML ID which begins with "Body", then get its parent of type tr, which is the row, and move it to the upper section which is the .ms-formtable

You can know the id for your field by using developer tools, and select the textbox, in the example of the description field shown above, it would look like this:

<div class="ms-rtestate-field ms-rtefield ms-inputBox" id="Body_7662cd2c-f069-4dba-9e35-082cf976e170_$TextField_topDiv">...

Note how the id begins with "Body". This is what you will deal with in your script like the one above.

  • What page do I edit? I'm using SharePoint designer and looking at the associated task list --> forms --> EditForm.aspx. – etho201 Mar 6 '15 at 23:43
  • When you go to the task list itself, and click new, you will be redirected to a page with the url: NewForm.aspx, in that page, edit the page, and add a script editor web part. Reference jQuery library (if not already referenced) from Google or any other CDN, and then open a script tag and write the script I've added above, but make sure to provide the ID of your control in the code. – user19105 Mar 6 '15 at 23:57
  • You should do same steps as well on the EditForm.aspx – user19105 Mar 6 '15 at 23:58
  • I added the following to my EditForm.aspx: <script type="text/javascript" src="ajax.googleapis.com/ajax/libs/jquery/1.5/…> $("div[id^='Reviewer_x0020_Comment_8fe70146-a56a-47cb-bf2a-805655cf405a_$TextField_topDiv']").parent().closest("tr").appendTo(".ms-formtable"); When I view the page in the browser, I see this error at the bottom of the page: Web Part Error: Unknown server tag. Correlation ID: c4cbf09c-66f6-f059-fe19-e6fcbeea92b1. My guess is I didn't add the Google jQuery library correctly. Can you provide any guidance? – etho201 Mar 8 '15 at 18:05
  • This is how you add the library: <script src="ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" type="text/javascript"></script> – user19105 Mar 8 '15 at 18:56

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.