Produced by Araxis Merge on 12/4/2017 8:32:35 AM Central 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 | VCCM.zip\VCCM\CRM_solutions\VCCMResources\VCCMResources_1_0_0_19.zip\WebResources | ftp_RequestJScriptrequest_GetSurrogatejs38E9D3A0-104D-E711-944F-0050568D743D | Wed Aug 9 01:02:16 2017 UTC |
| 2 | VCCM.zip\VCCM\CRM_solutions\VCCMResources\VCCMResources_1_0_0_19.zip\WebResources | ftp_RequestJScriptrequest_GetSurrogatejs38E9D3A0-104D-E711-944F-0050568D743D | Thu Nov 30 17:19:51 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1180 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| 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 | //request_ GetSurroga te.js | |
| 2 | //Contains functions used on t he request form to r etrieve VI A surrogat e data | |
| 3 | //Requires jQuery lo aded on th e CRM Form | |
| 4 | ||
| 5 | //Static V ariables | |
| 6 | var rgs_cr mOdataEndP oint = '/X RMServices /2011/Orga nizationDa ta.svc'; | |
| 7 | var rgs_se rverUrl = Xrm.Page.c ontext.get ClientUrl( ); | |
| 8 | ||
| 9 | //var rgs_ GetSurroga teUrl = 'h ttps://qac rmdac.np.c rm.vrm.vba . DNS /WebParts/ DEV/api/VI A/surrogat e/1.0/json '; //OLD MANU AL DEV URL | |
| 10 | var rgs_Ge tSurrogate Url = ''; | |
| 11 | var rgs_ba seServiceE ndpointUrl = null; | |
| 12 | var rgs_re questingAp p = null; | |
| 13 | var rgs_co nsumingApp Token = nu ll; | |
| 14 | var rgs_co nsumingApp Password = null; | |
| 15 | ||
| 16 | //Required function, used by L ogin Contr ol | |
| 17 | function v cmn_initVi aDropdownC ontrols() { | |
| 18 | //Func tion is tr iggered by The VistA Login Con trol | |
| 19 | try { | |
| 20 | // Not used f or this en tity form, but must exist here . | |
| 21 | } | |
| 22 | catch (err) { | |
| 23 | al ert('Reque st Surroga te VIA Log in Functio n Error(vc mn_initVia DropdownCo ntrols): ' + err.mes sage); | |
| 24 | } | |
| 25 | } | |
| 26 | ||
| 27 | function r gs_getSurr ogate() { | |
| 28 | try { | |
| 29 | Xr m.Page.ui. clearFormN otificatio n("SURR100 1"); | |
| 30 | // If selecte d user is null, then exit | |
| 31 | va r rgs_user SelectedVa lue = Xrm. Page.getAt tribute("f tp_usersel ected").ge tValue(); | |
| 32 | if (rgs_user SelectedVa lue == nul l) { | |
| 33 | return f alse; | |
| 34 | } | |
| 35 | ||
| 36 | // Turn on Su rrogate Pr ocessing M essage.... . | |
| 37 | Xr m.Page.ui. setFormNot ification( "Checking for VIA Su rrogates f or the ass igned user , please w ait..", "I NFO", "SUR R1001"); | |
| 38 | ||
| 39 | // GET CRM SE TTINGS WEB SERVICE U RLS | |
| 40 | va r rgs_cond itionalFil ter = "(mc s_name eq 'Active Se ttings')"; | |
| 41 | rg s_getMulti pleEntityD ataAsync(' mcs_settin gSet', 'ft p_DACURL, ftp_VIASur rogateURL, ftp_IsPro ductionEnv ironment, ftp_VIASer viceBaseUR L, ftp_VIA Requesting Applicatio nCode, ftp _VIAConsum ingApplica tionToken, ftp_VIACo nsumingApp licationPa ssword', r gs_conditi onalFilter , 'mcs_nam e', 'asc', 0, rgs_vi aSurrogate Setting_re sponse); | |
| 42 | } | |
| 43 | catch (err) { | |
| 44 | al ert('Reque st Surroga te Functio n Error(rg s_getSurro gate): ' + err.messa ge); | |
| 45 | Xr m.Page.ui. clearFormN otificatio n("SURR100 1"); | |
| 46 | } | |
| 47 | } | |
| 48 | ||
| 49 | function r gs_viaSurr ogateSetti ng_respons e(rgs_sett ingData, r gs_lastSki p) { | |
| 50 | try { | |
| 51 | // rgs_lastSk ip is the starting p oint in th e result ( use if mor e than 50 records) / /Not used in this sc enario | |
| 52 | va r rgs_DacU rl = null; | |
| 53 | va r rgs_ViaS urrogateAp iUrl = nul l; | |
| 54 | fo r (var i = 0; i <= r gs_setting Data.d.res ults.lengt h - 1; i++ ) { | |
| 55 | //Get in fo | |
| 56 | if (rgs_ settingDat a.d.result s[i].ftp_D ACURL != n ull) { rgs _DacUrl = rgs_settin gData.d.re sults[i].f tp_DACURL; } | |
| 57 | if (rgs_ settingDat a.d.result s[i].ftp_V IASurrogat eURL != nu ll) { rgs_ ViaSurroga teApiUrl = rgs_setti ngData.d.r esults[i]. ftp_VIASur rogateURL; } | |
| 58 | if (rgs_ settingDat a.d.result s[i].ftp_V IAServiceB aseURL != null) { rg s_baseServ iceEndpoin tUrl = rgs _settingDa ta.d.resul ts[i].ftp_ VIAService BaseURL; } | |
| 59 | if (rgs_ settingDat a.d.result s[i].ftp_V IARequesti ngApplicat ionCode != null) { r gs_request ingApp = r gs_setting Data.d.res ults[i].ft p_VIAReque stingAppli cationCode ; } | |
| 60 | if (rgs_ settingDat a.d.result s[i].ftp_V IAConsumin gApplicati onToken != null) { r gs_consumi ngAppToken = rgs_set tingData.d .results[i ].ftp_VIAC onsumingAp plicationT oken; } | |
| 61 | if (rgs_ settingDat a.d.result s[i].ftp_V IAConsumin gApplicati onPassword != null) { rgs_cons umingAppPa ssword = r gs_setting Data.d.res ults[i].ft p_VIAConsu mingApplic ationPassw ord; } | |
| 62 | break; | |
| 63 | } | |
| 64 | if (rgs_DacU rl != null && rgs_Vi aSurrogate ApiUrl != null) { | |
| 65 | //Constr uct full w eb service URL | |
| 66 | rgs_GetS urrogateUr l = rgs_Da cUrl + rgs _ViaSurrog ateApiUrl; | |
| 67 | } | |
| 68 | el se { | |
| 69 | Xrm.Page .ui.setFor mNotificat ion("ERROR : THE VIA GET SURROG ATE SERVIC E URL IS M ISSING, PL EASE CONTA CT TECHNIC AL SUPPORT !", "ERROR ", "VISTAS ERVICE"); | |
| 70 | //Exit p rocess, cl ear notifi cation mes sage | |
| 71 | Xrm.Page .ui.clearF ormNotific ation("SUR R1001"); | |
| 72 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setVal ue(null); | |
| 73 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setSub mitMode('a lways'); | |
| 74 | return f alse; | |
| 75 | } | |
| 76 | if (rgs_base ServiceEnd pointUrl = = null || rgs_reques tingApp == null || r gs_consumi ngAppToken == null | | rgs_cons umingAppPa ssword == null) { | |
| 77 | Xrm.Page .ui.setFor mNotificat ion("ERROR : THE 'VIA CONFIGURA TION IS MI SSING DATA IN THE 'S ettings En tity', PLE ASE CONTAC T TECHNICA L SUPPORT! ", "ERROR" , "VISTASE RVICE"); | |
| 78 | //Exit p rocess, cl ear notifi cation mes sage | |
| 79 | Xrm.Page .ui.clearF ormNotific ation("SUR R1001"); | |
| 80 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setVal ue(null); | |
| 81 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setSub mitMode('a lways'); | |
| 82 | return f alse; | |
| 83 | } | |
| 84 | // Decrypt VI A Service Connector Items | |
| 85 | rg s_requesti ngApp = rg s_decryptS erviceConn ector(rgs_ requesting App, 4); | |
| 86 | rg s_consumin gAppToken = rgs_decr yptService Connector( rgs_consum ingAppToke n, 6); | |
| 87 | rg s_consumin gAppPasswo rd = rgs_d ecryptServ iceConnect or(rgs_con sumingAppP assword, 8 ); | |
| 88 | ||
| 89 | // Get the se lected use r value | |
| 90 | va r rgs_user SelectedVa lue = Xrm. Page.getAt tribute("f tp_usersel ected").ge tValue(); | |
| 91 | // Check if a record al ready exis ts for the selected CRM user | |
| 92 | va r rgs_cros sReference Id = null; | |
| 93 | va r rgs_cros sReference Duz = null ; | |
| 94 | va r rgs_cros sReference Name = nul l; | |
| 95 | va r rgs_cond itionalFil ter = "ftp _crmuser/I d eq (guid '" + rgs_u serSelecte dValue[0]. id + "')"; | |
| 96 | va r rgs_cros sReference Data = rgs _getMultip leEntityDa taSync('ft p_useridSe t', 'ftp_u seridId, f tp_vistadu z, ftp_vis tausername ', rgs_con ditionalFi lter, 'ftp _name', 'a sc', 0); | |
| 97 | if (rgs_cros sReference Data != nu ll) { | |
| 98 | for (var i = 0; i <= rgs_cro ssReferenc eData.d.re sults.leng th - 1; i+ +) { | |
| 99 | //Ge t Info | |
| 100 | if ( rgs_crossR eferenceDa ta.d.resul ts[i].ftp_ useridId ! = null) { rgs_crossR eferenceId = rgs_cro ssReferenc eData.d.re sults[i].f tp_useridI d; } | |
| 101 | if ( rgs_crossR eferenceDa ta.d.resul ts[i].ftp_ vistaduz ! = null) { rgs_crossR eferenceDu z = rgs_cr ossReferen ceData.d.r esults[i]. ftp_vistad uz; } | |
| 102 | if ( rgs_crossR eferenceDa ta.d.resul ts[i].ftp_ vistausern ame != nul l) { rgs_c rossRefere nceName = rgs_crossR eferenceDa ta.d.resul ts[i].ftp_ vistausern ame; } | |
| 103 | brea k; | |
| 104 | } | |
| 105 | } | |
| 106 | ||
| 107 | if (rgs_cros sReference Id == null ) { | |
| 108 | //Values are null, inform us er and per form stand ard assign ement and exit | |
| 109 | Xrm.Page .ui.setFor mNotificat ion("The s elected us er does no t have a V IA/CRM Cro ss Referen ce record. A surroga te check w as not per formed!", "INFO", "S URR1001"); | |
| 110 | Xrm.Page .getAttrib ute("owner id").setVa lue([{ | |
| 111 | id: rgs_userSe lectedValu e[0].id, | |
| 112 | name : rgs_user SelectedVa lue[0].nam e, | |
| 113 | enti tyType: "s ystemuser" | |
| 114 | }]); | |
| 115 | Xrm.Page .getAttrib ute("owner id").setSu bmitMode(' always'); | |
| 116 | //Set As signed to Surrogate to No | |
| 117 | Xrm.Page .getAttrib ute("tri_i ssurrogate assigned") .setValue( 0); | |
| 118 | Xrm.Page .getAttrib ute("tri_i ssurrogate assigned") .setSubmit Mode('alwa ys'); | |
| 119 | rgs_owne rChange(); | |
| 120 | return f alse; | |
| 121 | } | |
| 122 | ||
| 123 | // Check if V IA Login c ookie exis t (not exp ired) | |
| 124 | va r rgs_ViaL oginCookie = rgs_get Cookie("vi asessionli nk"); | |
| 125 | ||
| 126 | if (rgs_ViaL oginCookie == "") { | |
| 127 | alert("Y our VISTA session ha s expired. In order to check f or surroga tes, you m ust be log ged into V ISTA!"); | |
| 128 | Xrm.Page .ui.tabs.g et('Tab_Vi stALogin') .setVisibl e(true); | |
| 129 | Xrm.Page .ui.tabs.g et('Tab_Vi stALogin') .setFocus( ); | |
| 130 | //Exit p rocess, cl ear notifi cation mes sage | |
| 131 | Xrm.Page .ui.clearF ormNotific ation("SUR R1001"); | |
| 132 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setVal ue(null); | |
| 133 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setSub mitMode('a lways'); | |
| 134 | return f alse; | |
| 135 | } | |
| 136 | ||
| 137 | // Prep user data | |
| 138 | va r rgs_user SiteId = " "; | |
| 139 | va r rgs_User SiteNo = " "; | |
| 140 | va r rgs_duz = ""; | |
| 141 | va r rgs_prov idername = ""; | |
| 142 | va r rgs_user Data = rgs _getSingle EntityData Sync('Syst emUserSet' , 'ftp_Fac ilitySiteI d', Xrm.Pa ge.context .getUserId ()); | |
| 143 | if (rgs_user Data != nu ll) { | |
| 144 | if (rgs_ userData.d .ftp_Facil itySiteId != null) { | |
| 145 | rgs_ userSiteId = rgs_use rData.d.ft p_Facility SiteId.Id; | |
| 146 | } | |
| 147 | } | |
| 148 | // Lookup the Facility/ Site # | |
| 149 | if (rgs_user SiteId != null && rg s_userSite Id != '') { | |
| 150 | var rgs_ facilityDa ta = rgs_g etSingleEn tityDataSy nc('ftp_fa cilitySet' , 'ftp_fac ilitycode' , rgs_user SiteId); | |
| 151 | if (rgs_ facilityDa ta != null ) { | |
| 152 | if ( rgs_facili tyData.d.f tp_facilit ycode != n ull) { rgs _UserSiteN o = rgs_fa cilityData .d.ftp_fac ilitycode; } | |
| 153 | } | |
| 154 | } | |
| 155 | ||
| 156 | // Get VIA Lo gin Cookie data | |
| 157 | va r rgs_ViaL oginCookie = rgs_get Cookie("vi asessionli nk"); | |
| 158 | ||
| 159 | if (rgs_ViaL oginCookie != null & & rgs_ViaL oginCookie != '') { | |
| 160 | var rgs_ cookiearra y = rgs_Vi aLoginCook ie.split(" ~~~~", 2); | |
| 161 | rgs_duz = rgs_cook iearray[0] ; | |
| 162 | rgs_prov idername = rgs_cooki earray[1]; | |
| 163 | } | |
| 164 | ||
| 165 | if (rgs_cros sReference Duz == nul l && rgs_c rossRefere nceName != null && r gs_crossRe ferenceNam e != '') { | |
| 166 | //No IEN , but have name, att empt cprs User Looku p | |
| 167 | //Extrac t Last Nam e from VIS TA Name | |
| 168 | var rgs_ cprsSearch Name = nul l; | |
| 169 | //Split on comma | |
| 170 | rgs_cprs SearchName = rgs_cro ssReferenc eName.spli t(",", 1); | |
| 171 | //Split on space | |
| 172 | rgs_cprs SearchName = rgs_cpr sSearchNam e[0].split (" ", 1); | |
| 173 | ||
| 174 | //Prep e xternal ob ject for v ia service use | |
| 175 | var rgs_ viaDataObj ect = new Object(); | |
| 176 | rgs_viaD ataObject. ProviderNa me = rgs_p rovidernam e; | |
| 177 | rgs_viaD ataObject. Duz = rgs_ duz; | |
| 178 | rgs_viaD ataObject. LoginSiteC ode = rgs_ UserSiteNo ; | |
| 179 | rgs_viaD ataObject. CrossRefNa me = rgs_c rossRefere nceName; | |
| 180 | ||
| 181 | //Execut e cprsUser Lookup Ser vice | |
| 182 | vialib_c prsUserLoo kup(rgs_re questingAp p, rgs_con sumingAppT oken, rgs_ consumingA ppPassword , rgs_base ServiceEnd pointUrl, rgs_provid ername, rg s_duz, rgs _UserSiteN o, rgs_cpr sSearchNam e, rgs_cpr sUserLooku p_response , rgs_viaD ataObject) ; | |
| 183 | ||
| 184 | } | |
| 185 | if (rgs_cros sReference Duz != nul l) { | |
| 186 | //Perfor m Surrogat e Check | |
| 187 | rgs_exec uteVistaGe tSurrogate (rgs_provi dername, r gs_duz, rg s_UserSite No, rgs_cr ossReferen ceDuz) | |
| 188 | } | |
| 189 | // Fallback i f no match , should n ot happen | |
| 190 | if (rgs_cros sReference Duz == nul l && (rgs_ crossRefer enceName = = null || rgs_crossR eferenceNa me == '')) { | |
| 191 | //Values are null, inform us er and per form stand ard assign ement and exit | |
| 192 | var rgs_ userSelect edValue = Xrm.Page.g etAttribut e("ftp_use rselected" ).getValue (); | |
| 193 | Xrm.Page .ui.setFor mNotificat ion("The s elected us er has an incomplete VIA/CRM C ross Refer ence recor d. A surro gate check was not p erformed!" , "INFO", "SURR1001" ); | |
| 194 | Xrm.Page .getAttrib ute("owner id").setVa lue([{ | |
| 195 | id: rgs_userSe lectedValu e[0].id, | |
| 196 | name : rgs_user SelectedVa lue[0].nam e, | |
| 197 | enti tyType: "s ystemuser" | |
| 198 | }]); | |
| 199 | Xrm.Page .getAttrib ute("owner id").setSu bmitMode(' always'); | |
| 200 | //Set As signed to Surrogate to No | |
| 201 | Xrm.Page .getAttrib ute("tri_i ssurrogate assigned") .setValue( 0); | |
| 202 | Xrm.Page .getAttrib ute("tri_i ssurrogate assigned") .setSubmit Mode('alwa ys'); | |
| 203 | rgs_owne rChange(); | |
| 204 | return f alse; | |
| 205 | } | |
| 206 | } | |
| 207 | catch (err) { | |
| 208 | al ert('Reque st Surroga te Functio n Error(rg s_viaSurro gateSettin g_response ): ' + err .message); | |
| 209 | Xr m.Page.ui. clearFormN otificatio n("SURR100 1"); | |
| 210 | } | |
| 211 | } | |
| 212 | ||
| 213 | function r gs_execute VistaGetSu rrogate(rg s_provider name, rgs_ duz, rgs_U serSiteNo, rgs_cross ReferenceD uz) { | |
| 214 | try { | |
| 215 | // Perform th e Surrogat e Lookup | |
| 216 | va r rgs_viaS urrogate = new Objec t(); | |
| 217 | rg s_viaSurro gate.Provi derName = rgs_provid ername; | |
| 218 | rg s_viaSurro gate.Duz = rgs_duz; | |
| 219 | rg s_viaSurro gate.Login SiteCode = rgs_UserS iteNo; | |
| 220 | rg s_viaSurro gate.Targe t = rgs_cr ossReferen ceDuz; | |
| 221 | ||
| 222 | $. ajax({ | |
| 223 | type: "P OST", | |
| 224 | url: rgs _GetSurrog ateUrl, | |
| 225 | data: JS ON.stringi fy(rgs_via Surrogate) , | |
| 226 | contentT ype: "appl ication/js on; charse t=utf-8", | |
| 227 | dataType : "json", | |
| 228 | success: function (data) { | |
| 229 | var rgs_newdat a = data.D ata; | |
| 230 | var rgs_reques tResponse = rgs_newd ata; | |
| 231 | rgs_ executeVis taGetSurro gate_respo nse(null, rgs_reques tResponse) ; | |
| 232 | }, | |
| 233 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 234 | //Sy stem Error | |
| 235 | rgs_ executeVis taGetSurro gate_respo nse(errorT hrown, nul l); | |
| 236 | }, | |
| 237 | async: f alse, | |
| 238 | cache: f alse | |
| 239 | }) ; | |
| 240 | } | |
| 241 | catch (err) { | |
| 242 | al ert('Reque st Surroga te Functio n Error(rg s_executeV istaGetSur rogate): ' + err.mes sage); | |
| 243 | Xr m.Page.ui. clearFormN otificatio n("SURR100 1"); | |
| 244 | } | |
| 245 | } | |
| 246 | ||
| 247 | function r gs_cprsUse rLookup_re sponse(rgs _error, rg s_userlook upResponse , rgs_exte rnalObject ) { | |
| 248 | try { | |
| 249 | // Check for non VIA Se rvice Erro r | |
| 250 | if (rgs_erro r != null) { | |
| 251 | alert("T he VIA cpr sUserLooku p service failed wit h error: " + rgs_use rlookupRes ponse); | |
| 252 | //Exit p rocess, cl ear notifi cation mes sage | |
| 253 | Xrm.Page .ui.clearF ormNotific ation("SUR R1001"); | |
| 254 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setVal ue(null); | |
| 255 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setSub mitMode('a lways'); | |
| 256 | return f alse; | |
| 257 | } | |
| 258 | // Test for V IA Service Error | |
| 259 | if (rgs_user lookupResp onse.getEl ementsByTa gName("fau lt").lengt h > 0) { | |
| 260 | alert("T he VIA cpr sUserLooku p service failed wit h error: " + rgs_use rlookupRes ponse.getE lementsByT agName("fa ult")[0].t extContent ); | |
| 261 | //Exit p rocess, cl ear notifi cation mes sage | |
| 262 | Xrm.Page .ui.clearF ormNotific ation("SUR R1001"); | |
| 263 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setVal ue(null); | |
| 264 | Xrm.Page .getAttrib ute("ftp_u serselecte d").setSub mitMode('a lways'); | |
| 265 | return f alse; | |
| 266 | } | |
| 267 | ||
| 268 | va r rgs_cprs UserIEN = null; | |
| 269 | va r rgs_cprs MatchCount = 0; | |
| 270 | ||
| 271 | // Get VIA se rvice Resp onse | |
| 272 | if (rgs_user lookupResp onse.getEl ementsByTa gName("use rs")[0].ch ildNodes.l ength > 0) { | |
| 273 | var rgs_ userlookup Array = rg s_userlook upResponse .getElemen tsByTagNam e("users") [0].childN odes; | |
| 274 | ||
| 275 | //Analyz e result | |
| 276 | for (var i = 0; i <= rgs_use rlookupArr ay.length - 1; i++) { | |
| 277 | //Co mpare VIA Full Name to the VIA Full Name in CRM an d if a mat ch, add to list... | |
| 278 | var rgs_cprsUs erName = r gs_userloo kupArray[i ].childNod es[0].text Content; | |
| 279 | var rgs_cprsUs erNameUppe r = rgs_cp rsUserName .toUpperCa se(); | |
| 280 | var rgs_crossR efName = r gs_externa lObject.Cr ossRefName ; | |
| 281 | var rgs_crossR efNameUppe r = rgs_cr ossRefName .toUpperCa se(); | |
| 282 | ||
| 283 | if ( rgs_cprsUs erNameUppe r == rgs_c rossRefNam eUpper) { | |
| 284 | //User Nam es Match | |
| 285 | rgs_cprsMa tchCount = rgs_cprsM atchCount + 1; | |
| 286 | rgs_cprsUs erIEN = rg s_userlook upArray[i] .childNode s[1].textC ontent; | |
| 287 | } | |
| 288 | } | |
| 289 | } | |
| 290 | ||
| 291 | // | |
| 292 | if (rgs_cprs MatchCount == 1 && r gs_cprsUse rIEN != nu ll) { | |
| 293 | //Perfor m Surrogat e Check | |
| 294 | rgs_exec uteVistaGe tSurrogate (rgs_exter nalObject. ProviderNa me, rgs_ex ternalObje ct.Duz, rg s_external Object.Log inSiteCode , rgs_cprs UserIEN) | |
| 295 | } | |
| 296 | el se { | |
| 297 | //Values are null, inform us er and per form stand ard assign ement and exit | |
| 298 | var rgs_ userSelect edValue = Xrm.Page.g etAttribut e("ftp_use rselected" ).getValue (); | |
| 299 | Xrm.Page .ui.setFor mNotificat ion("The s elected us er was not located i n VIA/CPRS or more t han one ex ist with t he same na me. A surr ogate chec k was not performed! ", "INFO", "SURR1001 "); | |
| 300 | Xrm.Page .getAttrib ute("owner id").setVa lue([{ | |
| 301 | id: rgs_userSe lectedValu e[0].id, | |
| 302 | name : rgs_user SelectedVa lue[0].nam e, | |
| 303 | enti tyType: "s ystemuser" | |
| 304 | }]); | |
| 305 | Xrm.Page .getAttrib ute("owner id").setSu bmitMode(' always'); | |
| 306 | //Set As signed to Surrogate to No | |
| 307 | Xrm.Page .getAttrib ute("tri_i ssurrogate assigned") .setValue( 0); | |
| 308 | Xrm.Page .getAttrib ute("tri_i ssurrogate assigned") .setSubmit Mode('alwa ys'); | |
| 309 | rgs_owne rChange(); | |
| 310 | return f alse; | |
| 311 | } | |
| 312 | } | |
| 313 | catch (err) { | |
| 314 | al ert('Reque st Surroga te Functio n Error(rg s_cprsUser Lookup_res ponse): ' + err.mess age); | |
| 315 | Xr m.Page.ui. clearFormN otificatio n("SURR100 1"); | |
| 316 | } | |
| 317 | } | |
| 318 | ||
| 319 | function r gs_execute VistaGetSu rrogate_re sponse(rgs _errorThro wn, rgs_re questRespo nse) { | |
| 320 | try { | |
| 321 | // Process Ge t Surrogat e Request Response | |
| 322 | if (rgs_erro rThrown != null) { | |
| 323 | //Handle Error | |
| 324 | alert("T he VIA Get Surrogate Service Fa iled with error: " + rgs_error Thrown); | |
| 325 | Xrm.Page .ui.clearF ormNotific ation("SUR R1001"); | |
| 326 | return f alse; | |
| 327 | } | |
| 328 | el se { | |
| 329 | if (rgs_ requestRes ponse.leng th > 0) { | |
| 330 | //Su rrogate Re turned, pr ocess data | |
| 331 | var rgs_surrog ateId = rg s_requestR esponse[0] .Id; | |
| 332 | var rgs_surrog ateName = rgs_reques tResponse[ 0].Name; | |
| 333 | var rgs_surrog ateStartDa te = rgs_r equestResp onse[0].St artDate; | |
| 334 | var rgs_surrog ateEndDate = rgs_req uestRespon se[0].EndD ate; | |
| 335 | ||
| 336 | //Po pulate Sur rogate Ass ignee Fiel d | |
| 337 | Xrm. Page.getAt tribute("f tp_surroga teassignee ").setValu e(rgs_surr ogateName) ; | |
| 338 | Xrm. Page.getAt tribute("f tp_surroga teassignee ").setSubm itMode('al ways'); | |
| 339 | //Se t Assigned to Surrog ate to Yes | |
| 340 | Xrm. Page.getAt tribute("t ri_issurro gateassign ed").setVa lue(1); | |
| 341 | Xrm. Page.getAt tribute("t ri_issurro gateassign ed").setSu bmitMode(' always'); | |
| 342 | //Di splay surr ogate assi gned to us er | |
| 343 | Xrm. Page.ui.se tFormNotif ication("A surrogate user '" + rgs_surro gateName + "' was ap plied!", " INFO", "SU RR1001"); | |
| 344 | //Up date the o wner field ... | |
| 345 | var rgs_userSe lectedValu e = Xrm.Pa ge.getAttr ibute("ftp _userselec ted").getV alue(); | |
| 346 | Xrm. Page.getAt tribute("o wnerid").s etValue([{ | |
| 347 | id: rgs_us erSelected Value[0].i d, | |
| 348 | name: rgs_ userSelect edValue[0] .name, | |
| 349 | entityType : "systemu ser" | |
| 350 | }]); | |
| 351 | Xrm. Page.getAt tribute("o wnerid").s etSubmitMo de('always '); | |
| 352 | rgs_ ownerChang e(); | |
| 353 | retu rn false; | |
| 354 | ||
| 355 | ||
| 356 | //** *The Secti on below i s the prio r method o f assignin g surrogat es | |
| 357 | //** *Code is c ommented o ut, but ma y be used again late r.. | |
| 358 | /* | |
| 359 | //De termine if CRM Cross Reference has a rec ord for th is IEN/Id | |
| 360 | var rgs_crossR eferenceId = null; | |
| 361 | var rgs_crossR eferenceCr mUser = nu ll; | |
| 362 | var rgs_condit ionalFilte r = "ftp_v istaduz eq '" + rgs_ surrogateI d + "'"; | |
| 363 | var rgs_crossR eferenceDa ta = rgs_g etMultiple EntityData Sync('ftp_ useridSet' , 'ftp_use ridId, ftp _crmuser', rgs_condi tionalFilt er, 'ftp_n ame', 'asc ', 0); | |
| 364 | if ( rgs_crossR eferenceDa ta != null ) { | |
| 365 | for (var i = 0; i <= rgs_cross ReferenceD ata.d.resu lts.length - 1; i++) { | |
| 366 | //Get Info | |
| 367 | if (rg s_crossRef erenceData .d.results [i].ftp_us eridId != null) { rg s_crossRef erenceId = rgs_cross ReferenceD ata.d.resu lts[i].ftp _useridId; } | |
| 368 | if (rg s_crossRef erenceData .d.results [i].ftp_cr muser != n ull) { rgs _crossRefe renceCrmUs er = rgs_c rossRefere nceData.d. results[i] .ftp_crmus er; } | |
| 369 | break; | |
| 370 | } | |
| 371 | } | |
| 372 | ||
| 373 | if ( rgs_crossR eferenceCr mUser != n ull) { | |
| 374 | //Cross Re ference fo r Surrogat e Exists | |
| 375 | Xrm.Page.u i.setFormN otificatio n("A surro gate user '" + rgs_s urrogateNa me + "' wa s assigned !", "INFO" , "SURR100 1"); | |
| 376 | //Set the selected u ser as the Original Assignee | |
| 377 | var rgs_us erSelected Value = Xr m.Page.get Attribute( "ftp_users elected"). getValue() ; | |
| 378 | Xrm.Page.g etAttribut e("tri_ori ginalassig nee").setV alue([{ | |
| 379 | id: rg s_userSele ctedValue[ 0].id, | |
| 380 | name: rgs_userSe lectedValu e[0].name, | |
| 381 | entity Type: "sys temuser" | |
| 382 | }]); | |
| 383 | Xrm.Page.g etAttribut e("tri_ori ginalassig nee").setS ubmitMode( 'always'); | |
| 384 | ||
| 385 | //Set the owner to t he Surroga te user | |
| 386 | Xrm.Page.g etAttribut e("ownerid ").setValu e([{ | |
| 387 | id: rg s_crossRef erenceCrmU ser.Id, | |
| 388 | name: rgs_crossR eferenceCr mUser.Name , | |
| 389 | entity Type: "sys temuser" | |
| 390 | }]); | |
| 391 | Xrm.Page.g etAttribut e("ownerid ").setSubm itMode('al ways'); | |
| 392 | //Set Assi gned to Su rrogate to Yes | |
| 393 | Xrm.Page.g etAttribut e("tri_iss urrogateas signed").s etValue(1) ; | |
| 394 | Xrm.Page.g etAttribut e("tri_iss urrogateas signed").s etSubmitMo de('always '); | |
| 395 | ||
| 396 | rgs_ownerC hange(); | |
| 397 | ||
| 398 | //Set the selected u ser to the surrogate user | |
| 399 | Xrm.Page.g etAttribut e("ftp_use rselected" ).setValue ([{ | |
| 400 | id: rg s_crossRef erenceCrmU ser.Id, | |
| 401 | name: rgs_crossR eferenceCr mUser.Name , | |
| 402 | entity Type: "sys temuser" | |
| 403 | }]); | |
| 404 | Xrm.Page.g etAttribut e("ftp_use rselected" ).setSubmi tMode('alw ays'); | |
| 405 | ||
| 406 | return fal se; | |
| 407 | } | |
| 408 | else { | |
| 409 | //No match ing surrog ate User I n CRM | |
| 410 | Xrm.Page.u i.setFormN otificatio n("The sur rogate use r '" + rgs _surrogate Name + "' does not h ave a VIA/ CRM Cross Reference record. Th e selected user was used inste ad!", "INF O", "SURR1 001"); | |
| 411 | var rgs_us erSelected Value = Xr m.Page.get Attribute( "ftp_users elected"). getValue() ; | |
| 412 | Xrm.Page.g etAttribut e("ownerid ").setValu e([{ | |
| 413 | id: rg s_userSele ctedValue[ 0].id, | |
| 414 | name: rgs_userSe lectedValu e[0].name, | |
| 415 | entity Type: "sys temuser" | |
| 416 | }]); | |
| 417 | Xrm.Page.g etAttribut e("ownerid ").setSubm itMode('al ways'); | |
| 418 | //Set Assi gned to Su rrogate to No | |
| 419 | Xrm.Page.g etAttribut e("tri_iss urrogateas signed").s etValue(0) ; | |
| 420 | Xrm.Page.g etAttribut e("tri_iss urrogateas signed").s etSubmitMo de('always '); | |
| 421 | rgs_ownerC hange(); | |
| 422 | return fal se; | |
| 423 | } | |
| 424 | */ | |
| 425 | //** *End of co mmented ou t section for reuse later | |
| 426 | ||
| 427 | } | |
| 428 | else { | |
| 429 | //No Surrogate Returned, complete assign wit h current selection | |
| 430 | var rgs_userSe lectedValu e = Xrm.Pa ge.getAttr ibute("ftp _userselec ted").getV alue(); | |
| 431 | Xrm. Page.getAt tribute("o wnerid").s etValue([{ | |
| 432 | id: rgs_us erSelected Value[0].i d, | |
| 433 | name: rgs_ userSelect edValue[0] .name, | |
| 434 | entityType : "systemu ser" | |
| 435 | }]); | |
| 436 | Xrm. Page.getAt tribute("o wnerid").s etSubmitMo de('always '); | |
| 437 | //Se t Assigned to Surrog ate to No | |
| 438 | Xrm. Page.getAt tribute("t ri_issurro gateassign ed").setVa lue(0); | |
| 439 | Xrm. Page.getAt tribute("t ri_issurro gateassign ed").setSu bmitMode(' always'); | |
| 440 | rgs_ ownerChang e(); | |
| 441 | } | |
| 442 | //Clear progress m essages | |
| 443 | Xrm.Page .ui.clearF ormNotific ation("SUR R1001"); | |
| 444 | } | |
| 445 | } | |
| 446 | catch (err) { | |
| 447 | al ert('Reque st Surroga te Functio n Error(rg s_executeV istaGetSur rogate_res ponse): ' + err.mess age); | |
| 448 | Xr m.Page.ui. clearFormN otificatio n("SURR100 1"); | |
| 449 | } | |
| 450 | } | |
| 451 | ||
| 452 | function r gs_ownerCh ange() { | |
| 453 | try { | |
| 454 | Xr m.Page.get Attribute( "ownerid") .fireOnCha nge(); | |
| 455 | } | |
| 456 | catch (err) { | |
| 457 | al ert('Reque st Surroga te Functio n Error(rg s_ownerCha nge): ' + err.messag e); | |
| 458 | } | |
| 459 | } | |
| 460 | ||
| 461 | function r gs_getCook ie(cname) { | |
| 462 | try { | |
| 463 | va r name = c name + "=" ; | |
| 464 | va r ca = doc ument.cook ie.split(' ;'); | |
| 465 | fo r (var i = 0; i < ca .length; i ++) { | |
| 466 | var c = ca[i]; | |
| 467 | while (c .charAt(0) == ' ') { | |
| 468 | c = c.substrin g(1); | |
| 469 | } | |
| 470 | if (c.in dexOf(name ) == 0) { | |
| 471 | retu rn c.subst ring(name. length, c. length); | |
| 472 | } | |
| 473 | } | |
| 474 | re turn ""; | |
| 475 | } | |
| 476 | catch (err) { | |
| 477 | al ert('Reque st Surroga te Functio n Error(rg s_getCooki e): ' + er r.message) ; | |
| 478 | } | |
| 479 | } | |
| 480 | ||
| 481 | function r gs_decrypt ServiceCon nector(rgs _connector Array, rgs _connector Value) { | |
| 482 | var rg s_decrypte dString = ""; | |
| 483 | if (rg s_connecto rArray != null && rg s_connecto rArray != "") { | |
| 484 | va r rgs_newA rray = rgs _connector Array.toSt ring().spl it(','); | |
| 485 | rg s_newArray .reverse() ; | |
| 486 | fo r (i = 0; i < rgs_ne wArray.len gth; i++) { | |
| 487 | var rgs_ curChar = ""; | |
| 488 | if (i == 0) { | |
| 489 | rgs_ curChar = rgs_newArr ay[i] - rg s_connecto rValue; | |
| 490 | } | |
| 491 | else { | |
| 492 | rgs_ curChar = rgs_newArr ay[i] - (i + rgs_con nectorValu e); | |
| 493 | } | |
| 494 | rgs_decr yptedStrin g = rgs_de cryptedStr ing + Stri ng.fromCha rCode(rgs_ curChar); | |
| 495 | } | |
| 496 | } | |
| 497 | return rgs_decry ptedString ; | |
| 498 | } | |
| 499 | ||
| 500 | function r gs_execute CrmOdataGe tRequest(r gs_jsonQue ry, rgs_aS ync, rgs_a SyncCallba ck, rgs_sk ipCount, r gs_optionA rray) { | |
| 501 | //This function executes a CRM Odata web servi ce call to retrieve Crm data | |
| 502 | //*rgs _jsonQuery * - a prop erly forma tted CRM O data Query string (r equired) | |
| 503 | //*rgs _aSync* - specify 't rue' to ex ecute asyn chronously otherwise 'false' ( required) | |
| 504 | //*rgs _aSyncCall back* - sp ecify the name of th e return f unction to call upon completio n (require d if rgs_a Sync = tru e. Otherw ise '') | |
| 505 | //*rgs _skipCount * - Initia l setting is always '0', incre ments by 5 0 per CRM SDK Odata standards (required) | |
| 506 | //*rgs _optionArr ay* - is a n optional array or single val ue, that c ontains ad ditional t ask specif ic variabl es that ca n be passe d between functions (pass 'nul l' if not used) | |
| 507 | try { | |
| 508 | va r rgs_enti tyData = n ull; | |
| 509 | $. ajax({ | |
| 510 | type: 'G ET', | |
| 511 | contentT ype: 'appl ication/js on; charse t=utf-8', | |
| 512 | datatype : 'json', | |
| 513 | url: rgs _jsonQuery , | |
| 514 | beforeSe nd: functi on (XMLHtt pRequest) { | |
| 515 | XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json'); | |
| 516 | }, | |
| 517 | success: function (data, tex tStatus, X mlHttpRequ est) { | |
| 518 | rgs_ entityData = data; | |
| 519 | if ( rgs_aSync == true) { | |
| 520 | rgs_aSyncC allback(rg s_entityDa ta, rgs_sk ipCount, r gs_optionA rray); | |
| 521 | } | |
| 522 | }, | |
| 523 | error: f unction (X MLHttpRequ est, textS tatus, err orThrown) { | |
| 524 | aler t('Fail: A jax Error in rgs_exe cuteCrmOda taGetReque st: ' + er rorThrown + " Reques t: " + rgs _jsonQuery ); | |
| 525 | }, | |
| 526 | async: r gs_aSync, | |
| 527 | cache: f alse | |
| 528 | }) ; | |
| 529 | re turn rgs_e ntityData; | |
| 530 | } | |
| 531 | catch (err) { | |
| 532 | al ert('An er ror occure d in the r gs_execute CrmOdataGe tRequest f unction. Error Deta il Message : ' + err) ; | |
| 533 | } | |
| 534 | } | |
| 535 | ||
| 536 | function r gs_getMult ipleEntity DataAsync( rgs_entity SetName, r gs_attribu teSet, rgs _condition alFilter, rgs_sortAt tribute, r gs_sortDir ection, rg s_skipCoun t, rgs_aSy ncCallback , rgs_opti onArray) { | |
| 537 | //This function returns a CRM JSON d ataset for all entit y records matching c riteria pr ovided Asy ncronously | |
| 538 | //*rgs _entitySet Name* - is the name of the ent ity set e. g 'Contact Set' | |
| 539 | //*rgs _attribute Set* - is a string containing the Crm A ttributes to retriev e e.g. 'Fi rstName, L astName, T elephone1, EMailAddr ess1' | |
| 540 | //*rgs _condition alFilter* - is the c onditional filter va lue placed on the da ta values retrived e .g. 'State Code/Value eq 0' to retrieve active con tact recor ds only | |
| 541 | //*rgs _sortAttri bute* - is a string containing the name of the att ribute to sort the r esult set by e.g. 'L astName' | |
| 542 | //*rgs _sortDirec tion* - is a string specifying the sort as Ascendi ng or Desc ending e.g . 'asc' or 'desc' | |
| 543 | //*rgs _skipCount * - is the starting point in t he result (use if mo re than 50 ), (Put 0 if not use d) | |
| 544 | //*rgs _aSyncCall back* - is the name of the fun ction to c all when r eturning t he result | |
| 545 | //*rgs _optionArr ay* - is a n optional array, th at contain s addition al task sp ecific var iables tha t can be p assed betw een functi ons | |
| 546 | ||
| 547 | try { | |
| 548 | va r rgs_json Query = rg s_serverUr l + rgs_cr mOdataEndP oint + '/' + rgs_ent itySetName + '?$sele ct=' + rgs _attribute Set + '&$f ilter=' + rgs_condit ionalFilte r + '&$ord erby=' + r gs_sortAtt ribute + ' ' + rgs_s ortDirecti on + '&$sk ip=' + rgs _skipCount ; | |
| 549 | rg s_executeC rmOdataGet Request(rg s_jsonQuer y, true, r gs_aSyncCa llback, rg s_skipCoun t, rgs_opt ionArray); | |
| 550 | } | |
| 551 | catch (err) { | |
| 552 | al ert('An er ror occure d in the r gs_getMult ipleEntity DataAsync function. Error Det ail Messag e: ' + err ); | |
| 553 | } | |
| 554 | } | |
| 555 | ||
| 556 | function r gs_getMult ipleEntity DataSync(r gs_entityS etName, rg s_attribut eSet, rgs_ conditiona lFilter, r gs_sortAtt ribute, rg s_sortDire ction, rgs _skipCount ) { | |
| 557 | //This function returns a CRM JSON d ataset for all entit y records matching c riteria pr ovided Syn cronously | |
| 558 | //*rgs _entitySet Name* - is the name of the ent ity set e. g 'Contact Set' | |
| 559 | //*rgs _attribute Set* - is a string containing the Crm A ttributes to retriev e e.g. 'Fi rstName, L astName, T elephone1, EMailAddr ess1' | |
| 560 | //*rgs _condition alFilter* - is the c onditional filter va lue placed on the da ta values retrived e .g. 'State Code/Value eq 0' to retrieve active con tact recor ds only | |
| 561 | //*rgs _sortAttri bute* - is a string containing the name of the att ribute to sort the r esult set by e.g. 'L astName' | |
| 562 | //*rgs _sortDirec tion* - is a string specifying the sort as Ascendi ng or Desc ending e.g . 'asc' or 'desc' | |
| 563 | //*rgs _skipCount * - is the starting point in t he result (use if mo re than 50 ), (Put 0 if not use d) | |
| 564 | ||
| 565 | try { | |
| 566 | va r rgs_json Query = rg s_serverUr l + rgs_cr mOdataEndP oint + '/' + rgs_ent itySetName + '?$sele ct=' + rgs _attribute Set + '&$f ilter=' + rgs_condit ionalFilte r + '&$ord erby=' + r gs_sortAtt ribute + ' ' + rgs_s ortDirecti on + '&$sk ip=' + rgs _skipCount ; | |
| 567 | va r rgs_enti tyData = r gs_execute CrmOdataGe tRequest(r gs_jsonQue ry, false, '', rgs_s kipCount, null); | |
| 568 | re turn rgs_e ntityData; | |
| 569 | } | |
| 570 | catch (err) { | |
| 571 | al ert('An er ror occure d in the r gs_getMult ipleEntity DataSync f unction. Error Deta il Message : ' + err) ; | |
| 572 | } | |
| 573 | } | |
| 574 | ||
| 575 | function r gs_getSing leEntityDa taSync(rgs _entitySet Name, rgs_ attributeS et, rgs_en tityId) { | |
| 576 | //This function returns a CRM JSON d ataset for a single entity rec ord based on the ent ity id pro vided Sync ronously | |
| 577 | //*rgs _entitySet Name* - is the name of the ent ity set e. g 'Contact Set' | |
| 578 | //*rgs _attribute Set* - is a string containing the Crm A ttributes to retriev e e.g. 'Fi rstName, L astName, T elephone1, EMailAddr ess1' | |
| 579 | //*rgs _entityId* - is the Guid for t he entity record | |
| 580 | ||
| 581 | try { | |
| 582 | va r rgs_enti tyIdNoBrac ket = rgs_ entityId.r eplace(/({ |})/g, '') ; | |
| 583 | va r rgs_sele ctString = '(guid' + "'" + rgs _entityIdN oBracket + "'" + ')? $select=' + rgs_attr ibuteSet; | |
| 584 | va r rgs_json Query = rg s_serverUr l + rgs_cr mOdataEndP oint + '/' + rgs_ent itySetName + rgs_sel ectString; | |
| 585 | va r rgs_enti tyData = r gs_execute CrmOdataGe tRequest(r gs_jsonQue ry, false, '', 0, nu ll); | |
| 586 | re turn rgs_e ntityData; | |
| 587 | } | |
| 588 | catch (err) { | |
| 589 | al ert('An er ror occure d in the r gs_getSing leEntityDa taSync fun ction. Er ror Detail Message: ' + err); | |
| 590 | } | |
| 591 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.