Produced by Araxis Merge on 5/9/2017 12:03:04 PM Eastern Daylight 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 | Tue May 9 16:03:04 2017 UTC | ||
| 2 | OSCIF_HEC_v1.4_Sprint23_build4_Apr_2017.zip\CRM_solutions\Managed\North52BPA_1_0_0_506_managed_2013_2015_2016..zip\WebResources | north52_javascriptsdkrest4776FC85-CEA2-E111-99B0-00155DF5B00D | Mon Sep 19 18:20:18 2016 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 490 |
| Removed | 0 | 0 |
| 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 | if (typeof (SDK) == "undefined ") | |||||
| 2 | { SDK = { __namespac e: true }; } | |||||
| 3 | SDK.REST = { | |||||
| 4 | _context: function () { | |||||
| 5 | ///<summ ary> | |||||
| 6 | /// Priv ate functi on to the context ob ject. | |||||
| 7 | ///</sum mary> | |||||
| 8 | ///<retu rns>Contex t</returns > | |||||
| 9 | if (type of GetGlob alContext != "undefi ned") | |||||
| 10 | { return GetGlobal Context(); } | |||||
| 11 | else { | |||||
| 12 | if (typ eof Xrm != "undefine d") { | |||||
| 13 | return Xrm.Page. context; | |||||
| 14 | } | |||||
| 15 | else | |||||
| 16 | { throw new Error ("Context is not ava ilable."); } | |||||
| 17 | } | |||||
| 18 | }, | |||||
| 19 | _getServe rUrl: func tion () { | |||||
| 20 | var crmServer Url = "Un known"; | |||||
| 21 | ||||||
| 22 | if (typeof th is._contex t().getCli entUrl != "undefined ") | |||||
| 23 | { | |||||
| 24 | crmServe rUrl = thi s._context ().getClie ntUrl(); | |||||
| 25 | } | |||||
| 26 | else | |||||
| 27 | { | |||||
| 28 | crmServ erUrl = th is._contex t().getSer verUrl(); | |||||
| 29 | crmServ erUrl = cr mServerUrl .replace(/ ^(http|htt ps):\/\/([ _a-zA-Z0-9 \-\.]+)(:( [0-9]{1,5} ))?/, wind ow.locatio n.protocol + "//" + window.loc ation.host ); | |||||
| 30 | crmServ erUrl = cr mServerUrl .replace(/ \/$/, ""); // remove trailing slash if a ny | |||||
| 31 | } | |||||
| 32 | ||||||
| 33 | return c rmServerUr l; | |||||
| 34 | ||||||
| 35 | }, | |||||
| 36 | _ODataPat h: functio n () { | |||||
| 37 | ///<summ ary> | |||||
| 38 | /// Priv ate functi on to retu rn the pat h to the R EST endpoi nt. | |||||
| 39 | ///</sum mary> | |||||
| 40 | ///<retu rns>String </returns> | |||||
| 41 | return t his._getSe rverUrl() + "/XRMSer vices/2011 /Organizat ionData.sv c/"; | |||||
| 42 | }, | |||||
| 43 | _errorHan dler: func tion (req) { | |||||
| 44 | ///<summ ary> | |||||
| 45 | /// Priv ate functi on return an Error o bject to t he errorCa llback | |||||
| 46 | ///</sum mary> | |||||
| 47 | ///<para m name="re q" type="X MLHttpRequ est"> | |||||
| 48 | /// The XMLHttpReq uest respo nse that r eturned an error. | |||||
| 49 | ///</par am> | |||||
| 50 | ///<retu rns>Error< /returns> | |||||
| 51 | //Error descriptio ns come fr om http:// support.mi crosoft.co m/kb/19362 5 | |||||
| 52 | if (req. status == 12029) | |||||
| 53 | { return new Error ("The atte mpt to con nect to th e server f ailed."); } | |||||
| 54 | if (req. status == 12007) | |||||
| 55 | { return new Error ("The serv er name co uld not be resolved. "); } | |||||
| 56 | var erro rText; | |||||
| 57 | try | |||||
| 58 | { errorText = JSON.par se(req.res ponseText) .error.mes sage.value ; } | |||||
| 59 | catch (e ) | |||||
| 60 | { errorText = req.resp onseText } | |||||
| 61 | ||||||
| 62 | return n ew Error(" Error : " + | |||||
| 63 | re q.status + ": " + | |||||
| 64 | re q.statusTe xt + ": " + errorTex t); | |||||
| 65 | }, | |||||
| 66 | _dateRevi ver: funct ion (key, value) { | |||||
| 67 | ///<summ ary> | |||||
| 68 | /// Priv ate functi on to conv ert matchi ng string values to Date objec ts. | |||||
| 69 | ///</sum mary> | |||||
| 70 | ///<para m name="ke y" type="S tring"> | |||||
| 71 | /// The key used t o identify the objec t property | |||||
| 72 | ///</par am> | |||||
| 73 | ///<para m name="va lue" type= "String"> | |||||
| 74 | /// The string val ue represe nting a da te | |||||
| 75 | ///</par am> | |||||
| 76 | var a; | |||||
| 77 | if (type of value = == 'string ') { | |||||
| 78 | a = /Da te\(([-+]? \d+)\)/.ex ec(value); | |||||
| 79 | if (a) { | |||||
| 80 | return new Date( parseInt(v alue.repla ce("/Date( ", "").rep lace(")/", ""), 10)) ; | |||||
| 81 | } | |||||
| 82 | } | |||||
| 83 | return v alue; | |||||
| 84 | }, | |||||
| 85 | _paramete rCheck: fu nction (pa rameter, m essage) { | |||||
| 86 | ///<summ ary> | |||||
| 87 | /// Priv ate functi on used to check whe ther requi red parame ters are n ull or und efined | |||||
| 88 | ///</sum mary> | |||||
| 89 | ///<para m name="pa rameter" t ype="Objec t"> | |||||
| 90 | /// The parameter to check; | |||||
| 91 | ///</par am> | |||||
| 92 | ///<para m name="me ssage" typ e="String" > | |||||
| 93 | /// The error mess age text t o include when the e rror is th rown. | |||||
| 94 | ///</par am> | |||||
| 95 | if ((typ eof parame ter === "u ndefined") || parame ter === nu ll) { | |||||
| 96 | throw n ew Error(m essage); | |||||
| 97 | } | |||||
| 98 | }, | |||||
| 99 | _stringPa rameterChe ck: functi on (parame ter, messa ge) { | |||||
| 100 | ///<summ ary> | |||||
| 101 | /// Priv ate functi on used to check whe ther requi red parame ters are n ull or und efined | |||||
| 102 | ///</sum mary> | |||||
| 103 | ///<para m name="pa rameter" t ype="Strin g"> | |||||
| 104 | /// The string par ameter to check; | |||||
| 105 | ///</par am> | |||||
| 106 | ///<para m name="me ssage" typ e="String" > | |||||
| 107 | /// The error mess age text t o include when the e rror is th rown. | |||||
| 108 | ///</par am> | |||||
| 109 | if (type of paramet er != "str ing") { | |||||
| 110 | throw n ew Error(m essage); | |||||
| 111 | } | |||||
| 112 | }, | |||||
| 113 | _callback ParameterC heck: func tion (call backParame ter, messa ge) { | |||||
| 114 | ///<summ ary> | |||||
| 115 | /// Priv ate functi on used to check whe ther requi red callba ck paramet ers are fu nctions | |||||
| 116 | ///</sum mary> | |||||
| 117 | ///<para m name="ca llbackPara meter" typ e="Functio n"> | |||||
| 118 | /// The callback p arameter t o check; | |||||
| 119 | ///</par am> | |||||
| 120 | ///<para m name="me ssage" typ e="String" > | |||||
| 121 | /// The error mess age text t o include when the e rror is th rown. | |||||
| 122 | ///</par am> | |||||
| 123 | if (type of callbac kParameter != "funct ion") { | |||||
| 124 | throw n ew Error(m essage); | |||||
| 125 | } | |||||
| 126 | }, | |||||
| 127 | createRec ord: funct ion (objec t, type, s uccessCall back, erro rCallback) { | |||||
| 128 | ///<summ ary> | |||||
| 129 | /// Send s an async hronous re quest to c reate a ne w record. | |||||
| 130 | ///</sum mary> | |||||
| 131 | ///<para m name="ob ject" type ="Object"> | |||||
| 132 | /// A Ja vaScript o bject with propertie s correspo nding to t he Schema name of | |||||
| 133 | /// enti ty attribu tes that a re valid f or create operations . | |||||
| 134 | ///</par am> | |||||
| 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 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 140 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 141 | /// This function can accept the retur ned record as a para meter. | |||||
| 142 | /// </pa ram> | |||||
| 143 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 144 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 145 | /// This function must accep t an Error object as a paramet er. | |||||
| 146 | /// </pa ram> | |||||
| 147 | this._pa rameterChe ck(object, "SDK.REST .createRec ord requir es the obj ect parame ter."); | |||||
| 148 | this._st ringParame terCheck(t ype, "SDK. REST.creat eRecord re quires the type para meter is a string.") ; | |||||
| 149 | this._ca llbackPara meterCheck (successCa llback, "S DK.REST.cr eateRecord requires the succes sCallback is a funct ion."); | |||||
| 150 | this._ca llbackPara meterCheck (errorCall back, "SDK .REST.crea teRecord r equires th e errorCal lback is a function. "); | |||||
| 151 | var req = new XMLH ttpRequest (); | |||||
| 152 | req.open ("POST", e ncodeURI(t his._OData Path() + t ype + "Set "), true); | |||||
| 153 | req.setR equestHead er("Accept ", "applic ation/json "); | |||||
| 154 | req.setR equestHead er("Conten t-Type", " applicatio n/json; ch arset=utf- 8"); | |||||
| 155 | req.onre adystatech ange = fun ction () { | |||||
| 156 | if (thi s.readySta te == 4 /* complete */) { | |||||
| 157 | if (th is.status == 201) { | |||||
| 158 | succe ssCallback (JSON.pars e(this.res ponseText, SDK.REST. _dateReviv er).d); | |||||
| 159 | } | |||||
| 160 | else { | |||||
| 161 | error Callback(S DK.REST._e rrorHandle r(this)); | |||||
| 162 | } | |||||
| 163 | } | |||||
| 164 | }; | |||||
| 165 | req.send (JSON.stri ngify(obje ct)); | |||||
| 166 | }, | |||||
| 167 | retrieveR ecord: fun ction (id, type, sel ect, expan d, success Callback, errorCallb ack) { | |||||
| 168 | ///<summ ary> | |||||
| 169 | /// Send s an async hronous re quest to r etrieve a record. | |||||
| 170 | ///</sum mary> | |||||
| 171 | ///<para m name="id " type="St ring"> | |||||
| 172 | /// A St ring repre senting th e GUID val ue for the record to retrieve. | |||||
| 173 | ///</par am> | |||||
| 174 | ///<para m name="ty pe" type=" String"> | |||||
| 175 | /// The Schema Nam e of the E ntity type record to retrieve. | |||||
| 176 | /// For an Account record, u se "Accoun t" | |||||
| 177 | ///</par am> | |||||
| 178 | ///<para m name="se lect" type ="String"> | |||||
| 179 | /// A St ring repre senting th e $select OData Syst em Query O ption to c ontrol whi ch | |||||
| 180 | /// attr ibutes wil l be retur ned. This is a comma separated list of A ttribute n ames that are valid for retrie ve. | |||||
| 181 | /// If n ull all pr operties f or the rec ord will b e returned | |||||
| 182 | ///</par am> | |||||
| 183 | ///<para m name="ex pand" type ="String"> | |||||
| 184 | /// A St ring repre senting th e $expand OData Syst em Query O ption valu e to contr ol which | |||||
| 185 | /// 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 | |||||
| 186 | /// If n ull no exp anded rela ted record s will be returned. | |||||
| 187 | ///</par am> | |||||
| 188 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 189 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 190 | /// This function must accep t the retu rned recor d as a par ameter. | |||||
| 191 | /// </pa ram> | |||||
| 192 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 193 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 194 | /// This function must accep t an Error object as a paramet er. | |||||
| 195 | /// </pa ram> | |||||
| 196 | this._st ringParame terCheck(i d, "SDK.RE ST.retriev eRecord re quires the id parame ter is a s tring."); | |||||
| 197 | this._st ringParame terCheck(t ype, "SDK. REST.retri eveRecord requires t he type pa rameter is a string. "); | |||||
| 198 | if (sele ct != null ) | |||||
| 199 | this._s tringParam eterCheck( select, "S DK.REST.re trieveReco rd require s the sele ct paramet er is a st ring."); | |||||
| 200 | if (expa nd != null ) | |||||
| 201 | this._s tringParam eterCheck( expand, "S DK.REST.re trieveReco rd require s the expa nd paramet er is a st ring."); | |||||
| 202 | this._ca llbackPara meterCheck (successCa llback, "S DK.REST.re trieveReco rd require s the succ essCallbac k paramete r is a fun ction."); | |||||
| 203 | this._ca llbackPara meterCheck (errorCall back, "SDK .REST.retr ieveRecord requires the errorC allback pa rameter is a functio n."); | |||||
| 204 | ||||||
| 205 | var syst emQueryOpt ions = ""; | |||||
| 206 | ||||||
| 207 | if (sele ct != null || expand != null) { | |||||
| 208 | systemQ ueryOption s = "?"; | |||||
| 209 | if (sel ect != nul l) { | |||||
| 210 | var se lectString = "$selec t=" + sele ct; | |||||
| 211 | if (ex pand != nu ll) { | |||||
| 212 | selec tString = selectStri ng + "," + expand; | |||||
| 213 | } | |||||
| 214 | system QueryOptio ns = syste mQueryOpti ons + sele ctString; | |||||
| 215 | } | |||||
| 216 | if (exp and != nul l) { | |||||
| 217 | system QueryOptio ns = syste mQueryOpti ons + "&$e xpand=" + expand; | |||||
| 218 | } | |||||
| 219 | } | |||||
| 220 | ||||||
| 221 | ||||||
| 222 | var req = new XMLH ttpRequest (); | |||||
| 223 | req.open ("GET", en codeURI(th is._ODataP ath() + ty pe + "Set( guid'" + i d + "')" + systemQue ryOptions) , true); | |||||
| 224 | req.setR equestHead er("Accept ", "applic ation/json "); | |||||
| 225 | req.setR equestHead er("Conten t-Type", " applicatio n/json; ch arset=utf- 8"); | |||||
| 226 | req.onre adystatech ange = fun ction () { | |||||
| 227 | if (thi s.readySta te == 4 /* complete */) { | |||||
| 228 | if (th is.status == 200) { | |||||
| 229 | succe ssCallback (JSON.pars e(this.res ponseText, SDK.REST. _dateReviv er).d); | |||||
| 230 | } | |||||
| 231 | else { | |||||
| 232 | error Callback(S DK.REST._e rrorHandle r(this)); | |||||
| 233 | } | |||||
| 234 | } | |||||
| 235 | }; | |||||
| 236 | req.send (); | |||||
| 237 | }, | |||||
| 238 | updateRec ord: funct ion (id, o bject, typ e, success Callback, errorCallb ack) { | |||||
| 239 | ///<summ ary> | |||||
| 240 | /// Send s an async hronous re quest to u pdate a re cord. | |||||
| 241 | ///</sum mary> | |||||
| 242 | ///<para m name="id " type="St ring"> | |||||
| 243 | /// A St ring repre senting th e GUID val ue for the record to retrieve. | |||||
| 244 | ///</par am> | |||||
| 245 | ///<para m name="ob ject" type ="Object"> | |||||
| 246 | /// A Ja vaScript o bject with propertie s correspo nding to t he Schema Names for | |||||
| 247 | /// enti ty attribu tes that a re valid f or update operations . | |||||
| 248 | ///</par am> | |||||
| 249 | ///<para m name="ty pe" type=" String"> | |||||
| 250 | /// The Schema Nam e of the E ntity type record to retrieve. | |||||
| 251 | /// For an Account record, u se "Accoun t" | |||||
| 252 | ///</par am> | |||||
| 253 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 254 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 255 | /// Noth ing will b e returned to this f unction. | |||||
| 256 | /// </pa ram> | |||||
| 257 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 258 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 259 | /// This function must accep t an Error object as a paramet er. | |||||
| 260 | /// </pa ram> | |||||
| 261 | this._st ringParame terCheck(i d, "SDK.RE ST.updateR ecord requ ires the i d paramete r."); | |||||
| 262 | this._pa rameterChe ck(object, "SDK.REST .updateRec ord requir es the obj ect parame ter."); | |||||
| 263 | this._st ringParame terCheck(t ype, "SDK. REST.updat eRecord re quires the type para meter."); | |||||
| 264 | this._ca llbackPara meterCheck (successCa llback, "S DK.REST.up dateRecord requires the succes sCallback is a funct ion."); | |||||
| 265 | this._ca llbackPara meterCheck (errorCall back, "SDK .REST.upda teRecord r equires th e errorCal lback is a function. "); | |||||
| 266 | var req = new XMLH ttpRequest (); | |||||
| 267 | ||||||
| 268 | req.open ("POST", e ncodeURI(t his._OData Path() + t ype + "Set (guid'" + id + "')") , true); | |||||
| 269 | req.setR equestHead er("Accept ", "applic ation/json "); | |||||
| 270 | req.setR equestHead er("Conten t-Type", " applicatio n/json; ch arset=utf- 8"); | |||||
| 271 | req.setR equestHead er("X-HTTP -Method", "MERGE"); | |||||
| 272 | req.onre adystatech ange = fun ction () { | |||||
| 273 | if (thi s.readySta te == 4 /* complete */) { | |||||
| 274 | if (th is.status == 204 || this.statu s == 1223) { | |||||
| 275 | succe ssCallback (); | |||||
| 276 | } | |||||
| 277 | else { | |||||
| 278 | error Callback(S DK.REST._e rrorHandle r(this)); | |||||
| 279 | } | |||||
| 280 | } | |||||
| 281 | }; | |||||
| 282 | req.send (JSON.stri ngify(obje ct)); | |||||
| 283 | }, | |||||
| 284 | deleteRec ord: funct ion (id, t ype, succe ssCallback , errorCal lback) { | |||||
| 285 | ///<summ ary> | |||||
| 286 | /// Send s an async hronous re quest to d elete a re cord. | |||||
| 287 | ///</sum mary> | |||||
| 288 | ///<para m name="id " type="St ring"> | |||||
| 289 | /// A St ring repre senting th e GUID val ue for the record to delete. | |||||
| 290 | ///</par am> | |||||
| 291 | ///<para m name="ty pe" type=" String"> | |||||
| 292 | /// The Schema Nam e of the E ntity type record to delete. | |||||
| 293 | /// For an Account record, u se "Accoun t" | |||||
| 294 | ///</par am> | |||||
| 295 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 296 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 297 | /// Noth ing will b e returned to this f unction. | |||||
| 298 | /// </pa ram> | |||||
| 299 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 300 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 301 | /// This function must accep t an Error object as a paramet er. | |||||
| 302 | /// </pa ram> | |||||
| 303 | this._st ringParame terCheck(i d, "SDK.RE ST.deleteR ecord requ ires the i d paramete r."); | |||||
| 304 | this._st ringParame terCheck(t ype, "SDK. REST.delet eRecord re quires the type para meter."); | |||||
| 305 | this._ca llbackPara meterCheck (successCa llback, "S DK.REST.de leteRecord requires the succes sCallback is a funct ion."); | |||||
| 306 | this._ca llbackPara meterCheck (errorCall back, "SDK .REST.dele teRecord r equires th e errorCal lback is a function. "); | |||||
| 307 | var req = new XMLH ttpRequest (); | |||||
| 308 | req.open ("POST", e ncodeURI(t his._OData Path() + t ype + "Set (guid'" + id + "')") , true); | |||||
| 309 | req.setR equestHead er("Accept ", "applic ation/json "); | |||||
| 310 | req.setR equestHead er("Conten t-Type", " applicatio n/json; ch arset=utf- 8"); | |||||
| 311 | req.setR equestHead er("X-HTTP -Method", "DELETE"); | |||||
| 312 | req.onre adystatech ange = fun ction () { | |||||
| 313 | ||||||
| 314 | if (thi s.readySta te == 4 /* complete */) { | |||||
| 315 | if (th is.status == 204 || this.statu s == 1223) { | |||||
| 316 | succe ssCallback (); | |||||
| 317 | } | |||||
| 318 | else { | |||||
| 319 | error Callback(S DK.REST._e rrorHandle r(this)); | |||||
| 320 | } | |||||
| 321 | } | |||||
| 322 | }; | |||||
| 323 | req.send (); | |||||
| 324 | ||||||
| 325 | }, | |||||
| 326 | retrieveM ultipleRec ords: func tion (type , options, successCa llback, er rorCallbac k, OnCompl ete) { | |||||
| 327 | ///<summ ary> | |||||
| 328 | /// Send s an async hronous re quest to r etrieve re cords. | |||||
| 329 | ///</sum mary> | |||||
| 330 | ///<para m name="ty pe" type=" String"> | |||||
| 331 | /// The Schema Nam e of the E ntity type record to retrieve. | |||||
| 332 | /// For an Account record, u se "Accoun t" | |||||
| 333 | ///</par am> | |||||
| 334 | ///<para m name="op tions" typ e="String" > | |||||
| 335 | /// A St ring repre senting th e OData Sy stem Query Options t o control the data r eturned | |||||
| 336 | ///</par am> | |||||
| 337 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 338 | /// The function t hat will b e passed t hrough and be called for each page of re cords retu rned. | |||||
| 339 | /// Each page is 5 0 records. If you ex pect that more than one page o f records will be re turned, | |||||
| 340 | /// this function should loo p through the result s and push the recor ds into an array out side of th e function . | |||||
| 341 | /// Use the OnComp lete event handler t o know whe n all the records ha ve been pr ocessed. | |||||
| 342 | /// </pa ram> | |||||
| 343 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 344 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 345 | /// This function must accep t an Error object as a paramet er. | |||||
| 346 | /// </pa ram> | |||||
| 347 | ///<para m name="On Complete" type="Func tion"> | |||||
| 348 | /// The function t hat will b e called w hen all th e requeste d records have been returned. | |||||
| 349 | /// No p arameters are passed to this f unction. | |||||
| 350 | /// </pa ram> | |||||
| 351 | this._st ringParame terCheck(t ype, "SDK. REST.retri eveMultipl eRecords r equires th e type par ameter is a string." ); | |||||
| 352 | if (opti ons != nul l) | |||||
| 353 | this._s tringParam eterCheck( options, " SDK.REST.r etrieveMul tipleRecor ds require s the opti ons parame ter is a s tring."); | |||||
| 354 | this._ca llbackPara meterCheck (successCa llback, "S DK.REST.re trieveMult ipleRecord s requires the succe ssCallback parameter is a func tion."); | |||||
| 355 | this._ca llbackPara meterCheck (errorCall back, "SDK .REST.retr ieveMultip leRecords requires t he errorCa llback par ameter is a function ."); | |||||
| 356 | this._ca llbackPara meterCheck (OnComplet e, "SDK.RE ST.retriev eMultipleR ecords req uires the OnComplete parameter is a func tion."); | |||||
| 357 | ||||||
| 358 | var opti onsString; | |||||
| 359 | if (opti ons != nul l) { | |||||
| 360 | if (opt ions.charA t(0) != "? ") { | |||||
| 361 | option sString = "?" + opti ons; | |||||
| 362 | } | |||||
| 363 | else | |||||
| 364 | { optio nsString = options; } | |||||
| 365 | } | |||||
| 366 | var req = new XMLH ttpRequest (); | |||||
| 367 | req.open ("GET", th is._ODataP ath() + ty pe + "Set" + options String, tr ue); | |||||
| 368 | req.setR equestHead er("Accept ", "applic ation/json "); | |||||
| 369 | req.setR equestHead er("Conten t-Type", " applicatio n/json; ch arset=utf- 8"); | |||||
| 370 | req.onre adystatech ange = fun ction () { | |||||
| 371 | if (thi s.readySta te == 4 /* complete */) { | |||||
| 372 | if (th is.status == 200) { | |||||
| 373 | var r eturned = JSON.parse (this.resp onseText, SDK.REST._ dateRevive r).d; | |||||
| 374 | succe ssCallback (returned. results); | |||||
| 375 | if (r eturned.__ next != nu ll) { | |||||
| 376 | var queryOptio ns = retur ned.__next .substring ((SDK.REST ._ODataPat h() + type + "Set"). length); | |||||
| 377 | SDK. REST.retri eveMultipl eRecords(t ype, query Options, s uccessCall back, erro rCallback, OnComplet e); | |||||
| 378 | } | |||||
| 379 | else | |||||
| 380 | { OnC omplete(); } | |||||
| 381 | } | |||||
| 382 | else { | |||||
| 383 | error Callback(S DK.REST._e rrorHandle r(this)); | |||||
| 384 | } | |||||
| 385 | } | |||||
| 386 | }; | |||||
| 387 | req.send (); | |||||
| 388 | }, | |||||
| 389 | associate Records: f unction (p arentId, p arentType, relations hipName, c hildId, ch ildType, s uccessCall back, erro rCallback) { | |||||
| 390 | this._st ringParame terCheck(p arentId, " SDK.REST.a ssociateRe cords requ ires the p arentId pa rameter is a string. "); | |||||
| 391 | ///<para m name="pa rentId" ty pe="String "> | |||||
| 392 | /// The Id of the record to be the par ent record in the re lationship | |||||
| 393 | /// </pa ram> | |||||
| 394 | ///<para m name="pa rentType" type="Stri ng"> | |||||
| 395 | /// The Schema Nam e of the E ntity type for the p arent reco rd. | |||||
| 396 | /// For an Account record, u se "Accoun t" | |||||
| 397 | /// </pa ram> | |||||
| 398 | ///<para m name="re lationship Name" type ="String"> | |||||
| 399 | /// The Schema Nam e of the E ntity Rela tionship t o use to a ssociate t he records . | |||||
| 400 | /// To a ssociate a ccount rec ords as a Parent acc ount, use "Reference daccount_p arent_acco unt" | |||||
| 401 | /// </pa ram> | |||||
| 402 | ///<para m name="ch ildId" typ e="String" > | |||||
| 403 | /// The Id of the record to be the chi ld record in the rel ationship | |||||
| 404 | /// </pa ram> | |||||
| 405 | ///<para m name="ch ildType" t ype="Strin g"> | |||||
| 406 | /// The Schema Nam e of the E ntity type for the c hild recor d. | |||||
| 407 | /// For an Account record, u se "Accoun t" | |||||
| 408 | /// </pa ram> | |||||
| 409 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 410 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 411 | /// Noth ing will b e returned to this f unction. | |||||
| 412 | /// </pa ram> | |||||
| 413 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 414 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 415 | /// This function must accep t an Error object as a paramet er. | |||||
| 416 | /// </pa ram> | |||||
| 417 | this._st ringParame terCheck(p arentType, "SDK.REST .associate Records re quires the parentTyp e paramete r is a str ing."); | |||||
| 418 | this._st ringParame terCheck(r elationshi pName, "SD K.REST.ass ociateReco rds requir es the rel ationshipN ame parame ter is a s tring."); | |||||
| 419 | this._st ringParame terCheck(c hildId, "S DK.REST.as sociateRec ords requi res the ch ildId para meter is a string.") ; | |||||
| 420 | this._st ringParame terCheck(c hildType, "SDK.REST. associateR ecords req uires the childType parameter is a strin g."); | |||||
| 421 | this._ca llbackPara meterCheck (successCa llback, "S DK.REST.as sociateRec ords requi res the su ccessCallb ack parame ter is a f unction.") ; | |||||
| 422 | this._ca llbackPara meterCheck (errorCall back, "SDK .REST.asso ciateRecor ds require s the erro rCallback parameter is a funct ion."); | |||||
| 423 | ||||||
| 424 | var req = new XMLH ttpRequest (); | |||||
| 425 | req.open ("POST", e ncodeURI(t his._OData Path() + p arentType + "Set(gui d'" + pare ntId + "') /$links/" + relation shipName), true); | |||||
| 426 | req.setR equestHead er("Accept ", "applic ation/json "); | |||||
| 427 | req.setR equestHead er("Conten t-Type", " applicatio n/json; ch arset=utf- 8"); | |||||
| 428 | req.onre adystatech ange = fun ction () { | |||||
| 429 | if (thi s.readySta te == 4 /* complete */) { | |||||
| 430 | if (th is.status == 204 || this.statu s == 1223) { | |||||
| 431 | succe ssCallback (); | |||||
| 432 | } | |||||
| 433 | else { | |||||
| 434 | error Callback(S DK.REST._e rrorHandle r(this)); | |||||
| 435 | } | |||||
| 436 | } | |||||
| 437 | }; | |||||
| 438 | var chil dEntityRef erence = { } | |||||
| 439 | childEnt ityReferen ce.uri = t his._OData Path() + " /" + child Type + "Se t(guid'" + childId + "')"; | |||||
| 440 | req.send (JSON.stri ngify(chil dEntityRef erence)); | |||||
| 441 | }, | |||||
| 442 | disassoci ateRecords : function (parentId , parentTy pe, relati onshipName , childId, successCa llback, er rorCallbac k) { | |||||
| 443 | this._st ringParame terCheck(p arentId, " SDK.REST.d isassociat eRecords r equires th e parentId parameter is a stri ng."); | |||||
| 444 | ///<para m name="pa rentId" ty pe="String "> | |||||
| 445 | /// The Id of the record to be the par ent record in the re lationship | |||||
| 446 | /// </pa ram> | |||||
| 447 | ///<para m name="pa rentType" type="Stri ng"> | |||||
| 448 | /// The Schema Nam e of the E ntity type for the p arent reco rd. | |||||
| 449 | /// For an Account record, u se "Accoun t" | |||||
| 450 | /// </pa ram> | |||||
| 451 | ///<para m name="re lationship Name" type ="String"> | |||||
| 452 | /// The Schema Nam e of the E ntity Rela tionship t o use to d isassociat e the reco rds. | |||||
| 453 | /// To d isassociat e account records as a Parent account, u se "Refere ncedaccoun t_parent_a ccount" | |||||
| 454 | /// </pa ram> | |||||
| 455 | ///<para m name="ch ildId" typ e="String" > | |||||
| 456 | /// The Id of the record to be disasso ciated as the child record in the relati onship | |||||
| 457 | /// </pa ram> | |||||
| 458 | ///<para m name="su ccessCallb ack" type= "Function" > | |||||
| 459 | /// The function t hat will b e passed t hrough and be called by a succ essful res ponse. | |||||
| 460 | /// Noth ing will b e returned to this f unction. | |||||
| 461 | /// </pa ram> | |||||
| 462 | ///<para m name="er rorCallbac k" type="F unction"> | |||||
| 463 | /// The function t hat will b e passed t hrough and be called by a fail ed respons e. | |||||
| 464 | /// This function must accep t an Error object as a paramet er. | |||||
| 465 | /// </pa ram> | |||||
| 466 | this._st ringParame terCheck(p arentType, "SDK.REST .disassoci ateRecords requires the parent Type param eter is a string."); | |||||
| 467 | this._st ringParame terCheck(r elationshi pName, "SD K.REST.dis associateR ecords req uires the relationsh ipName par ameter is a string." ); | |||||
| 468 | this._st ringParame terCheck(c hildId, "S DK.REST.di sassociate Records re quires the childId p arameter i s a string ."); | |||||
| 469 | this._ca llbackPara meterCheck (successCa llback, "S DK.REST.di sassociate Records re quires the successCa llback par ameter is a function ."); | |||||
| 470 | this._ca llbackPara meterCheck (errorCall back, "SDK .REST.disa ssociateRe cords requ ires the e rrorCallba ck paramet er is a fu nction."); | |||||
| 471 | ||||||
| 472 | var req = new XMLH ttpRequest (); | |||||
| 473 | req.open ("POST", e ncodeURI(t his._OData Path() + p arentType + "Set(gui d'" + pare ntId + "') /$links/" + relation shipName + "(guid'" + childId + "')"), t rue); | |||||
| 474 | req.setR equestHead er("Accept ", "applic ation/json "); | |||||
| 475 | req.setR equestHead er("Conten t-Type", " applicatio n/json; ch arset=utf- 8"); | |||||
| 476 | req.setR equestHead er("X-HTTP -Method", "DELETE"); | |||||
| 477 | req.onre adystatech ange = fun ction () { | |||||
| 478 | if (thi s.readySta te == 4 /* complete */) { | |||||
| 479 | if (th is.status == 204 || this.statu s == 1223) { | |||||
| 480 | succe ssCallback (); | |||||
| 481 | } | |||||
| 482 | else { | |||||
| 483 | error Callback(S DK.REST._e rrorHandle r(this)); | |||||
| 484 | } | |||||
| 485 | } | |||||
| 486 | }; | |||||
| 487 | req.send (); | |||||
| 488 | }, | |||||
| 489 | __namespa ce: true | |||||
| 490 | }; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.