Code work whell before i add to code: items[i].get_item("SITE")
I can take ID from code, but not a column element. What have I do bad. Here is a code:
<input type='button' id='123' value='Pokaż rekordy' onclick="getSelectedItems();"/>
<div>
<p id="p1"></p>
</div>
<script language="javascript" type="text/javascript">
function getSelectedItems()
{
var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var myItems = '';
var i;
var siteUrl = '/sites/MCUW-IT/kostka-pilotaze/restauracje-pilotaże/';
document.getElementById("p1").innerHTML="";
for (i in items){
myItems = items[i].id;
var targetListItem;
document.getElementById("p1").innerHTML += items[i].id + " "**+ items[i].get_item("SITE")**;
window.location.href = window.location.pathname + window.location.search + window.location.hash;
updateListItem();
function updateListItem() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Testowa Lista');
this.oListItem = oList.getItemById(myItems);
oListItem.set_item('Poka_x017c_WWidoku', 'Tak');
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
alert('Item updated!');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
}
}
</script>
EDITED
It's don't work. Its don't giving me anything as return. See the code:
<input type='button' id='124' value='Pokaż' onclick="abc();"/>
<div>
<p id="p2"></p>
</div>
<script>
function abc() {
getSelectedItems().then(function(items){
var i;
for (i in items){
myItems = items[i].id;
var targetListItem;
document.getElementById("p2").innerHTML += items[i].id + " "+ items[i].get_item("SITE");
window.location.href = window.location.pathname + window.location.search + window.location.hash;
updateListItem();
}
}
}
</script>