Monday, July 31, 2017

Have checkbox set and disable a metadata field

Here's a snippet of code you can throw into the NewForm.aspx page if you need a checkbox to set a value in a metadata field and disable that metadata field:

 //Execute the Query.
// Get the value of the checkbox
if ($('input[name="NewDepartment"]:checked').val() == "true")
boolAutoApprove = true;
boolAutoApprove = false;

// When checkbox is clicked, set or unset the value of the Department field
$("input[id ^= 'NewDepartment']").change(function(){
boolAutoApprove = !boolAutoApprove;

if (boolAutoApprove) 
$("div[title='Department']").children().html("New Department");


Thursday, July 20, 2017

Create a SharePoint View for All Tasks Assigned to Groups a User is in

I wanted to create a new SharePoint view for tasks that were assigned to me or any groups I'm in.  So first I went to the list where I want to create the view in SharePoint Designer and select new.  I named mine "My Groups":

Then right-click the view and select "Edit in Advanced Mode" to open it up, and search for:


and replace it with the following:

<Membership Type="CurrentUserGroups">
<FieldRef Name="AssignedTo"/>
<FieldRef Name="AssignedTo"></FieldRef>
<Value Type="Integer">

Thanks goes out to Laura Rogers' article on this one!

Tuesday, July 18, 2017

Workflow hangs when calling a web service: "Invalid text value"

When I call a web service I'm usually spitting out what I get back by logging it to the history list.  And sometimes my workflow will hang with an error message along the lines of:

Retrying last request. Next attempt scheduled in less than one minute. Details of last request: HTTP InternalServerError to ...

Invalid text value.

A text field contains invalid data. Please check the value and try again. 

If you see this, it usually means you're logging something to the history list that's greater than 256 characters.

Wednesday, July 5, 2017

Auto Populate Person Field / People Picker in SharePoint Online

Wanted to throw some reference code out there for how to auto populate a Person field using jQuery and SPServices.  The full code is below, and I pasted this directly below the "PlaceHolderMain" in the NewForm.aspx file in SharePoint Designer.  You'll find the original article here.

<script type="text/javascript" src=""></script>
<script src="/_layouts/15/clientforms.js"></script>
<script src="/_layouts/15/clientpeoplepicker.js"></script>
<script src="/_layouts/15/autofill.js"></script>
<script src=""></script>
<script type="text/javascript">

$(document).ready(function () {
SP.SOD.executeFunc('sp.js', null, function () {
retrieveUserInfo("Employee");  // Set this to the Title of the person column

  function retrieveUserInfo(PickerTitle) {
var currentuserName = $().SPServices.SPGetCurrentUser({
fieldName: "Title"

  $('input[title="' + PickerTitle + '"]').val(currentuserName).attr('size', 40);

    $('div[title="' + PickerTitle + '"]').hide();

    // Select the target user field from the dictionary of user fields on the page.
    var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[$('[title="' + PickerTitle + '"]')[0].id];

    // Resolve the user using the value set in the input field.