How to update and delete using rest services in SharePoint 2013..

I am looking to create,update and delete data in SharePoint list where i am using below code for creating data..I should be performing three operations on single button click how can i achieve this.Below is the code i am using for creating data to list and
displaying in CEWP.
<html>
<head>
<style type="text/css">
#mytable{
border : 1px solid;
</style>
<script type="text/javascript" src="https://sharepointapp28.sharepoint.com/sites/Dev2013/SiteAssets/Scripts/jquery-1.11.1.min.js" ></script>
<script type="text/javascript">
var ListName;
var webUrl;
$(document).ready(function(){
 SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);//Doubt
function sharePointReady() {
webUrl = _spPageContextInfo.siteAbsoluteUrl;
ListName = "test"; 
$('#btnSub').click(function () {
updateItem();
function updateItem() {
var name = $('#txtName').val();
var Desc = $('#txtDesc').val();
var city = $('#txtCity').val();
    var itemType = GetItemTypeForListName(ListName);
    var item;
        item = {
            '__metadata': { "type": itemType },
            'Name': name,
            'Description': Desc,
            'City': city
    var xmethod = 'POST';
    jQuery.ajax({
        url: webUrl + "/_api/web/lists/getbytitle('" + ListName + "')/items",
        type: "POST",
        data: JSON.stringify(item),
        contentType: "application/json;odata=verbose",
        headers: {
            "Accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        success: onUpdateMSOPProcessSuccess,
        error: onUpdateMSOPProcesFail
    function onUpdateMSOPProcessSuccess(data) {
alert('successfully updated to MyList!!!')
    function onUpdateMSOPProcesFail(data) {
        alert(data.d.err);
function GetItemTypeForListName(name) {
    return "SP.Data." + name + "ListItem";
</script>
</head>
<body>
<table style="width:500px" id="mytable">
<tr><td colspan="3">&nbsp;</td></tr>
<tr><th colspan="3">Rest API</th></tr>
<tr><td colspan="3">&nbsp;</td></tr>
<tr><th>Name</th> <td> : </td> <td> <input type="text" id="txtName" /> </td></tr>
<tr><th>Description</th> <td> : </td> <td> <input type="text" id="txtDesc" /> </td></tr>
<tr><th>City</th> <td> : </td> <td> <input type="text" id="txtCity" /> </td></tr>
<tr><td colspan="3">&nbsp;</td></tr>
<tr><th></th><td colspan="2" align="left"><input type="button" value="submit" id="btnSub" /></th></tr>
<tr><td colspan="3">&nbsp;</td></tr>
</table>
</body>
</html>

Hello,
With one button you want to perform 3(Create, Update and Delete) operation
To create:
First check whether the data exist with full combination of Name,Desc and City.
If not exist you can execute the create function.
If exist, get confirmation to delete the item by pop up. Using item ID you can perform Delete operation
To Update:
How you want to update the item, by keeping unique value or combination of columns?
based on that you can perform the update operation.
Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

Similar Messages

  • How to update and delete records in a text file?

    Hi,
    I had a text file in which contains records line by line with ',' as delimiter as I use stringtokenizer and vector to read the data.
    The format in the text file likes: Name, Sex, Age.
    I want to add 2 functions:
    (1) update the record by name, sex or age;
    (2) delete the whole line of record;
    Do I need to open a temp text file to do it?
    And, what is the algorithm can be suggested?
    For both of them, I want to firstly read the total line numbers. Then, the line number + Name, Sex, Age will be displayed on the console window. User can choose which line of record to update or delete.
    Or, user can search name in order to do that.
    But, what is the backend algorithm to handle it? If I have 10 lines of record, I want to delete 7th line, the 7th line of the text file will be blanked. How can I move 8th, 9th and 10th lines of records up by one line in order to fill the blank line?
    Do I need to copy the first 6 lines to a temp text file and copy the last 3 lines of records to the same temp file first? and then copy all the content of that temp file back to the original text file? If so, how can I copy the same format of the original file (with '\n') to the temp file? I need the same data structure likes Name, Sex, Age.
    However, when I add records, I need to append the text in the original text file, not override it's current content.
    Any advice?
    Thanks
    gogo

    If your file is not designed to be amazingly large, then you don't need to use a temporary file -- you can just read the data into memory and manipulate it there. (Like, into a Document object or something.)
    But if you are dealing with really large files, you might want to consider using a database back end instead of a text file, which is a completely different approach I know but... well, that's why databases were invented.

  • Document Set Creation in document library using REST API in Sharepoint 2013

    Hi,
    I want to create the document set using REST API call. Currently i am able to create the folder and able to upload the files using REST API's in the document library. Is there any way we can pass the contentype name or Id and create the document set using
    REST API call. We need to create the document set along with metadata and upload the files inside the document set.
    I need to create the document set along with meta data column values using REST API. Please let me know how we can achieve this through REST API.
    Thank you,
    Mylsamy

    Hi,
    According to your post, my understanding is that you wanted to create document set along with managed metadata fields.
    The REST API does not currently support working with Managed Metadata or Taxonomy fields.
    As a workaround, we can use the JavaScript Client Object Model.
    Create document set using JavaScript Client Object Model.
    http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/aacd96dc-0fb2-4f0d-ab4c-f94ce819e3ed/create-document-sets-with-javascript-com-sharepoint-2010
    Set managed metadata field with JavaScript Client Object Model.
    http://sharepoint.stackexchange.com/questions/95933/add-list-item-with-managed-metadata-field-through-jsom
    http://sharepointfieldnotes.blogspot.com/2013/06/sharepoint-2013-code-tips-setting.html
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Problem while refreshing the data for the second time using excel services in sharepoint 2013...

    Hi,
    I have migrated my Sharepoint from 2010 to 2013.I am able to get the data at the first time of refresh when I click on refresh for the second time I am getting the empty the sheet.
    below find the flow of refresh
    First Refresh
    On Click of refresh open the workbook with excel services and return the session id.
    Using that session I am invoking RefrehAsync method of excel services
    After refresh completed I am setting the calculation of workbook as automatic(to calculate the formulas) using the same session id
    After setting the calculation as Automatic I am setting the calculation type as full(recalculate) using the same session id.
    Now I am able to see the data
    Second Refresh
    After clicking on refresh instead of opening the workbook I am using the session id(already opened workbook) and setting the calculation type as manual
    I am following the same process from refresh(RefreshAsync) as I have followed in first refresh.
    This time my formulas are not getting calculated because of that I am not able to see the data.
    Could you please let me know that am I missing anything here?
    Is this know issue in Sharepoint2013 excel services as same code is working fine with Sharepoint2010.
    If I close the workbook(session id null) and opens(new session id) for all the refreshes it is working and I am able to see the data.
    Thanks,
    Meenakshi Nagpal
    N.Meenakshi

    I am able to see the data for the second refresh  if I change the data source.If I use the same data source which is used in the first refresh I am not getting the data.Excel services will contact the cubes and calculate the formulas in my workbook.
    Could you please let me know what could be the problem at second refresh while contacting the same data source with same session id?
    Please help me asap.
    Thanks,
    Meenakshi Nagpal
    N.Meenakshi

  • Аdding department export data from a survey list from user profile services in Sharepoint 2013.

    When voting, survey Sharepoint 2013, there is a field created by whom. But the name is not enough. Necessary to add the department name of the profile data in the exported list excel.

    Hi,
    The OOTB feature “Export to Spreadsheet” won’t contain the department in the exported report, we will need to create a custom one programmatically.
    We can use SharePoint Object Model to retrieve the data from the Survey and the User Profile Service, then generate an Excel Spreadsheet with the data we need.
    SharePoint Object Model -
    SPListItem class
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.aspx 
    Add, Update and Delete List Items Programmatically in SharePoint
    http://www.mindfiresolutions.com/Add-Update-and-Delete-List-Items-Programmatically-in-Sharepoint-372.php 
    More information about
    SharePoint Object Model:
    http://msdn.microsoft.com/en-us/library/ms473633.ASPX
    How to: Work with user profiles and organization profiles by using the server object model in SharePoint 2013
    http://msdn.microsoft.com/en-us/library/office/jj163142(v=office.15).aspx
    For about
    generating an Excel document:
    http://www.codeproject.com/Articles/20228/Using-C-to-Create-an-Excel-Document
    Or you can post another question to
    Excel for Developers for about creating an Excel file programmatically:
    http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=exceldev
    Feel free to reply if there are still any questions.
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to authenticate with Sharepoint using rest service and jquery

    Hi ,
    I have a requirement where i need to authenticate with  sharepoint from ios and android app using rest services and jquery.
    Can anyone help me in this .
    Thanks in Advance.
    Regards,
    Srinath 

    Hi,
    According to your post, my understanding is that you want to access SharePoint data from IOS and Android app.
    The following materials for your reference:
    How can I authenticate SharePoint REST calls from Android App?
    http://stackoverflow.com/questions/24673373/how-can-i-authenticate-sharepoint-rest-calls-from-android-app
    Calling RESTful services from your Android app
    http://www.techrepublic.com/blog/software-engineer/calling-restful-services-from-your-android-app/
    SharePoint 2013 REST API in iOS
    http://omicron-llama.co.uk/2012/12/13/sharepoint-2013-rest-api-in-ios/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • How to supervise (and fix) using BPEL web services in AIA?

    We have unbelievably many problems with using AIA & web services concerned. Is there any way of online monitoring using the web services, checking data/parameters provided and fixing what needed - before a disasters comes? The supervising layer should work WITHOUT the same environment (rather on the system level) in order to be on a qualitative much higher reliability level. I would gratefully appreciate any experience to help us from heavy problems...

    Hello,
    With one button you want to perform 3(Create, Update and Delete) operation
    To create:
    First check whether the data exist with full combination of Name,Desc and City.
    If not exist you can execute the create function.
    If exist, get confirmation to delete the item by pop up. Using item ID you can perform Delete operation
    To Update:
    How you want to update the item, by keeping unique value or combination of columns?
    based on that you can perform the update operation.
    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer

  • How to update and insert the records without using Table_comparison and Map_operation?

    How to update and insert the records without using Table_comparison and Map_operation?

    Use either join or MERGE see this Inserting, Updating, and Deleting Data by Using MERGE

  • As i am fresher Please share the doc of ECMA script using java script in SharePoint 2013 also how we can insert,update,delete records in list using ECMA script.

    As i am fresher Please share the doc of ECMA script using java script in SharePoint 2013 step by step also how we can insert,update,delete records in list using ECMA script.
    Thanks and Regards, Rangnath Mali

    Hi,
    According to your post, my understanding is that you want to use JavaScript to work with SharePoint list.
    To create list items, we can create a ListItemCreationInformation object, set its properties, and pass it as parameter to the addItem(parameters) function
    of the List object.
    To set list item properties, we can use a column indexer to make an assignment, and call the update() function so that changes will take effect when you callexecuteQueryAsync(succeededCallback,
    failedCallback). 
    And to delete a list item, call the deleteObject() function on the object. 
    There is an MSDN article about the details steps of this topic, you can have a look at it.
    How to: Create, Update, and Delete List Items Using JavaScript
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • How to Implement basic Insert ,Update and delete Actions

    Hi all,
              i want to implement 1)INSERT 2)UPDATE 3)DELETE actions in webdynpro application means i have to add a new record to my R/3 backend and update and delete records from my database
    can anyone tell me how to do these actions
    Regards
    Padma N

    Hi Murtuza ,
                           I have 2 views in my application.In the first view i enterd some purchaseorder number and clicked serarch button.The items regarding that purchaseorder gets populated in the table which is in second view.All the data is in R/3 backend system.
    the code i used to get the details of that particular purchaseorder is
    try {
    wdcontext.currentZ_Matrls_For_Inputlement().modelObiect.execte();
    catch(RFCException e){
    /* Catch the Exception Here */
    Here now i want to delete one record of that particular purchaseorder from the database.So Wat should be the code to delete record from R/3 Model
    Regards
    Padma N

  • Using Update and Delete Links in QBE Reports with a Template

    QBE Reports in Portal allow Update and Delete links against Report output rows.
    When run, if I press the Update link it displays a simple form and utilises the Template I specified for the Report (as expected).
    If I press the Delete link it displays a page with a default Oracle template (including Navigator, Home and Help buttons I wish to suppress)
    How can I get the Delete to use the specified Template?
    Any simple fix appreciated.

    QBE Reports in Portal allow Update and Delete links against Report output rows.
    When run, if I press the Update link it displays a simple form and utilises the Template I specified for the Report (as expected).
    If I press the Delete link it displays a page with a default Oracle template (including Navigator, Home and Help buttons I wish to suppress)
    How can I get the Delete to use the specified Template?
    Any simple fix appreciated.

  • Insert,update and delete data in a table using webdynpro for abap

    Dear All,
    I have a requirement to create a table allowing the user to add rows in it and update a row as well as delete a row from that table.To do this I guess I have to make use of ALV.But using ALV I am not able to enter data to a table where as I can make a column editable delete a row etc. please guide me to perform these operations(insert,update and delete) on table.
    Thanks,
    Reddy.

    Hi Sridhar,
    By using ALV you can do all insert delete etc things. if you want to edit i mean you can yenter data in ALV.
    Check this...
    http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1
    Editing alv in web dynpro
    editing rows in alv reports
    Re: editing rows and columns in alv reports in webdynpro abap
    Cheers,
    Kris.

  • How to perform insert, update and delete in a table component

    hi all,
    i am using a table component in my page. I want to retreive data from multiple tables as well as perform insertion, updation and deletion operation.The changes should be affected in the corresponding tables. can anyone provide a solution for my problem.
    Thanks in advance
    regards,
    prasant

    There is a great tutorial for insert, update and delete records in a table.
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/inserts_updates_deletes.html
    Hope it helps.
    Thanks,
    Moumita

  • How can I select several emails from 3900 on my 5c and delete the rest easily

         How can I select several emails from 3900 on my 5c and delete the rest easily

    We'll I don't think there's a easy way to delete a lot of emails besides deleting all of them. To delete all of them click on inbox them edit then "mark all" then trash/delete. Other than that you will have to specifically deleted the ones you want to delete.

  • How to deploy and debug java web service in eclipes or using any other soft

    Hai,
    can any one tell me how to deploy and debug java web service in eclipes or using any other software.
    i have used tomcat web server and jdk1.4.0 to develop web service.
    we have used web service to interact with MS outlook .
    bye
    sudhakar.m

    Hi Sudhakar,
    If you are used to working with ant then you can very well use eclipse to deploy your web service.
    You would usually have the ant script in the source root working directory. From eclipse if you select the build file from the navigator view and right click you will see a run ant option in the pop up menu.
    Select that option and you would be able to see each targets with a checkbox select option. So define each target maybe one for wsdl2java conversion, one for compilation and one for deploying your web services. You can either make all of them run by having depends option on or you can run them individually as it takes your fancy.
    I am not sure about debugging a web service yet.
    Hope this helps
    Aviroop
    The truth is out there? Does anyone know the URL?

Maybe you are looking for

  • Best Illustrator method to make a logo background "transparent..."

    I have seen that there are several posts regarding "transparent backgrounds," but but they're difficult to follow. I apologize if this is old territory. If there is a solution somewhere already, I'd appreciate your pointing me towards it. I'm using A

  • Testing apk files on the B & N Nook/Amazon Kindle Fire

    Can someone provide some guidance on how to test on the B & N Nook Device and the Amazon Kindle Fire. I am aware that both devices are Android-based and accept the apk files. However, I would like to test on both devices but I am not sure that these

  • Why does my CSS have black bars?

    I picked 2 col elastic with left sidebar.  It shows as full width with springs but I get black bars on the sides?   How do I make the page wider? Thanks Frank

  • Reg: JDBC

    Hi...    i am doing File to JDBC scenario using the stored procedure. While running the scenario, I am getting below error. Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error

  • Having a look at Adobe Premiere

    Im a very long time FCP User and am not starting this thread to get you hard core fans upset but, K owing the the new suite is coming out and after reading and watching all the vids and posts I can find.... I am entertaining Premiere.... Looks pretty