Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

how to update a People group field in SharePoint list with a given SharePoint group

$
0
0
I have a requirement that I need to update a field in my list item (upon creation with the value of a SharePoint group stored in another list. How can I accomplish this either using SharePoint designer or JavaScript please?

How can I utilize the code below to insert value of a given SharePoint group into a field using Ajax:

function updateFileMetadata()
{
    ro = new SP.RequestExecutor('https://mysiteurl');
    var info = {
        url: "_api/web/GetFolderByServerRelativeUrl('documentlibraryurl')/Files/getbyurl(url='" + currentFileName+ "')/listitemallfields/validateupdatelistitem",
        method: "POST",
        body: JSON.stringify({
            'formValues': [
                {
                    '__metadata': { 'type': 'SP.ListItemFormUpdateValue' },
                    'FieldName': 'fieldname1',
                    'FieldValue': value1
                },
            {
                '__metadata': { 'type': 'SP.ListItemFormUpdateValue' },
                'FieldName': 'FieldName2',
                'FieldValue': value2
            },
            {
                '__metadata': { 'type': 'SP.ListItemFormUpdateValue' },
                'FieldName': 'PersonOrGroupField',
                'FieldValue': Value3
            }
            ],
            'bNewDocumentUpdate': true,
            'checkInComment': ''
        }),
        'headers': {
            'accept': 'application/json;odata=verbose',
            'content-type': 'application/json;odata=verbose',
        },
        success: mysuccessfunction,
        error: myErrorfunction
    };
    ro.executeAsync(info);

}



Viewing all articles
Browse latest Browse all 7589

Trending Articles