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

get list item id in javascript?

$
0
0

Hi,

little issues on getting List item id in my js file.

Actually I have created js file for updating list item ie, when click on delete button then 'IsDeleted' checkbox status will change No to Yes. For this I want to get list item id but couldnt get id. please give any suggestions.

Thank you

function LogicalDelete(itmID,lstName)
{	
    var clientContext = null;
    var oList = null;
    var oListItem = null;
    var lstItmIsDeleted = null;
    clientContext = SP.ClientContext.get_current();

    oList = clientContext.get_web().get_lists().getByTitle(lstName);  
    oListItem = oList.getItemById(itmID);
      
    clientContext.load(oListItem,"Title", "IsDeleted");
    oListItem.set_item('IsDeleted', true);
    oListItem.update();
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args) 
{
    var lstItmTitle = null;
    lstItmTitle = oListItem.get_item('Title');    
    
    alert(lstItmTitle + ' has been successfully deleted!');
    window.close();
}

function onQueryFailed(sender, args) 
{
    alert('Error: Could not delete item ! ' + '\n' + args.get_message() + '\n' + args.get_stackTrace());
    window.close();
}</script>



Viewing all articles
Browse latest Browse all 11571

Trending Articles



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