Produced by Araxis Merge on 2/1/2017 2:56:57 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\FormScripts | SDK.DependentOptionSet.js | Tue Dec 20 19:51:48 2016 UTC |
| 2 | Wed Feb 1 19:56:57 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 167 |
| 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.Depen dentOption Set.js> | |||||
| 16 | ||||||
| 17 | //If the S DK namespa ce object is not def ined, crea te it. | |||||
| 18 | if (typeof (SDK) == "undefined ") | |||||
| 19 | { SDK = {} ; } | |||||
| 20 | // Create Namespace container for functi ons in thi s library; | |||||
| 21 | SDK.Depend entOptionS et = {}; | |||||
| 22 | SDK.Depend entOptionS et.init = function ( webResourc eName) { | |||||
| 23 | //Retriev e the XML Web Resour ce specifi ed by the parameter passed | |||||
| 24 | var clien tURL = Xrm .Page.cont ext.getCli entUrl(); | |||||
| 25 | ||||||
| 26 | var pathT oWR = clie ntURL + "/ WebResourc es/" + web ResourceNa me; | |||||
| 27 | var xhr = new XMLHt tpRequest( ); | |||||
| 28 | xhr.open( "GET", pat hToWR, tru e); | |||||
| 29 | xhr.setRe questHeade r("Content -Type", "t ext/xml"); | |||||
| 30 | xhr.onrea dystatecha nge = func tion () { SDK.Depend entOptionS et.complet eInitializ ation(xhr) ; }; | |||||
| 31 | xhr.send( ); | |||||
| 32 | }; | |||||
| 33 | SDK.Depend entOptionS et.complet eInitializ ation = fu nction (xh r) { | |||||
| 34 | if (xhr.r eadyState == 4 /* co mplete */) { | |||||
| 35 | if (x hr.status == 200) { | |||||
| 36 | x hr.onready statechang e = null; //avoids m emory leak s | |||||
| 37 | var JSC onfig = [] ; | |||||
| 38 | var Par entFields = xhr.resp onseXML.do cumentElem ent.getEle mentsByTag Name("Pare ntField"); | |||||
| 39 | for (va r i = 0; i < ParentF ields.leng th; i++) { | |||||
| 40 | var Pa rentField = ParentFi elds[i]; | |||||
| 41 | var ma pping = {} ; | |||||
| 42 | mappin g.parent = ParentFie ld.getAttr ibute("id" ); | |||||
| 43 | mappin g.dependen t = SDK.Ut il.selectS ingleNode( ParentFiel d, "Depend entField") .getAttrib ute("id"); | |||||
| 44 | mappin g.options = []; | |||||
| 45 | var op tions = SD K.Util.sel ectNodes(P arentField , "Option" ); | |||||
| 46 | for (v ar a = 0; a < option s.length; a++) { | |||||
| 47 | var o ption = {} ; | |||||
| 48 | optio n.value = options[a] .getAttrib ute("value "); | |||||
| 49 | optio n.showOpti ons = []; | |||||
| 50 | var o ptionsToSh ow = SDK.U til.select Nodes(opti ons[a], "S howOption" ); | |||||
| 51 | for ( var b = 0; b < optio nsToShow.l ength; b++ ) { | |||||
| 52 | var optionToSh ow = {}; | |||||
| 53 | opti onToShow.v alue = opt ionsToShow [b].getAtt ribute("va lue"); | |||||
| 54 | opti onToShow.t ext = opti onsToShow[ b].getAttr ibute("lab el"); | |||||
| 55 | opti on.showOpt ions.push( optionToSh ow); | |||||
| 56 | } | |||||
| 57 | mappi ng.options .push(opti on); | |||||
| 58 | } | |||||
| 59 | JSConf ig.push(ma pping); | |||||
| 60 | } | |||||
| 61 | //Attac h the conf iguration object to DependentO ptionSet | |||||
| 62 | //so it will be a vailable f or the OnC hange even ts | |||||
| 63 | SDK.Dep endentOpti onSet.conf ig = JSCon fig; | |||||
| 64 | //Fire the onchan ge event f or the map ped option set fields | |||||
| 65 | // so t hat the de pendent fi elds are f iltered fo r the curr ent values . | |||||
| 66 | for (va r depOptio nSet in SD K.Dependen tOptionSet .config) { | |||||
| 67 | var pa rent = SDK .Dependent OptionSet. config[dep OptionSet] .parent; | |||||
| 68 | Xrm.Pa ge.data.en tity.attri butes.get( parent).fi reOnChange (); | |||||
| 69 | } | |||||
| 70 | } | |||||
| 71 | } | |||||
| 72 | }; | |||||
| 73 | // This i s the func tion set o n the onch ange event for | |||||
| 74 | // parent fields | |||||
| 75 | SDK.Depend entOptionS et.filterD ependentFi eld = func tion (pare ntField, c hildField) { | |||||
| 76 | for (var depOptionS et in SDK. DependentO ptionSet.c onfig) { | |||||
| 77 | var Depe ndentOptio nSet = SDK .Dependent OptionSet. config[dep OptionSet] ; | |||||
| 78 | /* Match the param eters to t he correct dependent optionset mapping*/ | |||||
| 79 | if ((Dep endentOpti onSet.pare nt == pare ntField) & & (Depende ntOptionSe t.dependen t == child Field)) { | |||||
| 80 | /* Get references to the re lated fiel ds*/ | |||||
| 81 | var Par entField = Xrm.Page. data.entit y.attribut es.get(par entField); | |||||
| 82 | var Chi ldField = Xrm.Page.d ata.entity .attribute s.get(chil dField); | |||||
| 83 | /* Capt ure the cu rrent valu e of the c hild field */ | |||||
| 84 | var Cur rentChildF ieldValue = ChildFie ld.getValu e(); | |||||
| 85 | /* If t he parent field is n ull the Ch ild field can be set to null * / | |||||
| 86 | if (Par entField.g etValue() == null) { | |||||
| 87 | ChildF ield.setVa lue(null); | |||||
| 88 | ChildF ield.setSu bmitMode(" always"); | |||||
| 89 | ChildF ield.fireO nChange(); | |||||
| 90 | ||||||
| 91 | // Any attribute may have any number of contro ls | |||||
| 92 | // So disable ea ch instanc e | |||||
| 93 | var co ntrols = C hildField. controls.g et() | |||||
| 94 | ||||||
| 95 | for (v ar ctrl in controls) { | |||||
| 96 | contr ols[ctrl]. setDisable d(true); | |||||
| 97 | } | |||||
| 98 | return ; | |||||
| 99 | } | |||||
| 100 | ||||||
| 101 | for (va r os in De pendentOpt ionSet.opt ions) { | |||||
| 102 | var Op tions = De pendentOpt ionSet.opt ions[os]; | |||||
| 103 | var op tionsToSho w = Option s.showOpti ons; | |||||
| 104 | /* Fin d the Opti ons that c orresponds to the va lue of the parent fi eld. */ | |||||
| 105 | if (Pa rentField. getValue() == Option s.value) { | |||||
| 106 | var c ontrols = ChildField .controls. get(); | |||||
| 107 | /*Ena ble the fi eld and se t the opti ons*/ | |||||
| 108 | for ( var ctrl i n controls ) { | |||||
| 109 | cont rols[ctrl] .setDisabl ed(false); | |||||
| 110 | cont rols[ctrl] .clearOpti ons(); | |||||
| 111 | ||||||
| 112 | for (var optio n in optio nsToShow) { | |||||
| 113 | con trols[ctrl ].addOptio n(optionsT oShow[opti on]); | |||||
| 114 | } | |||||
| 115 | ||||||
| 116 | } | |||||
| 117 | /*Che ck whether the curre nt value i s valid*/ | |||||
| 118 | var b CurrentVal ueIsValid = false; | |||||
| 119 | var C hildFieldO ptions = o ptionsToSh ow; | |||||
| 120 | ||||||
| 121 | for ( var validO ptionIndex in ChildF ieldOption s) { | |||||
| 122 | var OptionData Value = Ch ildFieldOp tions[vali dOptionInd ex].value; | |||||
| 123 | ||||||
| 124 | if ( CurrentChi ldFieldVal ue == Opti onDataValu e) { | |||||
| 125 | bCu rrentValue IsValid = true; | |||||
| 126 | bre ak; | |||||
| 127 | } | |||||
| 128 | } | |||||
| 129 | /* | |||||
| 130 | If th e value is valid, se t it. | |||||
| 131 | If no t, set the child fie ld to null | |||||
| 132 | */ | |||||
| 133 | if (b CurrentVal ueIsValid) { | |||||
| 134 | Chil dField.set Value(Curr entChildFi eldValue); | |||||
| 135 | } | |||||
| 136 | else { | |||||
| 137 | Chil dField.set Value(null ); | |||||
| 138 | } | |||||
| 139 | Child Field.setS ubmitMode( "always"); | |||||
| 140 | Child Field.fire OnChange() ; | |||||
| 141 | break ; | |||||
| 142 | } | |||||
| 143 | } | |||||
| 144 | } | |||||
| 145 | } | |||||
| 146 | }; | |||||
| 147 | ||||||
| 148 | SDK.Util = {}; | |||||
| 149 | //Helper m ethods to merge diff erences be tween brow sers for t his sample | |||||
| 150 | SDK.Util. selectSing leNode = f unction (n ode, eleme ntName) { | |||||
| 151 | if (type of (node.s electSingl eNode) != "undefined ") { | |||||
| 152 | return node.selec tSingleNod e(elementN ame); | |||||
| 153 | } | |||||
| 154 | else { | |||||
| 155 | return node.getEl ementsByTa gName(elem entName)[0 ]; | |||||
| 156 | } | |||||
| 157 | }; | |||||
| 158 | SDK.Util. selectNode s = functi on (node, elementNam e) { | |||||
| 159 | if (type of (node.s electNodes ) != "unde fined") { | |||||
| 160 | return node.selec tNodes(ele mentName); | |||||
| 161 | } | |||||
| 162 | else { | |||||
| 163 | return node.getEl ementsByTa gName(elem entName); | |||||
| 164 | } | |||||
| 165 | }; | |||||
| 166 | ||||||
| 167 | // </snipp etSDK.Depe ndentOptio nSet.js> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.