Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

User selection via ribbon and updated multiple selected Items assigned to field with user id function

$
0
0

I am looking the different approach for CallbackAssignedTo function which I can use in any browser as ActiveX is only confined to IE , and still the code is not fully working. unable to update the Assigned to field with user Id's and button is greyed when selecting multiple items.

<link rel="stylesheet" type="text/css" href="http://test/jquery-ui.min.css"><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"> </script><script src="http://test/jquery-ui.min.js"></script><script type="text/javascript">// <![CDATA[

function getAssignedTo(defaultSearch) {
if (defaultSearch == undefined)
    defaultSearch = '';
var sDialogUrl = '\u002f_layouts\u002fPicker.aspx?MultiSelect=False\u0026CustomProperty=User\u00252CSecGroup\u00252CSPGroup\u00253B\u00253B15\u00253B\u00253B\u00253BFalse\u0026DialogTitle=Select\u002520People\u002520and\u002520Groups\u0026DialogImage=\u00252F\u00255Flayouts\u00252Fimages\u00252Fppeople\u00252Egif\u0026PickerDialogType=Microsoft\u00252ESharePoint\u00252EWebControls\u00252EPeoplePickerDialog\u00252C\u002520Microsoft\u00252ESharePoint\u00252C\u002520Version\u00253D14\u00252E0\u00252E0\u00252E0\u00252C\u002520Culture\u00253Dneutral\u00252C\u002520PublicKeyToken\u00253D71e9bce111e9429c\u0026ForceClaims=False\u0026DisableClaims=False\u0026EnabledClaimProviders=\u0026EntitySeparator=\u00253B\u0025EF\u0025BC\u00259B\u0025EF\u0025B9\u002594\u0025EF\u0025B8\u002594\u0025E2\u00258D\u0025AE\u0025E2\u002581\u00258F\u0025E1\u00258D\u0025A4\u0025D8\u00259B';
sDialogUrl = sDialogUrl + '&DefaultSearch=' + escapeProperly(defaultSearch);
var sFeatures = 'resizable: yes; status: no; scroll: no; help: no; center: yes; dialogWidth : 575px; dialogHeight : 500px; zoominherit : 1';

var rv = commonShowModalDialog(sDialogUrl, sFeatures, CallbackAssignedTo);
}
function CallbackAssignedTo(xml) {
if (xml == null)
    return;
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xml);
var node = xmlDoc.getElementsByTagName('Entity');
var userName = '';
var selectedUser = null;
if (node != null) {
    if (node[0].attributes.getNamedItem('Key') != null) {
        userName = node[0].attributes.getNamedItem('Key').value
        userName = userName.substring(userName.indexOf('\\') + 1, userName.length);
        selectedUser = SP.FieldUserValue.fromUser(userName)
    }
}
if (selectedUser != null) {
    var ctx = SP.ClientContext.get_current();
    var currentweb = ctx.get_web();
    var ListId = SP.ListOperation.Selection.getSelectedList();
    var list = currentweb.get_lists().getById(ListId);
    var selectedItems = SP.ListOperation.Selection.getSelectedItems();
    var k;
    var ListItem;
    for (k in selectedItems) {
        ListItem = list.getItemById(selectedItems[k].id);
        ListItem.set_item('AssignedTo', selectedUser);
        ListItem.update();

    }
    ctx.executeQueryAsync(function (sender, args) { }, function (sender, args) { });
}
}

// ]]></script><div><div id="spp"></div>


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>