Produced by Araxis Merge on 2/1/2017 2:57:02 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\SOAPForJScript\SOAPForJScript\Scripts | SDK.SOAPSample.Assign.js | Tue Dec 20 19:51:48 2016 UTC |
| 2 | Wed Feb 1 19:57:02 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 246 |
| 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 tSDK.SOAPS ample.Assi gn.js> | |||||
| 16 | if (typeof (SDK) == "undefined ") | |||||
| 17 | { SDK = { __namespac e: true }; } | |||||
| 18 | //This wil l establis h a more u nique name space for functions in this li brary. Thi s will red uce the | |||||
| 19 | // potenti al for fun ctions to be overwri tten due t o a duplic ate name w hen the li brary is l oaded. | |||||
| 20 | SDK.SOAPSa mples = { | |||||
| 21 | _getClien tUrl: func tion () { | |||||
| 22 | ///<summ ary> | |||||
| 23 | /// Retu rns the UR L for the SOAP endpo int using the contex t informat ion availa ble in the form | |||||
| 24 | /// or H TML Web re source. | |||||
| 25 | ///</sum mary | |||||
| 26 | var OrgS ervicePath = "/XRMSe rvices/201 1/Organiza tion.svc/w eb"; | |||||
| 27 | var clie ntUrl = "" ; | |||||
| 28 | if (type of GetGlob alContext == "functi on") { | |||||
| 29 | var con text = Get GlobalCont ext(); | |||||
| 30 | clientU rl = conte xt.getClie ntUrl(); | |||||
| 31 | } | |||||
| 32 | else { | |||||
| 33 | if (typ eof Xrm.Pa ge.context == "objec t") { | |||||
| 34 | client Url = Xrm. Page.conte xt.getClie ntUrl(); | |||||
| 35 | } | |||||
| 36 | else | |||||
| 37 | { throw new Error ("Unable t o access t he server URL"); } | |||||
| 38 | } | |||||
| 39 | ||||||
| 40 | return c lientUrl + OrgServic ePath; | |||||
| 41 | }, | |||||
| 42 | assignReq uest: func tion (Assi gnee, Targ et, Type, successCal lback, err orCallback ) { | |||||
| 43 | ///<summ ary> | |||||
| 44 | /// Send s the Assi gn Request | |||||
| 45 | ///</sum mary> | |||||
| 46 | this._pa rameterChe ck(Assigne e, "GUID", "The SDK. SOAPSample s.assignRe quest meth od Assigne e paramete r must be a string R epresentin g a GUID v alue."); | |||||
| 47 | ///<para m name="As signee" Ty pe="String "> | |||||
| 48 | /// The GUID repre senting th e System user that the record will be a ssigned to . | |||||
| 49 | ///</par am> | |||||
| 50 | this._pa rameterChe ck(Target, "GUID", " The SDK.SO APSamples. assignRequ est method Target pa rameter mu st be a st ring Repre senting a GUID value ."); | |||||
| 51 | ///<para m name="Ta rget" Type ="String"> | |||||
| 52 | /// The GUID repre senting th e user-own ed entity record tha t will be assigne to the Assig nee. | |||||
| 53 | ///</par am> | |||||
| 54 | this._pa rameterChe ck(Type, " String", " The SDK.SO APSamples. assignRequ est method Type para meter must be a stri ng value." ); | |||||
| 55 | Type = T ype.toLowe rCase(); | |||||
| 56 | ///<para m name="Ty pe" Type=" String"> | |||||
| 57 | /// The Logical na me of the user-owned entity. F or example , 'account '. | |||||
| 58 | ///</par am> | |||||
| 59 | if (succ essCallbac k != null) | |||||
| 60 | this._pa rameterChe ck(success Callback, "Function" , "The SDK .SOAPSampl es.assignR equest met hod succes sCallback parameter must be a function." ); | |||||
| 61 | ///<para m name="su ccessCallb ack" Type= "Function" > | |||||
| 62 | /// The function t o perform when an su ccessfult response i s returned . | |||||
| 63 | ///</par am> | |||||
| 64 | this._pa rameterChe ck(errorCa llback, "F unction", "The SDK.S OAPSamples .assignReq uest metho d errorCal lback para meter must be a func tion."); | |||||
| 65 | ///<para m name="er rorCallbac k" Type="F unction"> | |||||
| 66 | /// The function t o perform when an er ror is ret urned. | |||||
| 67 | ///</par am> | |||||
| 68 | //The re quest is s imply the soap envel ope captur ed by the SOAPLogger with vari ables adde d for the | |||||
| 69 | // value s passed. All quotat ions must be escaped to create valid JSc ript strin gs. | |||||
| 70 | var requ est = []; | |||||
| 71 | ||||||
| 72 | reque st.push("< s:Envelope xmlns:s=\ "http://sc hemas.xmls oap.org/so ap/envelop e/\">"); | |||||
| 73 | reque st.push("< s:Body>"); | |||||
| 74 | reque st.push("< Execute xm lns=\"http ://schemas .microsoft .com/xrm/2 011/Contra cts/Servic es\""); | |||||
| 75 | reque st.push(" xmlns:i=\" http://www .w3.org/20 01/XMLSche ma-instanc e\">"); | |||||
| 76 | reque st.push("< request i: type=\"b:A ssignReque st\""); | |||||
| 77 | reque st.push(" xmlns:a=\" http://sch emas.micro soft.com/x rm/2011/Co ntracts\"" ); | |||||
| 78 | reque st.push(" xmlns:b=\" http://sch emas.micro soft.com/c rm/2011/Co ntracts\"> "); | |||||
| 79 | reque st.push("< a:Paramete rs xmlns:c =\"http:// schemas.da tacontract .org/2004/ 07/System. Collection s.Generic\ ">"); | |||||
| 80 | reque st.push("< a:KeyValue PairOfstri nganyType> "); | |||||
| 81 | reque st.push("< c:key>Targ et</c:key> "); | |||||
| 82 | reque st.push("< c:value i: type=\"a:E ntityRefer ence\">"); | |||||
| 83 | reque st.push("< a:Id>" + t his._xmlEn code(Targe t) + "</a: Id>"); | |||||
| 84 | reque st.push("< a:LogicalN ame>" + th is._xmlEnc ode(Type) + "</a:Log icalName>" ); | |||||
| 85 | reque st.push("< a:Name i:n il=\"true\ " />"); | |||||
| 86 | reque st.push("< /c:value>" ); | |||||
| 87 | reque st.push("< /a:KeyValu ePairOfstr inganyType >"); | |||||
| 88 | reque st.push("< a:KeyValue PairOfstri nganyType> "); | |||||
| 89 | reque st.push("< c:key>Assi gnee</c:ke y>"); | |||||
| 90 | reque st.push("< c:value i: type=\"a:E ntityRefer ence\">"); | |||||
| 91 | reque st.push("< a:Id>" + t his._xmlEn code(Assig nee) + "</ a:Id>"); | |||||
| 92 | reque st.push("< a:LogicalN ame>system user</a:Lo gicalName> "); | |||||
| 93 | reque st.push("< a:Name i:n il=\"true\ " />"); | |||||
| 94 | reque st.push("< /c:value>" ); | |||||
| 95 | reque st.push("< /a:KeyValu ePairOfstr inganyType >"); | |||||
| 96 | reque st.push("< /a:Paramet ers>"); | |||||
| 97 | reque st.push("< a:RequestI d i:nil=\" true\" />" ); | |||||
| 98 | reque st.push("< a:RequestN ame>Assign </a:Reques tName>"); | |||||
| 99 | reque st.push("< /request>" ); | |||||
| 100 | reque st.push("< /Execute>" ); | |||||
| 101 | reque st.push("< /s:Body>") ; | |||||
| 102 | reque st.push("< /s:Envelop e>"); | |||||
| 103 | ||||||
| 104 | var req = new XMLH ttpRequest (); | |||||
| 105 | req.open ("POST", S DK.SOAPSam ples._getC lientUrl() , true) | |||||
| 106 | // Respo nses will return XML . It isn't possible to return JSON. | |||||
| 107 | req.setR equestHead er("Accept ", "applic ation/xml, text/xml, */*"); | |||||
| 108 | req.setR equestHead er("Conten t-Type", " text/xml; charset=ut f-8"); | |||||
| 109 | req.setR equestHead er("SOAPAc tion", "ht tp://schem as.microso ft.com/xrm /2011/Cont racts/Serv ices/IOrga nizationSe rvice/Exec ute"); | |||||
| 110 | req.onre adystatech ange = fun ction () { SDK.SOAPS amples.ass ignRespons e(req, suc cessCallba ck, errorC allback); }; | |||||
| 111 | req.send (request.j oin("")); | |||||
| 112 | ||||||
| 113 | }, | |||||
| 114 | assignRes ponse: fun ction (req , successC allback, e rrorCallba ck) { | |||||
| 115 | ///<summ ary> | |||||
| 116 | /// Reci eves the a ssign resp onse | |||||
| 117 | ///</sum mary> | |||||
| 118 | ///<para m name="re q" Type="X MLHttpRequ est"> | |||||
| 119 | /// The XMLHttpReq uest respo nse | |||||
| 120 | ///</par am> | |||||
| 121 | ///<para m name="su ccessCallb ack" Type= "Function" > | |||||
| 122 | /// The function t o perform when an su ccessfult response i s returned . | |||||
| 123 | /// For this messa ge no data is return ed so a su ccess call back is no t really n ecessary. | |||||
| 124 | ///</par am> | |||||
| 125 | ///<para m name="er rorCallbac k" Type="F unction"> | |||||
| 126 | /// The function t o perform when an er ror is ret urned. | |||||
| 127 | /// This function accepts a JScript er ror return ed by the _getError function | |||||
| 128 | ///</par am> | |||||
| 129 | if (r eq.readySt ate == 4) { | |||||
| 130 | r eq.onready statechang e = null; //avoids m emory leak s | |||||
| 131 | if (req .status == 200) { | |||||
| 132 | if (su ccessCallb ack != nul l) | |||||
| 133 | { succ essCallbac k(); } | |||||
| 134 | } | |||||
| 135 | else { | |||||
| 136 | errorC allback(SD K.SOAPSamp les._getEr ror(req.re sponseXML) ); | |||||
| 137 | } | |||||
| 138 | } | |||||
| 139 | }, | |||||
| 140 | _getError : function (faultXml ) { | |||||
| 141 | ///<summ ary> | |||||
| 142 | /// Pars es the WCF fault ret urned in t he event o f an error . | |||||
| 143 | ///</sum mary> | |||||
| 144 | ///<para m name="fa ultXml" Ty pe="XML"> | |||||
| 145 | /// The responseXM L property of the XM LHttpReque st respons e. | |||||
| 146 | ///</par am> | |||||
| 147 | var erro rMessage = "Unknown Error (Una ble to par se the fau lt)"; | |||||
| 148 | if (type of faultXm l == "obje ct") { | |||||
| 149 | try { | |||||
| 150 | var bo dyNode = f aultXml.fi rstChild.f irstChild; | |||||
| 151 | //Retr ieve the f ault node | |||||
| 152 | for (v ar i = 0; i < bodyNo de.childNo des.length ; i++) { | |||||
| 153 | var n ode = body Node.child Nodes[i]; | |||||
| 154 | ||||||
| 155 | //NOT E: This co mparison d oes not ha ndle the c ase where the XML na mespace ch anges | |||||
| 156 | if (" s:Fault" = = node.nod eName) { | |||||
| 157 | for (var j = 0 ; j < node .childNode s.length; j++) { | |||||
| 158 | var faultStri ngNode = n ode.childN odes[j]; | |||||
| 159 | if ("faultstr ing" == fa ultStringN ode.nodeNa me) { | |||||
| 160 | er rorMessage = faultSt ringNode.t extContent ; | |||||
| 161 | br eak; | |||||
| 162 | } | |||||
| 163 | } | |||||
| 164 | brea k; | |||||
| 165 | } | |||||
| 166 | } | |||||
| 167 | } | |||||
| 168 | catch ( e) { }; | |||||
| 169 | } | |||||
| 170 | return n ew Error(e rrorMessag e); | |||||
| 171 | }, | |||||
| 172 | _xmlEncod e: functio n (strInpu t) { | |||||
| 173 | var c; | |||||
| 174 | var XmlE ncode = '' ; | |||||
| 175 | ||||||
| 176 | if (strI nput == nu ll) { | |||||
| 177 | return null; | |||||
| 178 | } | |||||
| 179 | if (strI nput == '' ) { | |||||
| 180 | return ''; | |||||
| 181 | } | |||||
| 182 | ||||||
| 183 | for (var cnt = 0; cnt < strI nput.lengt h; cnt++) { | |||||
| 184 | c = str Input.char CodeAt(cnt ); | |||||
| 185 | ||||||
| 186 | if (((c > 96) && (c < 123)) || | |||||
| 187 | ((c > 64) && (c < 91)) || | |||||
| 188 | (c == 32) || | |||||
| 189 | ((c > 47) && (c < 58)) || | |||||
| 190 | (c == 46) || | |||||
| 191 | (c == 44) || | |||||
| 192 | (c == 45) || | |||||
| 193 | (c == 95)) { | |||||
| 194 | XmlEnc ode = XmlE ncode + St ring.fromC harCode(c) ; | |||||
| 195 | } | |||||
| 196 | else { | |||||
| 197 | XmlEnc ode = XmlE ncode + '& #' + c + ' ;'; | |||||
| 198 | } | |||||
| 199 | } | |||||
| 200 | ||||||
| 201 | return X mlEncode; | |||||
| 202 | }, | |||||
| 203 | _paramete rCheck: fu nction (pa rameter, t ype, error Message) { | |||||
| 204 | switch ( type) { | |||||
| 205 | case "S tring": | |||||
| 206 | if (ty peof param eter != "s tring") { | |||||
| 207 | throw new Error (errorMess age); | |||||
| 208 | } | |||||
| 209 | break; | |||||
| 210 | case "F unction": | |||||
| 211 | if (ty peof param eter != "f unction") { | |||||
| 212 | throw new Error (errorMess age); | |||||
| 213 | } | |||||
| 214 | break; | |||||
| 215 | case "E ntityFilte rs": | |||||
| 216 | var fo und = fals e; | |||||
| 217 | for (x in this.E ntityFilte rs) { | |||||
| 218 | if (t his.Entity Filters[x] == parame ter) { | |||||
| 219 | foun d = true; | |||||
| 220 | brea k; | |||||
| 221 | } | |||||
| 222 | } | |||||
| 223 | if (!f ound) { | |||||
| 224 | throw new Error (errorMess age); | |||||
| 225 | } | |||||
| 226 | break; | |||||
| 227 | case "B oolean": | |||||
| 228 | if (ty peof param eter != "b oolean") { | |||||
| 229 | throw new Error (errorMess age); | |||||
| 230 | } | |||||
| 231 | break; | |||||
| 232 | case "G UID": | |||||
| 233 | var re = new Reg Exp("[0-9a -fA-F]{8}\ -[0-9a-fA- F]{4}\-[0- 9a-fA-F]{4 }\-[0-9a-f A-F]{4}\-[ 0-9a-fA-F] {12}"); | |||||
| 234 | if (!( typeof par ameter == "string" & & re.test( parameter) )) { | |||||
| 235 | throw new Error (errorMess age); | |||||
| 236 | } | |||||
| 237 | ||||||
| 238 | break; | |||||
| 239 | default : | |||||
| 240 | throw new Error( "An invali d type par ameter val ue was pas sed to the SDK.MetaD ata._param eterCheck function." ); | |||||
| 241 | break; | |||||
| 242 | } | |||||
| 243 | }, | |||||
| 244 | __namespa ce: true | |||||
| 245 | }; | |||||
| 246 | // </snipp etSDK.SOAP Sample.Ass ign.js> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.