The text of this article is not in this database — only its details are. Read it on the old site: SharePoint Hosted App Using REST API From Client Side Script
11 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.

sagar JinturkarPosted Jul 3, 2018, 5:09 AM
If editcustomer.js = sourcecode ??
sagar JinturkarPosted Jul 3, 2018, 5:08 AM
And what about the app.js code its not working , it gives an exception $ is undefined
Samudra ChakrabortyPosted Dec 15, 2016, 2:56 AM
Your function should be as below For Getting Customer ============================================================================== function getCustomers() { $("#results").empty(); $("<img>", { "src": "/_layouts/images/GEARS_AN.GIF" }).appendTo("#results"); var executor = new SP.RequestExecutor(appweburl); var FullURL = appweburl + "/_api/web/lists/getbytitle('Customers')/items"; executor.executeAsync( { url: FullURL, method: "GET", headers: { "accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: onDataReturned, error: errorHandler } ); } ============================================================================= For Saving Item to Customer List =============================================================================== function saveNewCustomer(dialogResult, returnValue) { if (dialogResult == SP.UI.DialogResult.OK) { // get data from dialog for new customer var LastName = returnValue.LastName; var FirstName = returnValue.FirstName; var WorkPhone = returnValue.WorkPhone; var executor = new SP.RequestExecutor(appweburl); var FullURL = appweburl + "/_api/Web/Lists/getByTitle('Customers')/items/"; var item = { "__metadata": { "type": "SP.Data.CustomersListItem" }, "Title": LastName, "FirstName": FirstName, "WorkPhone": WorkPhone }; executor.executeAsync({ url: FullURL, method: "POST", headers: { "Content-Type": "application/json;odata=verbose", "Accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val(), }, body: JSON.stringify(item), success: onSuccess, error: onError }); } } ===================================================================================== For Deleting Item to Customer List ==================================================================================== function onDeleteCustomer(customer) { var executor = new SP.RequestExecutor(appweburl); var FullURL = appweburl + "/_api/Web/Lists/getByTitle('Customers')/items(" + customer + ")"; executor.executeAsync({ url: FullURL, method: "DELETE", headers: { "Content-Type": "application/json;odata=verbose", "Accept": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val(), "If-Match": "*" }, success: onSuccess, error: onError }); } ==================================================================================== For Getting specific item from Customer list ==================================================================================== function onUpdateCustomer(customer) { var executor = new SP.RequestExecutor(appweburl); var FullURL = appweburl + "/_api/web/lists/getbytitle('Customers')/items(" + customer + ")"; executor.executeAsync( { url: FullURL, method: "GET", headers: { "accept": "application/json;odata=verbose", "content-type": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val() }, success: onCustomerReturned, error: errorHandler } ); } ==================================================================================== for Updateing Item of the customer list ==================================================================================== function updateCustomer(dialogResult, returnValue) { if (dialogResult == SP.UI.DialogResult.OK) { var Id = returnValue.Id; var FirstName = returnValue.FirstName; var LastName = returnValue.LastName; var WorkPhone = returnValue.WorkPhone; var executor = new SP.RequestExecutor(appweburl); var FullURL = appweburl + "/_api/web/lists/getbytitle('Customers')/items(" + Id + ")"; var item = { "__metadata": { "type": "SP.Data.CustomersListItem" }, "Title": LastName, "FirstName": FirstName, "WorkPhone": WorkPhone }; executor.executeAsync({ url: FullURL, method: "POST", headers: { "accept": "application/json;odata=verbose", "Content-Type": "application/json;odata=verbose", "X-RequestDigest": $("#__REQUESTDIGEST").val(), "X-HTTP-Method": "MERGE", "If-Match": "*" }, body: JSON.stringify(item), success: onSuccess, error: onError }); } }
Nimit ThakurPosted Sep 8, 2016, 1:45 AM
Can you please provide code written in editcustomer.js???
Rajesh KPosted Sep 4, 2016, 3:41 AM
Can you please provide code written in editcustomer.js
Rajesh KPosted Sep 4, 2016, 1:38 AM
Hi,When I clicked on "Add New Customer" , The model dialog is showing and immediately getting javascript error as "Unhandled exception at line 17, column 40482 in script block0x800a139e - JavaScript runtime error: Invalid field or parameter url. on throw SP.RequestExecutorUtility.$G(b); error" Similarly when clicking on edit also same error. is it possible to share complete project that will be great.
Jaspreet SinghPosted Aug 10, 2016, 6:37 AM
Great
Vinodh NarayananPosted Dec 17, 2015, 4:16 AM
Good one