Produced by Araxis Merge on 2/1/2017 2:56:58 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\JavaScriptRESTDataOperations\JavaScriptRESTDataOperations\Scripts | JavaScriptRESTDataOperationsSample.js | Tue Dec 20 19:51:48 2016 UTC |
| 2 | Wed Feb 1 19:56:58 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 214 |
| 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 | ||||||
| 16 | /// <refer ence path= "SDK.REST. js" /> | |||||
| 17 | ||||||
| 18 | //<snippet JavaScript RESTDataOp erationsSa mpleJS> | |||||
| 19 | var primar yContact = null; | |||||
| 20 | var startB utton; | |||||
| 21 | var resetB utton; | |||||
| 22 | var output ; //The <o l> element used by t he writeMe ssage func tion to di splay text showing t he progres s of this sample. | |||||
| 23 | ||||||
| 24 | document.o nreadystat echange = function ( ) { | |||||
| 25 | if (docum ent.readyS tate == "c omplete") { | |||||
| 26 | getFirst ContactToB ePrimaryCo ntact(); | |||||
| 27 | ||||||
| 28 | startBut ton = docu ment.getEl ementById( "start"); | |||||
| 29 | resetBut ton = docu ment.getEl ementById( "reset"); | |||||
| 30 | output = document. getElement ById("outp ut"); | |||||
| 31 | ||||||
| 32 | startBut ton.onclic k = create Account; | |||||
| 33 | resetBut ton.onclic k = resetS ample; | |||||
| 34 | } | |||||
| 35 | } | |||||
| 36 | ||||||
| 37 | function c reateAccou nt() { | |||||
| 38 | var accou nt = {}; | |||||
| 39 | account.N ame = "Tes t Account Name"; | |||||
| 40 | account.D escription = "This a ccount was created b y the Java ScriptREST DataOperat ions sampl e."; | |||||
| 41 | if (prima ryContact != null) { | |||||
| 42 | //Set a lookup val ue | |||||
| 43 | writeMes sage("Sett ing the pr imary cont act to: " + primaryC ontact.Ful lName + ". "); | |||||
| 44 | account. PrimaryCon tactId = { Id: prima ryContact. ContactId, LogicalNa me: "conta ct", Name: primaryCo ntact.Full Name }; | |||||
| 45 | ||||||
| 46 | } | |||||
| 47 | //Set a p icklist va lue | |||||
| 48 | writeMess age("Setti ng Preferr ed Contact Method to E-mail.") ; | |||||
| 49 | account.P referredCo ntactMetho dCode = { Value: 2 } ; //E-mail | |||||
| 50 | ||||||
| 51 | //Set a m oney value | |||||
| 52 | writeMess age("Setti ng Annual Revenue to Two Milli on ."); | |||||
| 53 | account.R evenue = { Value: "2 000000.00" }; //Set Annual Rev enue | |||||
| 54 | ||||||
| 55 | //Set a B oolean val ue | |||||
| 56 | writeMess age("Setti ng Contact Method Ph one to \"D o Not Allo w\"."); | |||||
| 57 | account.D oNotPhone = true; // Do Not All ow | |||||
| 58 | ||||||
| 59 | //Add Two Tasks | |||||
| 60 | var today = new Dat e(); | |||||
| 61 | var start Date = new Date(toda y.getFullY ear(), tod ay.getMont h(), today .getDate() + 3); //S et a date three days in the fu ture. | |||||
| 62 | ||||||
| 63 | var LowPr iTask = { Subject: " Low Priori ty Task", ScheduledS tart: star tDate, Pri orityCode: { Value: 0} }; //Lo w Priority Task | |||||
| 64 | var HighP riTask = { Subject: "High Prio rity Task" , Schedule dStart: st artDate, P riorityCod e: { Value : 2} }; // High Prior ity Task | |||||
| 65 | account.A ccount_Tas ks = [LowP riTask, Hi ghPriTask] | |||||
| 66 | ||||||
| 67 | ||||||
| 68 | ||||||
| 69 | //Create the Accoun t | |||||
| 70 | SDK.REST. createReco rd( | |||||
| 71 | accou nt, | |||||
| 72 | "Acco unt", | |||||
| 73 | funct ion (accou nt) { | |||||
| 74 | writ eMessage(" The accoun t named \" " + accoun t.Name + " \" was cre ated with the Accoun tId : \"" + account. AccountId + "\"."); | |||||
| 75 | writ eMessage(" Retrieving account w ith the Ac countId: \ "" + accou nt.Account Id + "\"." ); | |||||
| 76 | retr ieveAccoun t(account. AccountId) | |||||
| 77 | }, | |||||
| 78 | error Handler | |||||
| 79 | ); | |||||
| 80 | this.setA ttribute(" disabled", "disabled "); | |||||
| 81 | } | |||||
| 82 | ||||||
| 83 | function r etrieveAcc ount(Accou ntId) { | |||||
| 84 | SDK.REST. retrieveRe cord( | |||||
| 85 | Accou ntId, | |||||
| 86 | "Acco unt", | |||||
| 87 | null, null, | |||||
| 88 | funct ion (accou nt) { | |||||
| 89 | writ eMessage(" Retrieved the accoun t named \" " + accoun t.Name + " \". This a ccount was created o n : \"" + account.Cr eatedOn + "\"."); | |||||
| 90 | upda teAccount( AccountId) ; | |||||
| 91 | }, | |||||
| 92 | error Handler | |||||
| 93 | ); | |||||
| 94 | } | |||||
| 95 | ||||||
| 96 | function u pdateAccou nt(Account Id) { | |||||
| 97 | var accou nt = {}; | |||||
| 98 | writeMess age("Chang ing the ac count Name to \"Upda ted Accoun t Name\"." ); | |||||
| 99 | account.N ame = "Upd ated Accou nt Name"; | |||||
| 100 | writeMess age("Addin g Address informatio n"); | |||||
| 101 | account.A ddress1_Ad dressTypeC ode = { Va lue: 3 }; //Address 1: Address Type = Pr imary | |||||
| 102 | account.A ddress1_Ci ty = "Samm amish"; | |||||
| 103 | account.A ddress1_Li ne1 = "123 Maple St. "; | |||||
| 104 | account.A ddress1_Po stalCode = "98074"; | |||||
| 105 | account.A ddress1_St ateOrProvi nce = "WA" ; | |||||
| 106 | writeMess age("Setti ng E-Mail address"); | |||||
| 107 | account.E MailAddres s1 = "some one@micros oft.com"; | |||||
| 108 | ||||||
| 109 | ||||||
| 110 | SDK.REST. updateReco rd( | |||||
| 111 | Accou ntId, | |||||
| 112 | accou nt, | |||||
| 113 | "Acco unt", | |||||
| 114 | funct ion () { | |||||
| 115 | writ eMessage(" The accoun t record c hanges wer e saved"); | |||||
| 116 | dele teAccount( AccountId) ; | |||||
| 117 | }, | |||||
| 118 | error Handler | |||||
| 119 | ); | |||||
| 120 | } | |||||
| 121 | ||||||
| 122 | function d eleteAccou nt(Account Id) { | |||||
| 123 | if (confi rm("Do you want to d elete this account r ecord?")) { | |||||
| 124 | writeMes sage("You chose to d elete the account re cord."); | |||||
| 125 | SDK.REST .deleteRec ord( | |||||
| 126 | Acc ountId, | |||||
| 127 | "Ac count", | |||||
| 128 | fun ction () { | |||||
| 129 | wr iteMessage ("The acco unt was de leted."); | |||||
| 130 | en ableResetB utton(); | |||||
| 131 | }, | |||||
| 132 | err orHandler | |||||
| 133 | ); | |||||
| 134 | } | |||||
| 135 | else { | |||||
| 136 | var li = document. createElem ent("li"); | |||||
| 137 | ||||||
| 138 | var span = documen t.createEl ement("spa n"); | |||||
| 139 | ||||||
| 140 | setEleme ntText(spa n, "You ch ose not to delete th e record. You can vi ew the rec ord "); | |||||
| 141 | ||||||
| 142 | ||||||
| 143 | var link = documen t.createEl ement("a") ; | |||||
| 144 | link.hre f = SDK.RE ST._getCli entUrl() + "/main.as px?etc=1&i d=%7b" + A ccountId + "%7d&page type=entit yrecord"; | |||||
| 145 | link.tar get = "_bl ank"; | |||||
| 146 | setEleme ntText(lin k, "here") ; | |||||
| 147 | ||||||
| 148 | ||||||
| 149 | li.appen dChild(spa n); | |||||
| 150 | li.appen dChild(lin k); | |||||
| 151 | output.a ppendChild (li); | |||||
| 152 | enableRe setButton( ); | |||||
| 153 | ||||||
| 154 | } | |||||
| 155 | } | |||||
| 156 | ||||||
| 157 | function g etFirstCon tactToBePr imaryConta ct() { | |||||
| 158 | ||||||
| 159 | SDK.REST. retrieveMu ltipleReco rds( | |||||
| 160 | "Cont act", | |||||
| 161 | "$sel ect=Contac tId,FullNa me&$top=1" , | |||||
| 162 | funct ion (resul ts) { | |||||
| 163 | var firstResul t = result s[0]; | |||||
| 164 | if ( firstResul t != null) { | |||||
| 165 | pri maryContac t = result s[0]; | |||||
| 166 | } | |||||
| 167 | else { | |||||
| 168 | wri teMessage( "No Contac t records are availa ble to set as the pr imary cont act for th e account. "); | |||||
| 169 | } | |||||
| 170 | }, | |||||
| 171 | error Handler, | |||||
| 172 | funct ion () { | |||||
| 173 | //OnC omplete ha ndler | |||||
| 174 | } | |||||
| 175 | ); | |||||
| 176 | } | |||||
| 177 | ||||||
| 178 | function e rrorHandle r(error) { | |||||
| 179 | writeMess age(error. message); | |||||
| 180 | } | |||||
| 181 | ||||||
| 182 | function e nableReset Button() { | |||||
| 183 | resetButt on.removeA ttribute(" disabled") ; | |||||
| 184 | } | |||||
| 185 | ||||||
| 186 | function r esetSample () { | |||||
| 187 | output.in nerHTML = ""; | |||||
| 188 | startButt on.removeA ttribute(" disabled") ; | |||||
| 189 | resetButt on.setAttr ibute("dis abled", "d isabled"); | |||||
| 190 | } | |||||
| 191 | ||||||
| 192 | //Helper f unction to write dat a to this page: | |||||
| 193 | function w riteMessag e(message) { | |||||
| 194 | va r li = doc ument.crea teElement( "li"); | |||||
| 195 | ||||||
| 196 | se tElementTe xt(li, mes sage); | |||||
| 197 | ||||||
| 198 | ||||||
| 199 | output.ap pendChild( li); | |||||
| 200 | } | |||||
| 201 | //Because Firefox do esn't sup port inner Text | |||||
| 202 | function s etElementT ext(elemen t, text) | |||||
| 203 | { | |||||
| 204 | if (element. innerText != undefin ed) | |||||
| 205 | { | |||||
| 206 | elem ent.innerT ext = text ; | |||||
| 207 | } | |||||
| 208 | el se | |||||
| 209 | { | |||||
| 210 | elem ent.textCo ntent = te xt; | |||||
| 211 | } | |||||
| 212 | } | |||||
| 213 | ||||||
| 214 | //</snippe tJavaScrip tRESTDataO perationsS ampleJS> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.