Produced by Araxis Merge on 6/22/2018 1:29:31 PM Central 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 | v1603_release_60.zip\CRM_solutions\VCCMResources.zip\WebResources | ftp_VistAMultiNoteVistaLoginControljsVistaLoginCon810D6C09-5423-E611-9437-0050568D743D | Tue May 22 14:39:24 2018 UTC |
| 2 | v1603_release_60.zip\CRM_solutions\VCCMResources.zip\WebResources | ftp_VistAMultiNoteVistaLoginControljsVistaLoginCon810D6C09-5423-E611-9437-0050568D743D | Wed Jun 20 16:38:27 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1532 |
| 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 | /// <refer ence path= '../../../ triipcrm_/ TR_KU_V201 5_2_902/js /jquery.mi n.js' /> | |
| 2 | /// <refer ence path= 'SSOiServi ceScriptLi b.js' /> | |
| 3 | /// <refer ence path= '../../Via ServiceLib rary.js' / > | |
| 4 | ||
| 5 | //VistaLog inControlS criptLib.j s | |
| 6 | //Contains variables and funct ions used by the Vis taLoginCon trol.html page | |
| 7 | ||
| 8 | //Static V ariables | |
| 9 | var vlc_cr mOdataEndP oint = '/X RMServices /2011/Orga nizationDa ta.svc'; | |
| 10 | var vlc_co ntext = Ge tGlobalCon text(); | |
| 11 | var vlc_se rverUrl = vlc_contex t.getClien tUrl(); | |
| 12 | var vlc_or gName = vl c_context. getOrgUniq ueName(); | |
| 13 | var vlc_us erId = vlc _context.g etUserId() ; | |
| 14 | var vlc_us erName = v lc_context .getUserNa me(); | |
| 15 | ||
| 16 | //var vlc_ ViaLoginUr l = 'https :// URL /WebParts/ dev/api/VI A/LoginVIA /1.0/json' ; //OLD MANU AL DEV URL | |
| 17 | var vlc_Vi aLoginUrl = ''; | |
| 18 | var vlc_us erSiteId = ''; | |
| 19 | var vlc_Us erSiteNo = ''; | |
| 20 | var vlc_Vi aLoginMinu tes = 1; //Populate d from set tings, but should ty pically be 230 minut es (3 hour s 50 Minut es) | |
| 21 | ||
| 22 | //To use L ogin Contr ol directl y from a U SD page (n ot using C RM Form), add '?data =USD' to t he calling URL | |
| 23 | var vlc_US Ddata = "" ; | |
| 24 | ||
| 25 | //VIA SSOi Settings | |
| 26 | var vlc_Vi aSSOiLogin Url = ''; | |
| 27 | var vlc_Vi aSSOiRefre shTokenUrl = ''; | |
| 28 | var vlc_Vi aSSOiPivCa rdUrl = '' ; | |
| 29 | var _SAMLT oken = nul l; | |
| 30 | var _IAMSe ssion = nu ll; | |
| 31 | ||
| 32 | //VIA serv ice librar y settings | |
| 33 | var vlc_ba seServiceE ndpointUrl = null; | |
| 34 | var vlc_co nsumingApp = ''; | |
| 35 | var vlc_co nsumingApp Token = '' ; | |
| 36 | var vlc_co nsumingApp Password = ''; | |
| 37 | ||
| 38 | function v lc_getQuer yVariable( vlc_variab le) { | |
| 39 | try { | |
| 40 | // Get a Quer y Variable | |
| 41 | va r vlc_quer y = window .location. search.sub string(1); | |
| 42 | va r vlc_vars = vlc_que ry.split(" &"); | |
| 43 | fo r (var i = 0; i < vl c_vars.len gth; i++) { | |
| 44 | var vlc_ pair = vlc _vars[i].s plit("="); | |
| 45 | if (vlc_ pair[0] == vlc_varia ble) { | |
| 46 | retu rn decodeU RIComponen t(vlc_pair [1]); | |
| 47 | } | |
| 48 | } | |
| 49 | re turn ""; | |
| 50 | } | |
| 51 | catch (err) { | |
| 52 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_get QueryVaria ble): ' + err.messag e); | |
| 53 | } | |
| 54 | } | |
| 55 | ||
| 56 | function v lc_Setting sWebServic eURL_respo nse(vlc_se ttingData, vlc_lastS kip, vlc_V iaLoginUrl _NA) { | |
| 57 | try { | |
| 58 | // vlc_lastSk ip is the starting p oint in th e result ( use if mor e than 50 records) / /Not used in this sc enario | |
| 59 | va r vlc_DacU rl = null; | |
| 60 | va r vlc_ViaL oginApiUrl = null; | |
| 61 | va r vlc_ViaS SOiLoginAp iUrl = nul l; | |
| 62 | fo r (var i = 0; i <= v lc_setting Data.d.res ults.lengt h - 1; i++ ) { | |
| 63 | //Get in fo | |
| 64 | if (vlc_ settingDat a.d.result s[i].ftp_D ACURL != n ull) { vlc _DacUrl = vlc_settin gData.d.re sults[i].f tp_DACURL; } | |
| 65 | if (vlc_ settingDat a.d.result s[i].ftp_V IALoginURL != null) { vlc_ViaL oginApiUrl = vlc_set tingData.d .results[i ].ftp_VIAL oginURL; } | |
| 66 | if (vlc_ settingDat a.d.result s[i].ftp_V IALoginMin utes != nu ll) { vlc_ ViaLoginMi nutes = vl c_settingD ata.d.resu lts[i].ftp _VIALoginM inutes; } | |
| 67 | if (vlc_ settingDat a.d.result s[i].ftp_V IASSOiLogi nURL != nu ll) { vlc_ ViaSSOiLog inApiUrl = vlc_setti ngData.d.r esults[i]. ftp_VIASSO iLoginURL; } | |
| 68 | if (vlc_ settingDat a.d.result s[i].ftp_V IASSOiRefr eshTokenUR L != null) { vlc_Via SSOiRefres hTokenUrl = vlc_sett ingData.d. results[i] .ftp_VIASS OiRefreshT okenURL; } | |
| 69 | if (vlc_ settingDat a.d.result s[i].ftp_V IASSOiPIVC ardURL != null) { vl c_ViaSSOiP ivCardUrl = vlc_sett ingData.d. results[i] .ftp_VIASS OiPIVCardU RL; } | |
| 70 | ||
| 71 | if (vlc_ settingDat a.d.result s[i].ftp_V IAServiceB aseURL != null) { vl c_baseServ iceEndpoin tUrl = vlc _settingDa ta.d.resul ts[i].ftp_ VIAService BaseURL; } | |
| 72 | if (vlc_ settingDat a.d.result s[i].ftp_V IARequesti ngApplicat ionCode != null) { v lc_consumi ngApp = vl c_settingD ata.d.resu lts[i].ftp _VIAReques tingApplic ationCode; } | |
| 73 | if (vlc_ settingDat a.d.result s[i].ftp_V IAConsumin gApplicati onToken != null) { v lc_consumi ngAppToken = vlc_set tingData.d .results[i ].ftp_VIAC onsumingAp plicationT oken; } | |
| 74 | if (vlc_ settingDat a.d.result s[i].ftp_V IAConsumin gApplicati onPassword != null) { vlc_cons umingAppPa ssword = v lc_setting Data.d.res ults[i].ft p_VIAConsu mingApplic ationPassw ord; } | |
| 75 | break; | |
| 76 | } | |
| 77 | if (vlc_DacU rl != null && vlc_Vi aLoginApiU rl != null ) { | |
| 78 | //Constr uct full w eb service URL | |
| 79 | vlc_ViaL oginUrl = vlc_DacUrl + vlc_Via LoginApiUr l; | |
| 80 | } | |
| 81 | el se { | |
| 82 | parent.X rm.Page.ui .setFormNo tification ("ERROR: T HE VIA LOG IN SERVICE URL IS MI SSING, PLE ASE CONTAC T TECHNICA L SUPPORT! ", "ERROR" , "VIASERV ICE"); | |
| 83 | } | |
| 84 | if (vlc_DacU rl != null && vlc_Vi aSSOiLogin ApiUrl != null) { | |
| 85 | //Constr uct full w eb service URL | |
| 86 | vlc_ViaS SOiLoginUr l = vlc_Da cUrl + vlc _ViaSSOiLo ginApiUrl; | |
| 87 | } | |
| 88 | ||
| 89 | // Decrypt VI A Service Connector Items | |
| 90 | vl c_consumin gApp = via lib_decryp tServiceCo nnector(vl c_consumin gApp, 4); | |
| 91 | vl c_consumin gAppToken = vialib_d ecryptServ iceConnect or(vlc_con sumingAppT oken, 6); | |
| 92 | vl c_consumin gAppPasswo rd = viali b_decryptS erviceConn ector(vlc_ consumingA ppPassword , 8); | |
| 93 | ||
| 94 | } | |
| 95 | catch (err) { | |
| 96 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_Set tingsWebSe rviceURL_r esponse): ' + err.me ssage); | |
| 97 | } | |
| 98 | } | |
| 99 | ||
| 100 | function v lc_formLoa d() { | |
| 101 | try { | |
| 102 | // Hide Busy Spinner | |
| 103 | do cument.get ElementByI d("BusySpi nner").sty le.display = "none"; | |
| 104 | ||
| 105 | vl c_USDdata = vlc_getQ ueryVariab le("data") ; | |
| 106 | if (vlc_USDd ata != "US D") { | |
| 107 | //Determ ine the st atus of th e parent r ecord | |
| 108 | if (pare nt.Xrm.Pag e.ui.getFo rmType() > 2) { | |
| 109 | //Th e form is disabled, hide login tab | |
| 110 | pare nt.Xrm.Pag e.ui.tabs. get('Tab_V istALogin' ).setVisib le(false); | |
| 111 | retu rn false; | |
| 112 | } | |
| 113 | ||
| 114 | //Check if VIA Log in cookie exist (not expired) | |
| 115 | var vlc_ ViaLoginCo okie = vlc _getCookie ("viasessi onlink"); | |
| 116 | ||
| 117 | //Hide V ista Login Tab and e xit if coo kie exist | |
| 118 | if (vlc_ ViaLoginCo okie != "" ) { | |
| 119 | pare nt.Xrm.Pag e.ui.tabs. get('Tab_V istALogin' ).setVisib le(false); | |
| 120 | //** TRIGGER FO RM SCRIPT CODE TO RE CREATE DEP ENDENT WEB RESOURCES ** | |
| 121 | pare nt.vcmn_in itViaDropd ownControl s(); | |
| 122 | retu rn false; | |
| 123 | } | |
| 124 | } | |
| 125 | ||
| 126 | // GET CRM SE TTINGS WEB SERVICE U RLS | |
| 127 | va r vlc_cond itionalFil ter = "(mc s_name eq 'Active Se ttings')"; | |
| 128 | vl c_getMulti pleEntityD ataAsync(' mcs_settin gSet', 'ft p_DACURL, ftp_VIALog inURL, ftp _VIALoginM inutes, ft p_VIASSOiL oginURL, f tp_VIASSOi RefreshTok enURL, ftp _VIASSOiPI VCardURL, ftp_VIASer viceBaseUR L, ftp_VIA Requesting Applicatio nCode, ftp _VIAConsum ingApplica tionToken, ftp_VIACo nsumingApp licationPa ssword', v lc_conditi onalFilter , 'mcs_nam e', 'asc', 0, vlc_Se ttingsWebS erviceURL_ response, vlc_ViaLog inUrl); | |
| 129 | if (vlc_USDd ata != "US D") { | |
| 130 | //Notify User to L ogin To Vi stA | |
| 131 | parent.X rm.Page.ui .setFormNo tification ("ERROR: Y OUR VISTA SESSION HA S EXPIRED, PLEASE LO GIN BELOW! ", "ERROR" , "VIASERV ICE"); | |
| 132 | //Set fo cus to the login con trol | |
| 133 | parent.X rm.Page.ge tControl(" WebResourc e_VistaLog inControl" ).setFocus (); | |
| 134 | } | |
| 135 | ||
| 136 | // Get the cu rrent CRM User's ass igned site /facility | |
| 137 | va r vlc_user Data = vlc _getSingle EntityData Sync('Syst emUserSet' , 'ftp_Fac ilitySiteI d', vlc_us erId); | |
| 138 | if (vlc_user Data != nu ll) { | |
| 139 | if (vlc_ userData.d .ftp_Facil itySiteId != null) { | |
| 140 | vlc_ userSiteId = vlc_use rData.d.ft p_Facility SiteId.Id; | |
| 141 | } | |
| 142 | } | |
| 143 | ||
| 144 | // Lookup the Facility/ Site # | |
| 145 | if (vlc_user SiteId != null && vl c_userSite Id != '') { | |
| 146 | var vlc_ facilityDa ta = vlc_g etSingleEn tityDataSy nc('ftp_fa cilitySet' , 'ftp_fac ilitycode' , vlc_user SiteId); | |
| 147 | if (vlc_ facilityDa ta != null ) { | |
| 148 | if ( vlc_facili tyData.d.f tp_facilit ycode != n ull) { vlc _UserSiteN o = vlc_fa cilityData .d.ftp_fac ilitycode; } | |
| 149 | } | |
| 150 | } | |
| 151 | } | |
| 152 | catch (err) { | |
| 153 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_for mLoad): ' + err.mess age); | |
| 154 | } | |
| 155 | } | |
| 156 | ||
| 157 | function v lc_vistaLo gin() { | |
| 158 | try { | |
| 159 | // Check for SSOi Login | |
| 160 | va r vlc_ssoi Checked = document.g etElementB yId("ssoic heck").che cked; | |
| 161 | if (vlc_ssoi Checked) { | |
| 162 | //Perfor m SSOi Log in | |
| 163 | vlc_ssoi Login(); | |
| 164 | return f alse; | |
| 165 | } | |
| 166 | ||
| 167 | // Perform No n SSOi Log in | |
| 168 | // Get Login Field data | |
| 169 | va r vlc_acce ssCode = $ ('#vlc_acc essCode'). val(); | |
| 170 | va r vlc_esig natureCode = $('#vlc _esignatur eCode').va l(); | |
| 171 | va r vlc_veri fyCode = $ ('#vlc_ver ifyCode'). val(); | |
| 172 | // Verify tha t fields a re not emp ty | |
| 173 | if (vlc_acce ssCode == null || vl c_accessCo de == "") { alert("P lease ente r your VIS TA Access Code!"); r eturn fals e; } | |
| 174 | if (vlc_esig natureCode == null | | vlc_esig natureCode == "") { alert("Ple ase enter your VISTA eSignatur e Code!"); return fa lse; } | |
| 175 | if (vlc_veri fyCode == null || vl c_verifyCo de == "") { alert("P lease ente r your VIS TA Verify Code!"); r eturn fals e; } | |
| 176 | ||
| 177 | // Disable lo gin fields and butto n | |
| 178 | do cument.get ElementByI d('vlc_acc essCode'). disabled = true; | |
| 179 | do cument.get ElementByI d('vlc_esi gnatureCod e').disabl ed = true; | |
| 180 | do cument.get ElementByI d('vlc_ver ifyCode'). disabled = true; | |
| 181 | do cument.get ElementByI d('vlc_log inbuttonid ').disable d = true; | |
| 182 | ||
| 183 | // Show Busy Spinner | |
| 184 | do cument.get ElementByI d("BusySpi nner").sty le.display = "inline -block"; | |
| 185 | ||
| 186 | // Process Vi stA Login using VIA web servic e | |
| 187 | va r vlc_viaL ogin = new Object(); | |
| 188 | vl c_viaLogin .AccessCod e = vlc_ac cessCode; | |
| 189 | vl c_viaLogin .VerifyCod e = vlc_ve rifyCode; | |
| 190 | vl c_viaLogin .SiteId = vlc_UserSi teNo.toStr ing(); | |
| 191 | vl c_viaLogin .Target = ""; | |
| 192 | ||
| 193 | va r vlc_logi nResponse = ""; | |
| 194 | ||
| 195 | $. ajax({ | |
| 196 | type: "P OST", | |
| 197 | url: vlc _ViaLoginU rl, | |
| 198 | data: JS ON.stringi fy(vlc_via Login), | |
| 199 | contentT ype: "appl ication/js on; charse t=utf-8", | |
| 200 | dataType : "json", | |
| 201 | success: function (data) { | |
| 202 | vlc_ loginRespo nse = data ; | |
| 203 | vlc_ vistaLogin _response( null, vlc_ loginRespo nse); | |
| 204 | }, | |
| 205 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 206 | //Sy stem Error | |
| 207 | vlc_ vistaLogin _response( errorThrow n, null); | |
| 208 | }, | |
| 209 | async: t rue, | |
| 210 | cache: f alse | |
| 211 | }) ; | |
| 212 | } | |
| 213 | catch (err) { | |
| 214 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_vis taLogin): ' + err.me ssage); | |
| 215 | // Hide Busy Spinner | |
| 216 | do cument.get ElementByI d("BusySpi nner").sty le.display = "none"; | |
| 217 | } | |
| 218 | } | |
| 219 | ||
| 220 | function v lc_vistaLo gin_respon se(vlc_err orThrown, vlc_loginR esponse) { | |
| 221 | try { | |
| 222 | va r vlc_ssoi Checked = document.g etElementB yId("ssoic heck").che cked; | |
| 223 | if (vlc_erro rThrown != null) { | |
| 224 | //Genera l Web Serv ice Error | |
| 225 | alert("E rror: The VISTA Logi n Web Serv ice Failed with erro r(" + vlc_ errorThrow n + ") Pl ease try y our login again!"); | |
| 226 | //Enable login fie lds and bu tton | |
| 227 | if (!vlc _ssoiCheck ed) { | |
| 228 | docu ment.getEl ementById( 'vlc_acces sCode').di sabled = f alse; | |
| 229 | docu ment.getEl ementById( 'vlc_verif yCode').di sabled = f alse; | |
| 230 | } | |
| 231 | document .getElemen tById('vlc _esignatur eCode').di sabled = f alse; | |
| 232 | document .getElemen tById('vlc _loginbutt onid').dis abled = fa lse; | |
| 233 | ||
| 234 | //Hide B usy Spinne r | |
| 235 | document .getElemen tById("Bus ySpinner") .style.dis play = "no ne"; | |
| 236 | return f alse; | |
| 237 | } | |
| 238 | if (vlc_logi nResponse. ErrorOccur red == tru e) { | |
| 239 | alert("E rror: The VISTA Logi n Web Serv ice Failed with erro r(" + vlc_ loginRespo nse.ErrorM essage + " ) Please try your l ogin again !"); | |
| 240 | //Enable login fie lds and bu tton | |
| 241 | if (!vlc _ssoiCheck ed) { | |
| 242 | docu ment.getEl ementById( 'vlc_acces sCode').di sabled = f alse; | |
| 243 | docu ment.getEl ementById( 'vlc_verif yCode').di sabled = f alse; | |
| 244 | } | |
| 245 | document .getElemen tById('vlc _esignatur eCode').di sabled = f alse; | |
| 246 | document .getElemen tById('vlc _loginbutt onid').dis abled = fa lse; | |
| 247 | ||
| 248 | //Hide B usy Spinne r | |
| 249 | document .getElemen tById("Bus ySpinner") .style.dis play = "no ne"; | |
| 250 | return f alse; | |
| 251 | } | |
| 252 | el se { | |
| 253 | //Get se ssionid/to ken full V istA user name and V istaDUZ(IE N) | |
| 254 | var vlc_ duz = ""; | |
| 255 | var vlc_ providerna me = ""; | |
| 256 | var vlc_ vistaduz = ""; | |
| 257 | ||
| 258 | if (vlc_ loginRespo nse.Data[0 ].Duz != n ull) { vlc _duz = vlc _loginResp onse.Data[ 0].Duz; } | |
| 259 | if (vlc_ loginRespo nse.Data[0 ].Provider Name != nu ll) { var vlc_provid ername = v lc_loginRe sponse.Dat a[0].Provi derName; } | |
| 260 | if (vlc_ loginRespo nse.Data[0 ].VistaDUZ != null) { vlc_vist aduz = vlc _loginResp onse.Data[ 0].VistaDU Z; } | |
| 261 | ||
| 262 | //Check that there are value s returned | |
| 263 | if (vlc_ duz == "" || vlc_pro vidername == "") { | |
| 264 | //Ch eck for Fa ult, set d efault mes sage | |
| 265 | var vlc_viaLog inFault = "The Login is invali d, please try your l ogin again !"; | |
| 266 | if ( vlc_loginR esponse.Da ta[0].Faul t != null) { vlc_via LoginFault = "The Lo gin is inv alid, " + vlc_loginR esponse.Da ta[0].Faul t.Message; } | |
| 267 | aler t("Error: " + vlc_vi aLoginFaul t); | |
| 268 | //En able login fields an d button | |
| 269 | if ( !vlc_ssoiC hecked) { | |
| 270 | document.g etElementB yId('vlc_a ccessCode' ).disabled = false; | |
| 271 | document.g etElementB yId('vlc_v erifyCode' ).disabled = false; | |
| 272 | } | |
| 273 | docu ment.getEl ementById( 'vlc_esign atureCode' ).disabled = false; | |
| 274 | docu ment.getEl ementById( 'vlc_login buttonid') .disabled = false; | |
| 275 | ||
| 276 | //Hi de Busy Sp inner | |
| 277 | docu ment.getEl ementById( "BusySpinn er").style .display = "none"; | |
| 278 | retu rn false; | |
| 279 | } | |
| 280 | ||
| 281 | //Valida te the use r's eSigna ture code using VIA services b efore cont inuing to close/hide this wind ow | |
| 282 | var vlc_ esignature Code = $(' #vlc_esign atureCode' ).val(); | |
| 283 | vialib_i sValidEsig (vlc_consu mingApp, v lc_consumi ngAppToken , vlc_cons umingAppPa ssword, vl c_baseServ iceEndpoin tUrl, vlc_ providerna me, vlc_du z, vlc_Use rSiteNo, v lc_esignat ureCode, v lc_isValid Esig_Respo nse, { vlc _duz: vlc_ duz, vlc_p rovidernam e: vlc_pro vidername, vlc_vista duz: vlc_v istaduz }) ; | |
| 284 | } | |
| 285 | } | |
| 286 | catch (err) { | |
| 287 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_vis taLogin_re sponse): ' + err.mes sage); | |
| 288 | // Hide Busy Spinner | |
| 289 | do cument.get ElementByI d("BusySpi nner").sty le.display = "none"; | |
| 290 | } | |
| 291 | } | |
| 292 | ||
| 293 | function v lc_isValid Esig_Respo nse(vlc_er rorThrown, vlc_isVal idEsigResp onse, vlc_ passThroug hObject) { | |
| 294 | //Get Login Fiel d data | |
| 295 | var vl c_accessCo de = $('#v lc_accessC ode').val( ); | |
| 296 | var vl c_esignatu reCode = $ ('#vlc_esi gnatureCod e').val(); | |
| 297 | var vl c_verifyCo de = $('#v lc_verifyC ode').val( ); | |
| 298 | ||
| 299 | if (vl c_errorThr own != nul l) { | |
| 300 | al ert("Error validatin g eSignatu re code: " + vlc_err orThrown); | |
| 301 | do cument.get ElementByI d('vlc_acc essCode'). disabled = false; | |
| 302 | do cument.get ElementByI d('vlc_esi gnatureCod e').disabl ed = false ; | |
| 303 | do cument.get ElementByI d('vlc_ver ifyCode'). disabled = false; | |
| 304 | do cument.get ElementByI d('vlc_log inbuttonid ').disable d = false; | |
| 305 | do cument.get ElementByI d('vlc_esi gnatureCod e').value = ''; | |
| 306 | do cument.get ElementByI d("BusySpi nner").sty le.display = "none"; | |
| 307 | re turn false ; | |
| 308 | } | |
| 309 | else { | |
| 310 | if (vlc_isVa lidEsigRes ponse.getE lementsByT agName("fa ult").leng th > 0) { | |
| 311 | alert("E rror valid ating eSig nature cod e: " + vlc _isValidEs igResponse .getElemen tsByTagNam e("fault") [0].textCo ntent); | |
| 312 | document .getElemen tById('vlc _accessCod e').disabl ed = false ; | |
| 313 | document .getElemen tById('vlc _esignatur eCode').di sabled = f alse; | |
| 314 | document .getElemen tById('vlc _verifyCod e').disabl ed = false ; | |
| 315 | document .getElemen tById('vlc _loginbutt onid').dis abled = fa lse; | |
| 316 | document .getElemen tById('vlc _esignatur eCode').va lue = ''; | |
| 317 | document .getElemen tById("Bus ySpinner") .style.dis play = "no ne"; | |
| 318 | return f alse; | |
| 319 | } | |
| 320 | el se { | |
| 321 | if (vlc_ isValidEsi gResponse. getElement sByTagName ("text").l ength > 0) { | |
| 322 | if ( vlc_isVali dEsigRespo nse.getEle mentsByTag Name("text ")[0].text Content == "FALSE") { | |
| 323 | alert("Inv alid eSign ature code !"); | |
| 324 | document.g etElementB yId('vlc_a ccessCode' ).disabled = false; | |
| 325 | document.g etElementB yId('vlc_e signatureC ode').disa bled = fal se; | |
| 326 | document.g etElementB yId('vlc_v erifyCode' ).disabled = false; | |
| 327 | document.g etElementB yId('vlc_l oginbutton id').disab led = fals e; | |
| 328 | document.g etElementB yId('vlc_e signatureC ode').valu e = ''; | |
| 329 | document.g etElementB yId("BusyS pinner").s tyle.displ ay = "none "; | |
| 330 | return fal se; | |
| 331 | } | |
| 332 | else { | |
| 333 | //esignatu re code is valid | |
| 334 | //Write va lues to Br owser Cook ie | |
| 335 | vlc_setCoo kie("viase ssionlink" , vlc_pass ThroughObj ect.vlc_du z + "~~~~" + vlc_pas sThroughOb ject.vlc_p rovidernam e + "~~~~" + vlc_esi gnatureCod e, vlc_Via LoginMinut es); | |
| 336 | ||
| 337 | //Update C ross Refer ence | |
| 338 | vlc_update CrossRefer ence(vlc_u serId, vlc _userName, vlc_passT hroughObje ct.vlc_vis taduz, vlc _passThrou ghObject.v lc_provide rname); | |
| 339 | ||
| 340 | //Clear lo gin fields and hide control | |
| 341 | if (vlc_US Ddata != " USD") { | |
| 342 | parent .Xrm.Page. ui.clearFo rmNotifica tion("VIAS ERVICE"); | |
| 343 | } | |
| 344 | document.g etElementB yId('vlc_a ccessCode' ).disabled = false; | |
| 345 | document.g etElementB yId('vlc_e signatureC ode').disa bled = fal se; | |
| 346 | document.g etElementB yId('vlc_v erifyCode' ).disabled = false; | |
| 347 | document.g etElementB yId('vlc_l oginbutton id').disab led = fals e; | |
| 348 | document.g etElementB yId('vlc_a ccessCode' ).value = ''; | |
| 349 | document.g etElementB yId('vlc_e signatureC ode').valu e = ''; | |
| 350 | document.g etElementB yId('vlc_v erifyCode' ).value = ''; | |
| 351 | //Hide the login tab | |
| 352 | if (vlc_US Ddata != " USD") { | |
| 353 | parent .Xrm.Page. ui.tabs.ge t('Tab_Vis tALogin'). setVisible (false); | |
| 354 | ||
| 355 | //**TR IGGER FORM SCRIPT CO DE TO RECR EATE DEPEN DENT WEB R ESOURCES** | |
| 356 | parent .vcmn_init ViaDropdow nControls( ); | |
| 357 | } | |
| 358 | ||
| 359 | if (vlc_US Ddata == " USD") { | |
| 360 | //Call USD Funct ion passin g VISTA da ta | |
| 361 | var vl c_pData = ["AccessCo de=" + vlc _accessCod e, "Verify Code=" + v lc_verifyC ode, "Site Number=" + vlc_UserS iteNo.toSt ring(), "E SignatureC ode=" + vl c_esignatu reCode]; | |
| 362 | VCCM.U SDHelper.C opyDataToR eplacement Parameters ("VISTA", vlc_pData, true); | |
| 363 | ||
| 364 | //Wait a few sec onds befor e closing tab to all ow USD to receive th e values | |
| 365 | setTim eout(funct ion () { | |
| 366 | // Hide Busy Spinner | |
| 367 | do cument.get ElementByI d("BusySpi nner").sty le.display = "none"; | |
| 368 | VC CM.USDHelp er.CallUSD Action("Cr edential M anager", " Close"); | |
| 369 | }, 100 0); | |
| 370 | } | |
| 371 | else { | |
| 372 | //Hide Busy Spin ner | |
| 373 | docume nt.getElem entById("B usySpinner ").style.d isplay = " none"; | |
| 374 | } | |
| 375 | } | |
| 376 | } | |
| 377 | } | |
| 378 | } | |
| 379 | } | |
| 380 | ||
| 381 | function v lc_loginKe yPress(eve nt) { | |
| 382 | try { | |
| 383 | // Determine if 'enter' key was p ressed if so attempt login | |
| 384 | va r vlc_keyp ressed = e vent.which || event. keyCode; | |
| 385 | if (vlc_keyp ressed == 13) { vlc_ vistaLogin (); } | |
| 386 | } | |
| 387 | catch (err) { | |
| 388 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_log inKeyPress ): ' + err .message); | |
| 389 | } | |
| 390 | } | |
| 391 | ||
| 392 | function v lc_getCook ie(cname) { | |
| 393 | try { | |
| 394 | va r name = c name + "=" ; | |
| 395 | va r ca = doc ument.cook ie.split(' ;'); | |
| 396 | fo r (var i = 0; i < ca .length; i ++) { | |
| 397 | var c = ca[i]; | |
| 398 | while (c .charAt(0) == ' ') { | |
| 399 | c = c.substrin g(1); | |
| 400 | } | |
| 401 | if (c.in dexOf(name ) == 0) { | |
| 402 | retu rn c.subst ring(name. length, c. length); | |
| 403 | } | |
| 404 | } | |
| 405 | re turn ""; | |
| 406 | } | |
| 407 | catch (err) { | |
| 408 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_get Cookie): ' + err.mes sage); | |
| 409 | } | |
| 410 | } | |
| 411 | ||
| 412 | function v lc_setCook ie(cname, cvalue, ex minutes) { | |
| 413 | try { | |
| 414 | va r d = new Date(); | |
| 415 | d. setMinutes (d.getMinu tes() + (e xminutes)) ; | |
| 416 | va r expires = "expires =" + d.toU TCString() ; | |
| 417 | do cument.coo kie = cnam e + "=" + cvalue + " ; " + expi res + "; p ath=/" + v lc_orgName + "/"; | |
| 418 | } | |
| 419 | catch (err) { | |
| 420 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_get Cookie): ' + err.mes sage); | |
| 421 | } | |
| 422 | } | |
| 423 | ||
| 424 | function v lc_updateC rossRefere nce(vlc_cr mUserGuid, vlc_crmUs erName, vl c_viaUserI en, vlc_vi aUserName) { | |
| 425 | try { | |
| 426 | // Check that the requi red parame ters has a value | |
| 427 | if (vlc_crmU serGuid != "" && vlc _crmUserGu id != null && vlc_vi aUserIen ! = "" && vl c_viaUserI en != null ) { | |
| 428 | //Check if a recor d already exists for the CRM u ser, if so preserve the cross reference record gui d | |
| 429 | var vlc_ crossRefer enceId = n ull; | |
| 430 | var vlc_ conditiona lFilter = "ftp_crmus er/Id eq ( guid'" + v lc_crmUser Guid + "') "; | |
| 431 | var vlc_ crossRefer enceData = vlc_getMu ltipleEnti tyDataSync ('ftp_user idSet', 'f tp_useridI d', vlc_co nditionalF ilter, 'ft p_name', ' asc', 0); | |
| 432 | if (vlc_ crossRefer enceData ! = null) { | |
| 433 | for (var i = 0 ; i <= vlc _crossRefe renceData. d.results. length - 1 ; i++) { | |
| 434 | //Get Info | |
| 435 | if (vlc_cr ossReferen ceData.d.r esults[i]. ftp_userid Id != null ) { vlc_cr ossReferen ceId = vlc _crossRefe renceData. d.results[ i].ftp_use ridId; } | |
| 436 | break; | |
| 437 | } | |
| 438 | } | |
| 439 | //Determ ine to add new recor d or updat e existing | |
| 440 | if (vlc_ crossRefer enceId != null) { | |
| 441 | //Ex isting Rec ord, perfo rm update | |
| 442 | var vlc_crossR eferenceRe cord = new Object(); | |
| 443 | vlc_ crossRefer enceRecord .ftp_crmgu id = vlc_c rmUserGuid ; | |
| 444 | vlc_ crossRefer enceRecord .ftp_vista duz = vlc_ viaUserIen ; | |
| 445 | vlc_ crossRefer enceRecord .ftp_vista username = vlc_viaUs erName; | |
| 446 | vlc_ crossRefer enceRecord .ftp_crmus er = { Id: vlc_crmUs erGuid, Lo gicalName: "systemus er", Name: vlc_crmUs erName }; | |
| 447 | vlc_ crossRefer enceRecord .ftp_name = "CROSS R EFERENCE - " + vlc_c rmUserName ; | |
| 448 | vlc_ crossRefer enceRecord .ftp_lastv ialogin = new Date() ; | |
| 449 | ||
| 450 | //ma ke it a js on object | |
| 451 | var jsonEntity = JSON.st ringify(vl c_crossRef erenceReco rd); | |
| 452 | ||
| 453 | $.aj ax({ | |
| 454 | type: "POS T", | |
| 455 | contentTyp e: "applic ation/json ; charset= utf-8", | |
| 456 | datatype: "json", | |
| 457 | url: vlc_s erverUrl + vlc_crmOd ataEndPoin t + "/" + 'ftp_useri dSet' + "( guid'" + v lc_crossRe ferenceId + "')", | |
| 458 | data: json Entity, | |
| 459 | beforeSend : function (XMLHttpR equest) { | |
| 460 | XMLHtt pRequest.s etRequestH eader("X-H TTP-Method ", "MERGE" ); | |
| 461 | }, | |
| 462 | success: f unction (t extStatus, XmlHttpRe quest) { | |
| 463 | //aler t("The Vis ta User Cr oss Refere nce Record was updat ed success fully."); | |
| 464 | }, | |
| 465 | error: fun ction (Xml HttpReques t, textSta tus, error Thrown) { | |
| 466 | alert( 'Ajax Erro r in Updat e of Vista User Cros s Referenc e Record: ' + errorT hrown); | |
| 467 | } | |
| 468 | }); | |
| 469 | } | |
| 470 | else { | |
| 471 | //Ne w Record, perform ad d | |
| 472 | var vlc_crossR eferenceRe cord = new Object(); | |
| 473 | vlc_ crossRefer enceRecord .ftp_crmgu id = vlc_c rmUserGuid ; | |
| 474 | vlc_ crossRefer enceRecord .ftp_vista duz = vlc_ viaUserIen ; | |
| 475 | vlc_ crossRefer enceRecord .ftp_vista username = vlc_viaUs erName; | |
| 476 | vlc_ crossRefer enceRecord .ftp_crmus er = { Id: vlc_crmUs erGuid, Lo gicalName: "systemus er", Name: vlc_crmUs erName }; | |
| 477 | vlc_ crossRefer enceRecord .ftp_name = "CROSS R EFERENCE - " + vlc_c rmUserName ; | |
| 478 | vlc_ crossRefer enceRecord .ftp_lastv ialogin = new Date() ; | |
| 479 | ||
| 480 | //ma ke it a js on object | |
| 481 | var jsonEntity = JSON.st ringify(vl c_crossRef erenceReco rd); | |
| 482 | ||
| 483 | $.aj ax({ | |
| 484 | type: "POS T", | |
| 485 | contentTyp e: "applic ation/json ; charset= utf-8", | |
| 486 | datatype: "json", | |
| 487 | url: vlc_s erverUrl + vlc_crmOd ataEndPoin t + "/" + 'ftp_useri dSet', | |
| 488 | data: json Entity, | |
| 489 | beforeSend : function (XMLHttpR equest) { | |
| 490 | XMLHtt pRequest.s etRequestH eader('Acc ept', 'app lication/j son'); | |
| 491 | }, | |
| 492 | success: f unction (t extStatus, XmlHttpRe quest) { | |
| 493 | //aler t("The Vis ta User Cr oss Refere nce Record was added successfu lly."); | |
| 494 | }, | |
| 495 | error: fun ction (Xml HttpReques t, textSta tus, error Thrown) { | |
| 496 | alert( 'Ajax Erro r in Addin g a Vista User Cross Reference Record: ' + errorTh rown); | |
| 497 | } | |
| 498 | }); | |
| 499 | } | |
| 500 | } | |
| 501 | } | |
| 502 | catch (err) { | |
| 503 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_upd ateCrossRe ference): ' + err.me ssage); | |
| 504 | } | |
| 505 | } | |
| 506 | ||
| 507 | function v lc_ssoiChe cked() { | |
| 508 | try { | |
| 509 | // Update Log in screen based on s soi checke d/unchecke d | |
| 510 | va r vlc_ssoi Checked = document.g etElementB yId("ssoic heck").che cked; | |
| 511 | if (vlc_ssoi Checked) { | |
| 512 | //update labels | |
| 513 | document .getElemen tById("lbl SubTitle") .innerHTML = "Enter your eSign ature Code &nb sp; & nbsp;  ; (Pl ease note that SSOi is current ly not sup ported for automatic VSE login !)"; | |
| 514 | document .getElemen tById("lbl SubTitle") .title = " Enter your eSignatur e Code (Please n ote that S SOi is cur rently not supported for autom atic VSE l ogin !)"; | |
| 515 | //Disabl e login fi elds | |
| 516 | document .getElemen tById('vlc _accessCod e').disabl ed = true; | |
| 517 | document .getElemen tById('vlc _verifyCod e').disabl ed = true; | |
| 518 | //Initia lize PIV C ard Login Form | |
| 519 | var apiN ame = "sta rtLoginSSO i"; | |
| 520 | try { | |
| 521 | SSOi Services.s tartLogin( vlc_ViaSSO iPivCardUr l); | |
| 522 | } catch (err) { | |
| 523 | aler t("PIV Car d Error: " + apiName + ': ' + err.messag e); | |
| 524 | } | |
| 525 | } | |
| 526 | el se { | |
| 527 | //update labels | |
| 528 | document .getElemen tById("lbl SubTitle") .innerHTML = "Enter your Acces s Code, Ve rify Code and eSigna ture Code" ; | |
| 529 | document .getElemen tById("lbl SubTitle") .title = " Enter your Access Co de, Verify Code and eSignature Code"; | |
| 530 | //Enable login fie lds | |
| 531 | document .getElemen tById('vlc _accessCod e').disabl ed = false ; | |
| 532 | document .getElemen tById('vlc _verifyCod e').disabl ed = false ; | |
| 533 | } | |
| 534 | } | |
| 535 | catch (err) { | |
| 536 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_sso iChecked): ' + err.m essage); | |
| 537 | } | |
| 538 | } | |
| 539 | ||
| 540 | function v lc_ssoiLog in() { | |
| 541 | try { | |
| 542 | // Verify tha t required URL's hav e data | |
| 543 | if (vlc_ViaS SOiLoginUr l == '' || vlc_ViaSS OiRefreshT okenUrl == '' || vlc _ViaSSOiPi vCardUrl = = '') { | |
| 544 | alert("T he CRM Set tings enti ty is miss ing the re quired VIA SSOi URL data, plea se contact technical support f or assista nce!"); | |
| 545 | return f alse; | |
| 546 | } | |
| 547 | ||
| 548 | // Get Login Field data | |
| 549 | va r vlc_esig natureCode = $('#vlc _esignatur eCode').va l(); | |
| 550 | // Verify tha t fields a re not emp ty | |
| 551 | if (vlc_esig natureCode == null | | vlc_esig natureCode == "") { alert("Ple ase enter your VISTA eSignatur e Code!"); return fa lse; } | |
| 552 | // Disable lo gin fields and butto n | |
| 553 | do cument.get ElementByI d('vlc_esi gnatureCod e').disabl ed = true; | |
| 554 | do cument.get ElementByI d('vlc_log inbuttonid ').disable d = true; | |
| 555 | ||
| 556 | // Show Busy Spinner | |
| 557 | do cument.get ElementByI d("BusySpi nner").sty le.display = "inline -block"; | |
| 558 | // Check for SAML Token | |
| 559 | if (isBlank( _SAMLToken )) { | |
| 560 | SSOiServ ices.refre shSSOi(vlc _ViaSSOiRe freshToken Url, callL oginVIA_SS Oi); | |
| 561 | } else { | |
| 562 | callLogi nVIA_SSOi( ); | |
| 563 | } | |
| 564 | } | |
| 565 | catch (err) { | |
| 566 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_sso iLogin): ' + err.mes sage); | |
| 567 | // Hide Busy Spinner | |
| 568 | do cument.get ElementByI d("BusySpi nner").sty le.display = "none"; | |
| 569 | } | |
| 570 | } | |
| 571 | ||
| 572 | function i sBlank(val ue) { | |
| 573 | return (value == = undefine d || value == null | | value.le ngth <= 0) ? true : false; | |
| 574 | } | |
| 575 | ||
| 576 | function c allLoginVI A_SSOi() { | |
| 577 | ||
| 578 | var ap iName = "l oginVIA: S SOi"; | |
| 579 | var si teId = vlc _UserSiteN o; | |
| 580 | ||
| 581 | try { | |
| 582 | // Check Toke n | |
| 583 | if (isBlank( _SAMLToken ) || _SAML Token == " undefined" ) { | |
| 584 | //SSOi t oken faile d | |
| 585 | alert("N o SSOi tok en retriev ed. SSOi l ogin was n ot success ful, pleas e try agai n."); | |
| 586 | document .getElemen tById("Bus ySpinner") .style.dis play = "no ne"; | |
| 587 | document .getElemen tById('vlc _esignatur eCode').di sabled = f alse; | |
| 588 | document .getElemen tById('vlc _loginbutt onid').dis abled = fa lse; | |
| 589 | } else { | |
| 590 | if (apiN ame !== nu ll && !isB lank(_SAML Token) && !isBlank(s iteId)) { | |
| 591 | //Ca ll VIA_SSO i_Login se rvice | |
| 592 | vlc_ loginVIA_S SOi(siteId , _SAMLTok en, _IAMSe ssion); | |
| 593 | } else { | |
| 594 | aler t("Please verify the SSOi logi n and that the Site ID is fill ed out, pl ease try a gain."); | |
| 595 | docu ment.getEl ementById( "BusySpinn er").style .display = "none"; | |
| 596 | docu ment.getEl ementById( 'vlc_esign atureCode' ).disabled = false; | |
| 597 | docu ment.getEl ementById( 'vlc_login buttonid') .disabled = false; | |
| 598 | } | |
| 599 | } | |
| 600 | } catc h (err) { | |
| 601 | al ert(apiNam e + ': ' + err.messa ge); | |
| 602 | } | |
| 603 | } | |
| 604 | ||
| 605 | function v lc_loginVI A_SSOi_OLD (siteId, s amlToken, iamSession ) { | |
| 606 | //This version o f the comm and has be en depreca ted | |
| 607 | //This version w as used wi th version 2.0, nw r eplaced by 2.1 | |
| 608 | try { | |
| 609 | va r b64token = window. btoa(samlT oken); | |
| 610 | va r viamessa ge = {}; | |
| 611 | vi amessage.A ccessCode = "donotus e"; | |
| 612 | vi amessage.V erifyCode = "donotus e"; | |
| 613 | vi amessage.S iteId = si teId; | |
| 614 | ||
| 615 | va r vlc_logi nResponse = ""; | |
| 616 | ||
| 617 | $. ajax({ | |
| 618 | url: vlc _ViaSSOiLo ginUrl, | |
| 619 | type: 'P OST', | |
| 620 | beforeSe nd: functi on (reques t) { | |
| 621 | requ est.setReq uestHeader ("CRMSSOiS ession", i amSession) , | |
| 622 | requ est.setReq uestHeader ("CRMSSOiS essionSaml ", b64toke n) | |
| 623 | }, | |
| 624 | dataType : 'json', | |
| 625 | data: JS ON.stringi fy(viamess age), | |
| 626 | contentT ype: 'appl ication/js on', | |
| 627 | success: function (data) { | |
| 628 | vlc_ loginRespo nse = data ; | |
| 629 | vlc_ vistaLogin _response( null, vlc_ loginRespo nse); | |
| 630 | }, | |
| 631 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 632 | //Sy stem Error | |
| 633 | vlc_ vistaLogin _response( errorThrow n, null); | |
| 634 | }, | |
| 635 | async: t rue, | |
| 636 | cache: f alse | |
| 637 | }) ; | |
| 638 | } | |
| 639 | catch (err) { | |
| 640 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_log inVIA_SSOi ): ' + err .message); | |
| 641 | } | |
| 642 | } | |
| 643 | ||
| 644 | function v lc_loginVI A_SSOi(sit eId, samlT oken, iamS ession) { | |
| 645 | try { | |
| 646 | va r b64token = window. btoa(samlT oken); | |
| 647 | va r viamessa ge = {}; | |
| 648 | vi amessage.S iteId = si teId; | |
| 649 | vi amessage.S amlToken = b64token; | |
| 650 | ||
| 651 | va r vlc_logi nResponse = ""; | |
| 652 | ||
| 653 | $. ajax({ | |
| 654 | url: vlc _ViaSSOiLo ginUrl, | |
| 655 | type: 'P OST', | |
| 656 | dataType : 'json', | |
| 657 | data: JS ON.stringi fy(viamess age), | |
| 658 | contentT ype: 'appl ication/js on', | |
| 659 | success: function (data) { | |
| 660 | vlc_ loginRespo nse = data ; | |
| 661 | vlc_ vistaLogin _response( null, vlc_ loginRespo nse); | |
| 662 | }, | |
| 663 | error: f unction (j qXHR, text Status, er rorThrown) { | |
| 664 | //Sy stem Error | |
| 665 | vlc_ vistaLogin _response( errorThrow n, null); | |
| 666 | }, | |
| 667 | async: t rue, | |
| 668 | cache: f alse | |
| 669 | }) ; | |
| 670 | } | |
| 671 | catch (err) { | |
| 672 | al ert('VistA Login Con trol Web R esource Fu nction Err or(vlc_log inVIA_SSOi ): ' + err .message); | |
| 673 | } | |
| 674 | } | |
| 675 | ||
| 676 | function v lc_execute CrmOdataGe tRequest(v lc_jsonQue ry, vlc_aS ync, vlc_a SyncCallba ck, vlc_sk ipCount, v lc_optionA rray) { | |
| 677 | //This function executes a CRM Odata web servi ce call to retrieve Crm data | |
| 678 | //*vlc _jsonQuery * - a prop erly forma tted CRM O data Query string (r equired) | |
| 679 | //*vlc _aSync* - specify 't rue' to ex ecute asyn chronously otherwise 'false' ( required) | |
| 680 | //*vlc _aSyncCall back* - sp ecify the name of th e return f unction to call upon completio n (require d if vlc_a Sync = tru e. Otherw ise '') | |
| 681 | //*vlc _skipCount * - Initia l setting is always '0', incre ments by 5 0 per CRM SDK Odata standards (required) | |
| 682 | //*vlc _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) | |
| 683 | try { | |
| 684 | va r vlc_enti tyData = n ull; | |
| 685 | $. ajax({ | |
| 686 | type: 'G ET', | |
| 687 | contentT ype: 'appl ication/js on; charse t=utf-8', | |
| 688 | datatype : 'json', | |
| 689 | url: vlc _jsonQuery , | |
| 690 | beforeSe nd: functi on (XMLHtt pRequest) { | |
| 691 | XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json'); | |
| 692 | }, | |
| 693 | success: function (data, tex tStatus, X mlHttpRequ est) { | |
| 694 | vlc_ entityData = data; | |
| 695 | if ( vlc_aSync == true) { | |
| 696 | vlc_aSyncC allback(vl c_entityDa ta, vlc_sk ipCount, v lc_optionA rray); | |
| 697 | } | |
| 698 | }, | |
| 699 | error: f unction (X MLHttpRequ est, textS tatus, err orThrown) { | |
| 700 | aler t('Fail: A jax Error in vlc_exe cuteCrmOda taGetReque st: ' + er rorThrown + " Reques t: " + vlc _jsonQuery ); | |
| 701 | }, | |
| 702 | async: v lc_aSync, | |
| 703 | cache: f alse | |
| 704 | }) ; | |
| 705 | re turn vlc_e ntityData; | |
| 706 | } | |
| 707 | catch (err) { | |
| 708 | al ert('An er ror occure d in the v lc_execute CrmOdataGe tRequest f unction. Error Deta il Message : ' + err) ; | |
| 709 | } | |
| 710 | } | |
| 711 | ||
| 712 | function v lc_getMult ipleEntity DataAsync( vlc_entity SetName, v lc_attribu teSet, vlc _condition alFilter, vlc_sortAt tribute, v lc_sortDir ection, vl c_skipCoun t, vlc_aSy ncCallback , vlc_opti onArray) { | |
| 713 | //This function returns a CRM JSON d ataset for all entit y records matching c riteria pr ovided Asy ncronously | |
| 714 | //*vlc _entitySet Name* - is the name of the ent ity set e. g 'Contact Set' | |
| 715 | //*vlc _attribute Set* - is a string containing the Crm A ttributes to retriev e e.g. 'Fi rstName, L astName, T elephone1, EMailAddr ess1' | |
| 716 | //*vlc _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 | |
| 717 | //*vlc _sortAttri bute* - is a string containing the name of the att ribute to sort the r esult set by e.g. 'L astName' | |
| 718 | //*vlc _sortDirec tion* - is a string specifying the sort as Ascendi ng or Desc ending e.g . 'asc' or 'desc' | |
| 719 | //*vlc _skipCount * - is the starting point in t he result (use if mo re than 50 ), (Put 0 if not use d) | |
| 720 | //*vlc _aSyncCall back* - is the name of the fun ction to c all when r eturning t he result | |
| 721 | //*vlc _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 | |
| 722 | ||
| 723 | try { | |
| 724 | va r vlc_json Query = vl c_serverUr l + vlc_cr mOdataEndP oint + '/' + vlc_ent itySetName + '?$sele ct=' + vlc _attribute Set + '&$f ilter=' + vlc_condit ionalFilte r + '&$ord erby=' + v lc_sortAtt ribute + ' ' + vlc_s ortDirecti on + '&$sk ip=' + vlc _skipCount ; | |
| 725 | vl c_executeC rmOdataGet Request(vl c_jsonQuer y, true, v lc_aSyncCa llback, vl c_skipCoun t, vlc_opt ionArray); | |
| 726 | } | |
| 727 | catch (err) { | |
| 728 | al ert('An er ror occure d in the v lc_getMult ipleEntity DataAsync function. Error Det ail Messag e: ' + err ); | |
| 729 | } | |
| 730 | } | |
| 731 | ||
| 732 | function v lc_getMult ipleEntity DataSync(v lc_entityS etName, vl c_attribut eSet, vlc_ conditiona lFilter, v lc_sortAtt ribute, vl c_sortDire ction, vlc _skipCount ) { | |
| 733 | //This function returns a CRM JSON d ataset for all entit y records matching c riteria pr ovided Syn cronously | |
| 734 | //*vlc _entitySet Name* - is the name of the ent ity set e. g 'Contact Set' | |
| 735 | //*vlc _attribute Set* - is a string containing the Crm A ttributes to retriev e e.g. 'Fi rstName, L astName, T elephone1, EMailAddr ess1' | |
| 736 | //*vlc _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 | |
| 737 | //*vlc _sortAttri bute* - is a string containing the name of the att ribute to sort the r esult set by e.g. 'L astName' | |
| 738 | //*vlc _sortDirec tion* - is a string specifying the sort as Ascendi ng or Desc ending e.g . 'asc' or 'desc' | |
| 739 | //*vlc _skipCount * - is the starting point in t he result (use if mo re than 50 ), (Put 0 if not use d) | |
| 740 | ||
| 741 | try { | |
| 742 | va r vlc_json Query = vl c_serverUr l + vlc_cr mOdataEndP oint + '/' + vlc_ent itySetName + '?$sele ct=' + vlc _attribute Set + '&$f ilter=' + vlc_condit ionalFilte r + '&$ord erby=' + v lc_sortAtt ribute + ' ' + vlc_s ortDirecti on + '&$sk ip=' + vlc _skipCount ; | |
| 743 | va r vlc_enti tyData = v lc_execute CrmOdataGe tRequest(v lc_jsonQue ry, false, '', vlc_s kipCount, null); | |
| 744 | re turn vlc_e ntityData; | |
| 745 | } | |
| 746 | catch (err) { | |
| 747 | al ert('An er ror occure d in the v lc_getMult ipleEntity DataSync f unction. Error Deta il Message : ' + err) ; | |
| 748 | } | |
| 749 | } | |
| 750 | ||
| 751 | function v lc_getSing leEntityDa taSync(vlc _entitySet Name, vlc_ attributeS et, vlc_en tityId) { | |
| 752 | //This function returns a CRM JSON d ataset for a single entity rec ord based on the ent ity id pro vided Sync ronously | |
| 753 | //*vlc _entitySet Name* - is the name of the ent ity set e. g 'Contact Set' | |
| 754 | //*vlc _attribute Set* - is a string containing the Crm A ttributes to retriev e e.g. 'Fi rstName, L astName, T elephone1, EMailAddr ess1' | |
| 755 | //*vlc _entityId* - is the Guid for t he entity record | |
| 756 | ||
| 757 | try { | |
| 758 | va r vlc_enti tyIdNoBrac ket = vlc_ entityId.r eplace(/({ |})/g, '') ; | |
| 759 | va r vlc_sele ctString = '(guid' + "'" + vlc _entityIdN oBracket + "'" + ')? $select=' + vlc_attr ibuteSet; | |
| 760 | va r vlc_json Query = vl c_serverUr l + vlc_cr mOdataEndP oint + '/' + vlc_ent itySetName + vlc_sel ectString; | |
| 761 | va r vlc_enti tyData = v lc_execute CrmOdataGe tRequest(v lc_jsonQue ry, false, '', 0, nu ll); | |
| 762 | re turn vlc_e ntityData; | |
| 763 | } | |
| 764 | catch (err) { | |
| 765 | al ert('An er ror occure d in the v lc_getSing leEntityDa taSync fun ction. Er ror Detail Message: ' + err); | |
| 766 | } | |
| 767 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.