Produced by Araxis Merge on 2/1/2017 2:57:00 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM\trunk\SDK\SampleCode\JS\RESTEndpoint\JQueryRESTDataOperations\JQueryRESTDataOperations\Scripts | SDK.JQuery.js | Tue Dec 20 19:51:48 2016 UTC |
| 2 | Wed Feb 1 19:57:00 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 406 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | // ======= ========== ========== ========== ========== ========== ========== == | |||||
| 2 | // This f ile is par t of the M icrosoft D ynamics CR M SDK code samples. | |||||
| 3 | // | |||||
| 4 | // Copyri ght (C) Mi crosoft Co rporation. All righ ts reserve d. | |||||
| 5 | // | |||||
| 6 | // This s ource code is intend ed only as a supplem ent to Mic rosoft | |||||
| 7 | // Develo pment Tool s and/or o n-line doc umentation . See the se other | |||||
| 8 | // materi als for de tailed inf ormation r egarding M icrosoft c ode sample s. | |||||
| 9 | // | |||||
| 10 | // THIS C ODE AND IN FORMATION ARE PROVID ED "AS IS" WITHOUT W ARRANTY OF ANY | |||||
| 11 | // KIND, EITHER EXP RESSED OR IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E | |||||
| 12 | // IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR A | |||||
| 13 | // PARTIC ULAR PURPO SE. | |||||
| 14 | // ======= ========== ========== ========== ========== ========== ========== == | |||||
| 15 | // <snippe tJQueryRES TDataOpera tions.SDK. JQuery.js> | |||||
| 16 | /// <refer ence path= "jquery1.4 .1vsdoc.js " /> | |||||
| 17 | ||||||
| 18 | if (typeof (SDK) == "undefined ") | |||||
| 19 | { SDK = { __namespac e: true }; } | |||||
| 20 | SDK.JQuery = { | |||||
| 21 | _context: function () { | |||||
| 22 | ///<summ ary> | |||||
| 23 | /// Priv ate functi on to the context ob ject. | |||||
| 24 | ///</sum mary> | |||||
| 25 | ///<retu rns>Contex t</returns > | |||||
| 26 | if (type of GetGlob alContext != "undefi ned") | |||||
| 27 | { return GetGlobal Context(); } | |||||
| 28 | else { | |||||
| 29 | if (typ eof Xrm != "undefine d") { | |||||
| 30 | return Xrm.Page. context; | |||||
| 31 | } | |||||
| 32 | else | |||||
| 33 | { throw new Error ("Context is not ava ilable."); } | |||||
| 34 | } | |||||
| 35 | }, | |||||
| 36 | _getClien tUrl: func tion () { | |||||
| 37 | ///<summ ary> | |||||
| 38 | /// Priv ate functi on to retu rn the ser ver URL fr om the con text | |||||
| 39 | ///</sum mary> | |||||
| 40 | ///<retu rns>String </returns> | |||||
| 41 | var serv erUrl = th is._contex t().getCli entUrl() | |||||
| 42 | ||||||
| 43 | return s erverUrl; | |||||
| 44 | }, | |||||
| 45 | _ODataPat h: functio n () { | |||||
| 46 | ///<summ ary> | |||||
| 47 | /// Priv ate functi on to retu rn the pat h to the R EST endpoi nt. | |||||
| 48 | ///</sum mary> | |||||
| 49 | ///<retu rns>String </returns> | |||||
| 50 | return t his._getCl ientUrl() + "/XRMSer vices/2011 /Organizat ionData.sv c/"; | |||||
| 51 | }, | |||||
| 52 | _errorHan dler: func tion (req) { | |||||
| 53 | ///<summ ary> | |||||
| 54 | /// Priv ate functi on return an Error o bject to t he errorCa llback | |||||
| 55 | ///</sum mary> | |||||
| 56 | ///<para m name="re q" type="X MLHttpRequ est"> | |||||
| 57 | /// The XMLHttpReq uest respo nse that r eturned an error. | |||||
| 58 | ///</par am> | |||||
| 59 | ///<retu rns>Error< /returns> | |||||
| 60 | return n ew Error(" Error : " + | |||||
| 61 | re q.status + ": " + | |||||
| 62 | re q.statusTe xt + ": " + | |||||
| 63 | JS ON.parse(r eq.respons eText).err or.message .value); | |||||
| 64 | }, | |||||
| 65 | _dateRevi ver: funct ion (key, value) { | |||||
| 66 | ///<summ ary> | |||||
| 67 | /// Priv ate functi on to conv ert matchi ng string values to Date objec ts. | |||||
| 68 | ///</sum mary> | |||||
| 69 | ///<para m name="ke y" type="S tring"> | |||||
| 70 | /// The key used t o identify the objec t property | |||||
| 71 | ///</par am> | |||||
| 72 | ///<para m name="va lue" type= "String"> | |||||
| 73 | /// The string val ue represe nting a da te | |||||
| 74 | ///</par am> | |||||
| 75 | var a; | |||||
| 76 | if (type of value = == 'string ') { | |||||
| 77 | a = /Da te\(([-+]? \d+)\)/.ex ec(value); | |||||
| 78 | if (a) { | |||||
| 79 | return new Date( parseInt(v alue.repla ce("/Date( ", "").rep lace(")/", ""), 10)) ; | |||||
| 80 | } | |||||
| 81 | } | |||||
| 82 | return v alue; | |||||
| 83 | }, | |||||
| 84 | _paramete rCheck: fu nction (pa rameter, m essage) { | |||||
| 85 | ///<summ ary> | |||||
| 86 | /// Priv ate functi on used to check whe ther requi red parame ters are n ull or und efined | |||||
| 87 | ///</sum mary> | |||||
| 88 | ///<para m name="pa rameter" t ype="Objec t"> | |||||
| 89 | /// The parameter to check; | |||||
| 90 | ///</par am> | |||||
| 91 | ///<para m name="me ssage" typ e="String" > | |||||
| 92 | /// The error mess age text t o include when the e rror is th rown. | |||||
| 93 | ///</par am> | |||||
| 94 | if ((typ eof parame ter === "u ndefined") || parame ter === nu ll) { | |||||
| 95 | throw n ew Error(m essage); | |||||
| 96 | } | |||||
| 97 | }, | |||||
| 98 | _stringPa rameterChe ck: functi on (parame ter, messa ge) { | |||||
| 99 | ///<summ ary> | |||||
| 100 | /// Priv ate functi on used to check whe ther requi red parame ters are n ull or und efined | |||||
| 101 | ///</sum mary> | |||||
| 102 | ///<para m name="pa rameter" t ype="Strin g"> | |||||
| 103 | /// The string par ameter to check; | |||||
| 104 | ///</par am> | |||||
| 105 | ///<para m name="me ssage" typ e="String" > | |||||
| 106 | /// The error mess age text t o include when the e rror is th rown. | |||||
| 107 | ///</par am> | |||||
| 108 | if (type of paramet er != "str ing") { | |||||
| 109 | throw n ew Error(m essage); | |||||
| 110 | } | |||||
| 111 | }, | |||||
| 112 | _callback ParameterC heck: func tion (call backParame ter, messa ge) { | |||||
| 113 | ///<summ ary> | |||||
| 114 | /// Priv ate functi on used to check whe ther requi red callba ck paramet ers are fu nctions | |||||
| 115 | ///</sum mary> | |||||
| 116 | ///<para m name="ca llbackPara meter" typ e="Functio n"> | |||||
| 117 | /// The callback p arameter t o check; | |||||
| 118 | ///</par am> | |||||
| 119 | ///<para m name="me ssage" typ e="String" > | |||||
| 120 | /// The error mess age text t o include when the e rror is th rown. | |||||
| 121 | ///</par am> | |||||
| 122 | if (type of callbac kParameter != "funct ion") { | |||||
| 123 | throw n ew Error(m essage); | |||||
| 124 | } | |||||
| 125 | }, | |||||
| 126 | createRec ord: funct ion (objec t, type, s uccessCall back, erro rCallback) { | |||||
| 127 | ///<summ ary> | |||||
| 128 | /// Send s an async hronous re quest to c reate a ne w record. | |||||
| 129 | ///</sum mary> | |||||
| 130 | ///<para m name="ob ject" type ="Object"> | |||||
| 131 | /// A Ja vaScript o bject with propertie s correspo nding to t he Schema name of | |||||
| 132 | /// enti ty attribu tes that a re valid f or create operations . | |||||
| 133 | ///</par am> | |||||
| 134 | this._pa rameterChe ck(object, "SDK.JQue ry.createR ecord requ ires the o bject para meter."); | |||||
| 135 | ///<para m name="ty pe" type=" String"> | |||||
| 136 | /// The Schema Nam e of the E ntity type record to create. | |||||
| 137 | /// For an Account record, u se "Accoun t" | |||||
| 138 | ///</par am> | |||||
| 139 | this._st ringParame terCheck(t ype, "SDK. JQuery.cre ateRecord requires t he type pa rameter is a string. "); | |||||
| 140 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 141 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 142 | /// This function can accept the retur ned record as a para meter. | |||||
| 143 | /// </pa ram> | |||||
| 144 | this._ca llbackPara meterCheck (successCa llback, "S DK.JQuery. createReco rd require s the succ essCallbac k is a fun ction."); | |||||
| 145 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 146 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 147 | /// This function must accep t an Error object as a paramet er. | |||||
| 148 | /// </pa ram> | |||||
| 149 | this._ca llbackPara meterCheck (errorCall back, "SDK .JQuery.cr eateRecord requires the errorC allback is a functio n."); | |||||
| 150 | ||||||
| 151 | var json Entity = w indow.JSON .stringify (object); | |||||
| 152 | ||||||
| 153 | $.ajax({ type: "PO ST", | |||||
| 154 | content Type: "app lication/j son; chars et=utf-8", | |||||
| 155 | datatyp e: "json", | |||||
| 156 | url: th is._ODataP ath() + ty pe + "Set" , | |||||
| 157 | data: j sonEntity, | |||||
| 158 | beforeS end: funct ion (xhr) { | |||||
| 159 | //Spec ifying thi s header e nsures tha t the resu lts will b e returned as JSON. | |||||
| 160 | xhr.se tRequestHe ader("Acce pt", "appl ication/js on"); | |||||
| 161 | }, | |||||
| 162 | success : function (data, te xtStatus, xhr) { | |||||
| 163 | succes sCallback( data.d); | |||||
| 164 | }, | |||||
| 165 | error: function ( xhr, textS tatus, err orThrown) { | |||||
| 166 | errorC allback(SD K.JQuery._ errorHandl er(xhr)); | |||||
| 167 | } | |||||
| 168 | }); | |||||
| 169 | }, | |||||
| 170 | retrieveR ecord: fun ction (id, type, sel ect, expan d, success Callback, errorCallb ack) { | |||||
| 171 | ///<summ ary> | |||||
| 172 | /// Send s an async hronous re quest to r etrieve a record. | |||||
| 173 | ///</sum mary> | |||||
| 174 | ///<para m name="id " type="St ring"> | |||||
| 175 | /// A St ring repre senting th e GUID val ue for the record to retrieve. | |||||
| 176 | ///</par am> | |||||
| 177 | this._st ringParame terCheck(i d, "SDK.JQ uery.retri eveRecord requires t he id para meter is a string.") ; | |||||
| 178 | ///<para m name="ty pe" type=" String"> | |||||
| 179 | /// The Schema Nam e of the E ntity type record to retrieve. | |||||
| 180 | /// For an Account record, u se "Accoun t" | |||||
| 181 | ///</par am> | |||||
| 182 | this._st ringParame terCheck(t ype, "SDK. JQuery.ret rieveRecor d requires the type parameter is a strin g."); | |||||
| 183 | ///<para m name="se lect" type ="String"> | |||||
| 184 | /// A St ring repre senting th e $select OData Syst em Query O ption to c ontrol whi ch | |||||
| 185 | /// attr ibutes wil l be retur ned. This is a comma separated list of A ttribute n ames that are valid for retrie ve. | |||||
| 186 | /// If n ull all pr operties f or the rec ord will b e returned | |||||
| 187 | ///</par am> | |||||
| 188 | if (sele ct != null ) | |||||
| 189 | this._s tringParam eterCheck( select, "S DK.JQuery. retrieveRe cord requi res the se lect param eter is a string."); | |||||
| 190 | ///<para m name="ex pand" type ="String"> | |||||
| 191 | /// A St ring repre senting th e $expand OData Syst em Query O ption valu e to contr ol which | |||||
| 192 | /// rela ted record s are also returned. This is a comma sep arated lis t of of up to 6 enti ty relatio nship name s | |||||
| 193 | /// If n ull no exp anded rela ted record s will be returned. | |||||
| 194 | ///</par am> | |||||
| 195 | if (expa nd != null ) | |||||
| 196 | this._s tringParam eterCheck( expand, "S DK.JQuery. retrieveRe cord requi res the ex pand param eter is a string."); | |||||
| 197 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 198 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 199 | /// This function must accep t the retu rned recor d as a par ameter. | |||||
| 200 | /// </pa ram> | |||||
| 201 | this._ca llbackPara meterCheck (successCa llback, "S DK.JQuery. retrieveRe cord requi res the su ccessCallb ack parame ter is a f unction.") ; | |||||
| 202 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 203 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 204 | /// This function must accep t an Error object as a paramet er. | |||||
| 205 | /// </pa ram> | |||||
| 206 | this._ca llbackPara meterCheck (errorCall back, "SDK .JQuery.re trieveReco rd require s the erro rCallback parameter is a funct ion."); | |||||
| 207 | ||||||
| 208 | var syst emQueryOpt ions = ""; | |||||
| 209 | ||||||
| 210 | if (sele ct != null || expand != null) { | |||||
| 211 | systemQ ueryOption s = "?"; | |||||
| 212 | if (sel ect != nul l) { | |||||
| 213 | var se lectString = "$selec t=" + sele ct; | |||||
| 214 | if (ex pand != nu ll) { | |||||
| 215 | selec tString = selectStri ng + "," + expand; | |||||
| 216 | } | |||||
| 217 | system QueryOptio ns = syste mQueryOpti ons + sele ctString; | |||||
| 218 | } | |||||
| 219 | if (exp and != nul l) { | |||||
| 220 | system QueryOptio ns = syste mQueryOpti ons + "&$e xpand=" + expand; | |||||
| 221 | } | |||||
| 222 | } | |||||
| 223 | ||||||
| 224 | $.ajax({ | |||||
| 225 | type: " GET", | |||||
| 226 | content Type: "app lication/j son; chars et=utf-8", | |||||
| 227 | datatyp e: "json", | |||||
| 228 | url: th is._ODataP ath() + ty pe + "Set" + "(guid' " + id + " ')" + syst emQueryOpt ions, | |||||
| 229 | beforeS end: funct ion (xhr) { | |||||
| 230 | //Spec ifying thi s header e nsures tha t the resu lts will b e returned as JSON. | |||||
| 231 | xhr.se tRequestHe ader("Acce pt", "appl ication/js on"); | |||||
| 232 | }, | |||||
| 233 | success : function (data, te xtStatus, xhr) { | |||||
| 234 | //JQue ry does no t provide an opportu nity to sp ecify a da te reviver so this c ode | |||||
| 235 | // pars es the xhr .responseT ext rather than use the data p arameter p assed by J Query. | |||||
| 236 | succes sCallback( JSON.parse (xhr.respo nseText, S DK.JQuery. _dateReviv er).d); | |||||
| 237 | }, | |||||
| 238 | error: function ( xhr, textS tatus, err orThrown) { | |||||
| 239 | errorC allback(SD K.JQuery._ errorHandl er(xhr)); | |||||
| 240 | } | |||||
| 241 | }); | |||||
| 242 | }, | |||||
| 243 | updateRec ord: funct ion (id, o bject, typ e, success Callback, errorCallb ack) { | |||||
| 244 | ///<summ ary> | |||||
| 245 | /// Send s an async hronous re quest to u pdate a re cord. | |||||
| 246 | ///</sum mary> | |||||
| 247 | ///<para m name="id " type="St ring"> | |||||
| 248 | /// A St ring repre senting th e GUID val ue for the record to retrieve. | |||||
| 249 | ///</par am> | |||||
| 250 | this._st ringParame terCheck(i d, "SDK.JQ uery.updat eRecord re quires the id parame ter."); | |||||
| 251 | ///<para m name="ob ject" type ="Object"> | |||||
| 252 | /// A Ja vaScript o bject with propertie s correspo nding to t he Schema Names for | |||||
| 253 | /// enti ty attribu tes that a re valid f or update operations . | |||||
| 254 | ///</par am> | |||||
| 255 | this._pa rameterChe ck(object, "SDK.JQue ry.updateR ecord requ ires the o bject para meter."); | |||||
| 256 | ///<para m name="ty pe" type=" String"> | |||||
| 257 | /// The Schema Nam e of the E ntity type record to retrieve. | |||||
| 258 | /// For an Account record, u se "Accoun t" | |||||
| 259 | ///</par am> | |||||
| 260 | this._st ringParame terCheck(t ype, "SDK. JQuery.upd ateRecord requires t he type pa rameter.") ; | |||||
| 261 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 262 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 263 | /// Noth ing will b e returned to this f unction. | |||||
| 264 | /// </pa ram> | |||||
| 265 | this._ca llbackPara meterCheck (successCa llback, "S DK.JQuery. updateReco rd require s the succ essCallbac k is a fun ction."); | |||||
| 266 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 267 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 268 | /// This function must accep t an Error object as a paramet er. | |||||
| 269 | /// </pa ram> | |||||
| 270 | this._ca llbackPara meterCheck (errorCall back, "SDK .JQuery.up dateRecord requires the errorC allback is a functio n."); | |||||
| 271 | ||||||
| 272 | var json Entity = w indow.JSON .stringify (object); | |||||
| 273 | ||||||
| 274 | $.ajax({ | |||||
| 275 | type: " POST", | |||||
| 276 | content Type: "app lication/j son; chars et=utf-8", | |||||
| 277 | datatyp e: "json", | |||||
| 278 | data: j sonEntity, | |||||
| 279 | url: th is._ODataP ath() + ty pe + "Set" + "(guid' " + id + " ')", | |||||
| 280 | beforeS end: funct ion (xhr) { | |||||
| 281 | //Spec ifying thi s header e nsures tha t the resu lts will b e returned as JSON. | |||||
| 282 | xhr.se tRequestHe ader("Acce pt", "appl ication/js on"); | |||||
| 283 | //Spec ify the HT TP method MERGE to u pdate just the chang es you are submittin g. | |||||
| 284 | xhr.se tRequestHe ader("X-HT TP-Method" , "MERGE") ; | |||||
| 285 | }, | |||||
| 286 | success : function (data, te xtStatus, xhr) { | |||||
| 287 | //Nothi ng is retu rned to th e success function | |||||
| 288 | succes sCallback( ); | |||||
| 289 | }, | |||||
| 290 | error: function ( xhr, textS tatus, err orThrown) { | |||||
| 291 | errorC allback(SD K.JQuery._ errorHandl er(xhr)); | |||||
| 292 | } | |||||
| 293 | }); | |||||
| 294 | }, | |||||
| 295 | deleteRec ord: funct ion (id, t ype, succe ssCallback , errorCal lback) { | |||||
| 296 | ///<summ ary> | |||||
| 297 | /// Send s an async hronous re quest to d elete a re cord. | |||||
| 298 | ///</sum mary> | |||||
| 299 | ///<para m name="id " type="St ring"> | |||||
| 300 | /// A St ring repre senting th e GUID val ue for the record to delete. | |||||
| 301 | ///</par am> | |||||
| 302 | this._st ringParame terCheck(i d, "SDK.JQ uery.delet eRecord re quires the id parame ter."); | |||||
| 303 | ///<para m name="ty pe" type=" String"> | |||||
| 304 | /// The Schema Nam e of the E ntity type record to delete. | |||||
| 305 | /// For an Account record, u se "Accoun t" | |||||
| 306 | ///</par am> | |||||
| 307 | this._st ringParame terCheck(t ype, "SDK. JQuery.del eteRecord requires t he type pa rameter.") ; | |||||
| 308 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 309 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 310 | /// Noth ing will b e returned to this f unction. | |||||
| 311 | /// </pa ram> | |||||
| 312 | this._ca llbackPara meterCheck (successCa llback, "S DK.JQuery. deleteReco rd require s the succ essCallbac k is a fun ction."); | |||||
| 313 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 314 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 315 | /// This function must accep t an Error object as a paramet er. | |||||
| 316 | /// </pa ram> | |||||
| 317 | this._ca llbackPara meterCheck (errorCall back, "SDK .JQuery.de leteRecord requires the errorC allback is a functio n."); | |||||
| 318 | ||||||
| 319 | $.ajax({ | |||||
| 320 | type: " POST", | |||||
| 321 | content Type: "app lication/j son; chars et=utf-8", | |||||
| 322 | datatyp e: "json", | |||||
| 323 | url: th is._ODataP ath() + ty pe + "Set( guid'" + i d + "')", | |||||
| 324 | beforeS end: funct ion (XMLHt tpRequest) { | |||||
| 325 | //Spec ifying thi s header e nsures tha t the resu lts will b e returned as JSON. | |||||
| 326 | XMLHtt pRequest.s etRequestH eader("Acc ept", "app lication/j son"); | |||||
| 327 | //Spec ify the HT TP method DELETE to perform a delete ope ration. | |||||
| 328 | XMLHtt pRequest.s etRequestH eader("X-H TTP-Method ", "DELETE "); | |||||
| 329 | }, | |||||
| 330 | success : function (data, te xtStatus, xhr) { | |||||
| 331 | // Noth ing is ret urned to t he success function. | |||||
| 332 | succes sCallback( ); | |||||
| 333 | }, | |||||
| 334 | error: function ( xhr, textS tatus, err orThrown) { | |||||
| 335 | errorC allback(SD K.JQuery._ errorHandl er(xhr)); | |||||
| 336 | } | |||||
| 337 | }); | |||||
| 338 | }, | |||||
| 339 | retrieveM ultipleRec ords: func tion (type , options, successCa llback, er rorCallbac k, OnCompl ete) { | |||||
| 340 | ///<summ ary> | |||||
| 341 | /// Send s an async hronous re quest to r etrieve re cords. | |||||
| 342 | ///</sum mary> | |||||
| 343 | ///<para m name="ty pe" type=" String"> | |||||
| 344 | /// The Schema Nam e of the E ntity type records t o retrieve | |||||
| 345 | /// For an Account record, u se "Accoun t" | |||||
| 346 | ///</par am> | |||||
| 347 | this._st ringParame terCheck(t ype, "SDK. JQuery.ret rieveMulti pleRecords requires the type p arameter i s a string ."); | |||||
| 348 | ///<para m name="op tions" typ e="String" > | |||||
| 349 | /// A St ring repre senting th e OData Sy stem Query Options t o control the data r eturned | |||||
| 350 | /// Do n ot include the $top option, us e the top parameters to set th e maximum number of records to return. | |||||
| 351 | ///</par am> | |||||
| 352 | if (opti ons != nul l) | |||||
| 353 | this._s tringParam eterCheck( options, " SDK.JQuery .retrieveM ultipleRec ords requi res the op tions para meter is a string.") ; | |||||
| 354 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 355 | /// The function t hat will b e passed t hrough and be called for each page of re cords retu rned. | |||||
| 356 | /// This function should loo p through the result s and push the recor ds into an array. | |||||
| 357 | /// </pa ram> | |||||
| 358 | this._ca llbackPara meterCheck (successCa llback, "S DK.JQuery. retrieveMu ltipleReco rds requir es the suc cessCallba ck paramet er is a fu nction."); | |||||
| 359 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 360 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 361 | /// This function must accep t an Error object as a paramet er. | |||||
| 362 | /// </pa ram> | |||||
| 363 | this._ca llbackPara meterCheck (errorCall back, "SDK .JQuery.re trieveMult ipleRecord s requires the error Callback p arameter i s a functi on."); | |||||
| 364 | ///<para m name="On Complete" type="Func tion"> | |||||
| 365 | /// The function t hat will b e called w hen all th e requeste d records have been returned. | |||||
| 366 | /// No p arameters are passed to this f unction. | |||||
| 367 | /// </pa ram> | |||||
| 368 | this._ca llbackPara meterCheck (OnComplet e, "SDK.JQ uery.retri eveMultipl eRecords r equires th e OnComple te paramet er is a fu nction."); | |||||
| 369 | ||||||
| 370 | var opti onsString; | |||||
| 371 | if (opti ons != nul l) { | |||||
| 372 | if (opt ions.charA t(0) != "? ") { | |||||
| 373 | option sString = "?" + opti ons; | |||||
| 374 | } | |||||
| 375 | else | |||||
| 376 | { optio nsString = options; } | |||||
| 377 | } | |||||
| 378 | ||||||
| 379 | $.ajax({ | |||||
| 380 | type: " GET", | |||||
| 381 | content Type: "app lication/j son; chars et=utf-8", | |||||
| 382 | datatyp e: "json", | |||||
| 383 | url: th is._ODataP ath() + ty pe + "Set" + options String, | |||||
| 384 | beforeS end: funct ion (XMLHt tpRequest) { | |||||
| 385 | //Spec ifying thi s header e nsures tha t the resu lts will b e returned as JSON. | |||||
| 386 | XMLHtt pRequest.s etRequestH eader("Acc ept", "app lication/j son"); | |||||
| 387 | }, | |||||
| 388 | success : function (data, te xtStatus, xhr) { | |||||
| 389 | if (da ta && data .d && data .d.results ) { | |||||
| 390 | succe ssCallback (JSON.pars e(xhr.resp onseText, SDK.JQuery ._dateRevi ver).d.res ults); | |||||
| 391 | if (d ata.d.__ne xt != null ) { | |||||
| 392 | var queryOptio ns = data. d.__next.s ubstring(( SDK.JQuery ._ODataPat h() + type + "Set"). length); | |||||
| 393 | SDK. JQuery.ret rieveMulti pleRecords (type, que ryOptions, successCa llback, er rorCallbac k, OnCompl ete); | |||||
| 394 | } | |||||
| 395 | else | |||||
| 396 | { OnC omplete(); } | |||||
| 397 | } | |||||
| 398 | }, | |||||
| 399 | error: function ( xhr, textS tatus, err orThrown) { | |||||
| 400 | errorC allback(SD K.JQuery._ errorHandl er(xhr)); | |||||
| 401 | } | |||||
| 402 | }); | |||||
| 403 | }, | |||||
| 404 | __namespa ce: true | |||||
| 405 | }; | |||||
| 406 | // </snipp etJQueryRE STDataOper ations.SDK .JQuery.js > |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.