0

I have a ParticipantsPickerId (Attendees) field in my Calendar List in Sharepoint 2013. How add value current user in this field.

1

Sample code for your reference:

<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">

var listName = 'Testcal';

var userid = _spPageContextInfo.userId;  

var taskProperties = {
    '__metadata': { "type": "SP.Data.TestcalListItem" },
    "Title": 'New caledar item',
    'ParticipantsPickerIdId': userid  //single-valued User field value 
};

$.ajax({
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items",
    type: "POST",
    contentType: "application/json;odata=verbose",
    data: JSON.stringify(taskProperties),
    headers: {
        "Accept": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val()
    },
    success: function (data) {
        console.log(JSON.stringify(data.d));
    },
    error: function (data) {
        console.log(data.responseText);
    }
});
</script>

enter image description here

  • Is it possible Update field, not overwriting old records? – alexaf Jul 10 '18 at 12:11

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.