In recently i have to work with problem which recursively call asynchronous methods. I tried with differed object $.when.appy ; but with large number of calls this method didn't show any constant result. Therefore i used some call back function with to archive this task. Here I'm a keeping a TrackCalls object to track async calls and their returns. If any error occurred loop will be stopped and notify. var TrackCalls = { "callCount" : 0 , "receivedCount" :0 , "errorCount" :0}; function callBack() { setTimeout( function () { if (TrackCalls.callCount == TrackCalls.receivedCount) { // all async call received } else if (TrackCalls.errorCount > 0) { // Error occurred in one of async call } else { callback(); } }, 2000); } function AsyncCall( finised , failed) { TrackCalls.callCount++; $.ajax({url: "test.html" }) ...
Let assume y is our object which has following data and you need to iterate it in native JavaScript var y = {1: "2" , name: "value" , sN: "sV" } $.each(y,function(k,v){alert(k + v)}); in jQuery you can do the same thing like below var Y = {1: "2" , name: "value" , sN: "sV" } for (var k in Y) { if (y.hasOwnProperty(k)) { alert(y[k]) ; // value alert(k) ; // key } }
How to make a REST call in SharePoint App and SharePoint Provider Hosted App – Part 1 SharePoint 2013 List Operations in REST– Retrieve List Fields Basics – Part 2 You can use the function specified in the first post to call the REST URLs. You can use the appropriate function depending on the App type you are developing. Get selected fields in SharePoint List using SELECT REST operation. Getting single value fields /* List Name : listname Columns: Title => Text , ID => Number */ var url = "/_api/web/lists/getbytitle('listname')/items?$select=Title,ID" ; function s(data){ // get the data and convert to JSON Objects var d = JSON.parse(data.body).d.results[0]; alert(d.ID); alert(d.Title); } function f(data){ alert(data); } getREST(url,s,f); Getting Single value Lookup fields /* List Name : listname Columns: ID => Number , CountryLookup => List LooukUp */ var url = "/_api/web/lists/get...
In my previous post (JSOM List Operations in SharePoint Apps in a proper way (Provider Hosted and SharePoint Hosted)–CRUD) I have explained how to work with basic list operations. Here I’m explaining the CAML and search options that we can perform. (function (spa, $, undefined) { window._sa = spa; _sa.ctx = null; _sa.web = null; // this should be initialised _sa.configs = { SPHostUrl: "", SPAppWebtUrl: "", isCrossDomain: false }; // init(); utils.log(_sa.configs.SPHostUrl); utils.log(_sa.configs.SPWebtUrl); function init() { if (!_sa.configs.SPAppWebtUrl) { alert("Please initialize _sa.configs"); } if (_sa.configs.isCrossDomain) { _sa.ctx = new SP.ClientContext(_sa.configs.SPAppWebtUrl); var factory = new SP.ProxyWebRequestExecutorFactory(_sa.configs.SPAppWebtUrl); _sa.ctx.set_webRequestExecutorFactory(factory); ...
There are few methods that we can use to send Emails in SharePoint Provider Hosted apps. Using general Email Sending method Using SharePoint Client Object Model (CSOM) Using SharePoint JavaScript Model (JSOM) Using general Email Sending method This is the general method we are using for sending email for asp.net. This is method has advantages over other two methods. this method has few advantages over other methods, Send attachments to the recipients Send emails to external users (SharePoint 2013 email function can not be used to send emails to external users) There are many articles in available for this , I’m describing a sample code below. MailMessage mail = new MailMessage( "from@mail.com" , "to@mail.com" ); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false ; client.Host = "smtp.google.com" ; mail.Subject = "this is a test email." ; m...