120. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/4/2017 8:32:42 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.

120.1 Files compared

# Location File Last Modified
1 VCCM.zip\VCCM\CRM_solutions\VCCMResources\WebResources ftp_VistAMultiNoteVistaLoginControljsVistaLoginCon810D6C09-5423-E611-9437-0050568D743D Tue Nov 7 11:34:40 2017 UTC
2 VCCM.zip\VCCM\CRM_solutions\VCCMResources\WebResources ftp_VistAMultiNoteVistaLoginControljsVistaLoginCon810D6C09-5423-E611-9437-0050568D743D Mon Dec 4 13:07:48 2017 UTC

120.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 1408
Changed 1 2
Inserted 0 0
Removed 0 0

120.3 Comparison options

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

120.4 Active regular expressions

No regular expressions were active.

120.5 Comparison detail

  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  
  4   //VistaLog inControlS criptLib.j s
  5   //Contains  variables  and funct ions used  by the Vis taLoginCon trol.html  page
  6  
  7   //Static V ariables
  8   var vlc_cr mOdataEndP oint = '/X RMServices /2011/Orga nizationDa ta.svc';
  9   var vlc_co ntext = Ge tGlobalCon text();
  10   var vlc_se rverUrl =  vlc_contex t.getClien tUrl();
  11   var vlc_or gName = vl c_context. getOrgUniq ueName();
  12   var vlc_us erId = vlc _context.g etUserId() ;
  13   var vlc_us erName = v lc_context .getUserNa me();
  14  
  15   //var vlc_ ViaLoginUr l = 'https :// se r
v e r
/WebParts/ dev/api/VI A/LoginVIA /1.0/json'   //OLD MANU AL DEV URL
  16   var vlc_Vi aLoginUrl  = '';
  17   var vlc_us erSiteId =  '';
  18   var vlc_Us erSiteNo =  '';
  19   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)
  20  
  21   //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
  22   var vlc_US Ddata = "" ;
  23  
  24   //VIA SSOi  Settings
  25   var vlc_Vi aSSOiLogin Url = '';
  26   var vlc_Vi aSSOiRefre shTokenUrl  = '';
  27   var vlc_Vi aSSOiPivCa rdUrl = '' ;
  28   var _SAMLT oken = nul l;
  29   var _IAMSe ssion = nu ll;
  30  
  31   function v lc_getQuer yVariable( vlc_variab le) {
  32       try {
  33           // Get a Quer y Variable
  34           va r vlc_quer y = window .location. search.sub string(1);
  35           va r vlc_vars  = vlc_que ry.split(" &");
  36           fo r (var i =  0; i < vl c_vars.len gth; i++)  {
  37                var vlc_ pair = vlc _vars[i].s plit("=");
  38                if (vlc_ pair[0] ==  vlc_varia ble) {
  39                    retu rn decodeU RIComponen t(vlc_pair [1]);
  40                }
  41           }
  42           re turn "";
  43       }
  44       catch  (err) {
  45           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_get QueryVaria ble): ' +  err.messag e);
  46       }
  47   }
  48  
  49   function v lc_Setting sWebServic eURL_respo nse(vlc_se ttingData,  vlc_lastS kip, vlc_V iaLoginUrl _NA) {
  50       try {
  51           // 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
  52           va r vlc_DacU rl = null;
  53           va r vlc_ViaL oginApiUrl  = null;
  54           va r vlc_ViaS SOiLoginAp iUrl = nul l;
  55           fo r (var i =  0; i <= v lc_setting Data.d.res ults.lengt h - 1; i++ ) {
  56                //Get in fo
  57                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;  }
  58                if (vlc_ settingDat a.d.result s[i].ftp_V IALoginURL  != null)  { vlc_ViaL oginApiUrl  = vlc_set tingData.d .results[i ].ftp_VIAL oginURL; }
  59                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; }
  60                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;  }
  61                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; }
  62                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; }
  63                break;
  64           }
  65           if  (vlc_DacU rl != null  && vlc_Vi aLoginApiU rl != null ) {
  66                //Constr uct full w eb service  URL
  67                vlc_ViaL oginUrl =  vlc_DacUrl  + vlc_Via LoginApiUr l;
  68           }
  69           el se {
  70                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");
  71           }
  72           if  (vlc_DacU rl != null  && vlc_Vi aSSOiLogin ApiUrl !=  null) {
  73                //Constr uct full w eb service  URL
  74                vlc_ViaS SOiLoginUr l = vlc_Da cUrl + vlc _ViaSSOiLo ginApiUrl;
  75           }
  76       }
  77       catch  (err) {
  78           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_Set tingsWebSe rviceURL_r esponse):  ' + err.me ssage);
  79       }
  80   }
  81  
  82   function v lc_formLoa d() {
  83       try {
  84           // Hide Busy  Spinner
  85           do cument.get ElementByI d("BusySpi nner").sty le.display  = "none";
  86  
  87           vl c_USDdata  = vlc_getQ ueryVariab le("data") ;
  88           if  (vlc_USDd ata != "US D") {
  89                //Determ ine the st atus of th e parent r ecord
  90                if (pare nt.Xrm.Pag e.ui.getFo rmType() >  2) {
  91                    //Th e form is  disabled,  hide login  tab
  92                    pare nt.Xrm.Pag e.ui.tabs. get('Tab_V istALogin' ).setVisib le(false);
  93                    retu rn false;
  94                }
  95  
  96                //Check  if VIA Log in cookie  exist (not  expired)
  97                var vlc_ ViaLoginCo okie = vlc _getCookie ("viasessi onlink");
  98  
  99                //Hide V ista Login  Tab and e xit if coo kie exist
  100                if (vlc_ ViaLoginCo okie != "" ) {
  101                    pare nt.Xrm.Pag e.ui.tabs. get('Tab_V istALogin' ).setVisib le(false);
  102                    //** TRIGGER FO RM SCRIPT  CODE TO RE CREATE DEP ENDENT WEB  RESOURCES **
  103                    pare nt.vcmn_in itViaDropd ownControl s();
  104                    retu rn false;
  105                }
  106           }
  107  
  108           // GET CRM SE TTINGS WEB  SERVICE U RLS
  109           va r vlc_cond itionalFil ter = "(mc s_name eq  'Active Se ttings')";
  110           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',  vlc_condi tionalFilt er, 'mcs_n ame', 'asc ', 0, vlc_ SettingsWe bServiceUR L_response , vlc_ViaL oginUrl);
  111           if  (vlc_USDd ata != "US D") {
  112                //Notify  User to L ogin To Vi stA
  113                parent.X rm.Page.ui .setFormNo tification ("ERROR: Y OUR VISTA  SESSION HA S EXPIRED,  PLEASE LO GIN BELOW! ", "ERROR" , "VIASERV ICE");
  114                //Set fo cus to the  login con trol
  115                parent.X rm.Page.ge tControl(" WebResourc e_VistaLog inControl" ).setFocus ();
  116           }
  117  
  118           // Get the cu rrent CRM  User's ass igned site /facility
  119           va r vlc_user Data = vlc _getSingle EntityData Sync('Syst emUserSet' , 'ftp_Fac ilitySiteI d', vlc_us erId);
  120           if  (vlc_user Data != nu ll) {
  121                if (vlc_ userData.d .ftp_Facil itySiteId  != null) {
  122                    vlc_ userSiteId  = vlc_use rData.d.ft p_Facility SiteId.Id;
  123                }
  124           }
  125  
  126           // Lookup the  Facility/ Site #
  127           if  (vlc_user SiteId !=  null && vl c_userSite Id != '')  {
  128                var vlc_ facilityDa ta = vlc_g etSingleEn tityDataSy nc('ftp_fa cilitySet' , 'ftp_fac ilitycode' , vlc_user SiteId);
  129                if (vlc_ facilityDa ta != null ) {
  130                    if ( vlc_facili tyData.d.f tp_facilit ycode != n ull) { vlc _UserSiteN o = vlc_fa cilityData .d.ftp_fac ilitycode;  }
  131                }
  132           }
  133       }
  134       catch  (err) {
  135           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_for mLoad): '  + err.mess age);
  136       }
  137   }
  138  
  139   function v lc_vistaLo gin() {
  140       try {
  141           // Check for  SSOi Login
  142           va r vlc_ssoi Checked =  document.g etElementB yId("ssoic heck").che cked;
  143           if  (vlc_ssoi Checked) {
  144                //Perfor m SSOi Log in
  145                vlc_ssoi Login();
  146                return f alse;
  147           }
  148           
  149           // Perform No n SSOi Log in
  150           // Get Login  Field data
  151           va r vlc_acce ssCode = $ ('#vlc_acc essCode'). val();
  152           va r vlc_esig natureCode  = $('#vlc _esignatur eCode').va l();
  153           va r vlc_veri fyCode = $ ('#vlc_ver ifyCode'). val();
  154           // Verify tha t fields a re not emp ty
  155           if  (vlc_acce ssCode ==  null || vl c_accessCo de == "")  { alert("P lease ente r your VIS TA Access  Code!"); r eturn fals e; }
  156           if  (vlc_esig natureCode  == null | | vlc_esig natureCode  == "") {  alert("Ple ase enter  your VISTA  eSignatur e Code!");  return fa lse; }
  157           if  (vlc_veri fyCode ==  null || vl c_verifyCo de == "")  { alert("P lease ente r your VIS TA Verify  Code!"); r eturn fals e; }
  158  
  159           // Disable lo gin fields  and butto n
  160           do cument.get ElementByI d('vlc_acc essCode'). disabled =  true;
  161           do cument.get ElementByI d('vlc_esi gnatureCod e').disabl ed = true;
  162           do cument.get ElementByI d('vlc_ver ifyCode'). disabled =  true;
  163           do cument.get ElementByI d('vlc_log inbuttonid ').disable d = true;
  164  
  165           // Show Busy  Spinner
  166           do cument.get ElementByI d("BusySpi nner").sty le.display  = "inline -block";
  167  
  168           // Process Vi stA Login  using VIA  web servic e
  169           va r vlc_viaL ogin = new  Object();
  170           vl c_viaLogin .AccessCod e = vlc_ac cessCode;
  171           vl c_viaLogin .VerifyCod e = vlc_ve rifyCode;
  172           vl c_viaLogin .SiteId =  vlc_UserSi teNo.toStr ing();
  173           vl c_viaLogin .Target =  "";
  174  
  175           va r vlc_logi nResponse  = "";
  176  
  177           $. ajax({
  178                type: "P OST",
  179                url: vlc _ViaLoginU rl,
  180                data: JS ON.stringi fy(vlc_via Login),
  181                contentT ype: "appl ication/js on; charse t=utf-8",
  182                dataType : "json",
  183                success:  function  (data) {
  184                    vlc_ loginRespo nse = data ;
  185                    vlc_ vistaLogin _response( null, vlc_ loginRespo nse);
  186                },
  187                error: f unction (j qXHR, text Status, er rorThrown)  {
  188                    //Sy stem Error
  189                    vlc_ vistaLogin _response( errorThrow n, null);
  190                },
  191                async: t rue,
  192                cache: f alse
  193           }) ;
  194       }
  195       catch  (err) {
  196           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_vis taLogin):  ' + err.me ssage);
  197           // Hide Busy  Spinner
  198           do cument.get ElementByI d("BusySpi nner").sty le.display  = "none";
  199       }
  200   }
  201  
  202   function v lc_vistaLo gin_respon se(vlc_err orThrown,  vlc_loginR esponse) {
  203       try {
  204           va r vlc_ssoi Checked =  document.g etElementB yId("ssoic heck").che cked;
  205           if  (vlc_erro rThrown !=  null) {
  206                //Genera l Web Serv ice Error
  207                alert("E rror: The  VISTA Logi n Web Serv ice Failed  with erro r(" + vlc_ errorThrow n + ")  Pl ease try y our login  again!");
  208                //Enable  login fie lds and bu tton
  209                if (!vlc _ssoiCheck ed) {
  210                    docu ment.getEl ementById( 'vlc_acces sCode').di sabled = f alse;
  211                    docu ment.getEl ementById( 'vlc_verif yCode').di sabled = f alse;
  212                }
  213                document .getElemen tById('vlc _esignatur eCode').di sabled = f alse;
  214                document .getElemen tById('vlc _loginbutt onid').dis abled = fa lse;
  215  
  216                //Hide B usy Spinne r
  217                document .getElemen tById("Bus ySpinner") .style.dis play = "no ne";
  218                return f alse;
  219           }
  220           if  (vlc_logi nResponse. ErrorOccur red == tru e) {
  221                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 !");
  222                //Enable  login fie lds and bu tton
  223                if (!vlc _ssoiCheck ed) {
  224                    docu ment.getEl ementById( 'vlc_acces sCode').di sabled = f alse;
  225                    docu ment.getEl ementById( 'vlc_verif yCode').di sabled = f alse;
  226                }
  227                document .getElemen tById('vlc _esignatur eCode').di sabled = f alse;
  228                document .getElemen tById('vlc _loginbutt onid').dis abled = fa lse;
  229  
  230                //Hide B usy Spinne r
  231                document .getElemen tById("Bus ySpinner") .style.dis play = "no ne";
  232                return f alse;
  233           }
  234           el se {
  235                //Get se ssionid/to ken full V istA user  name and V istaDUZ(IE N)
  236                var vlc_ duz = "";
  237                var vlc_ providerna me = "";
  238                var vlc_ vistaduz =  "";
  239  
  240                //Get Lo gin Field  data
  241                var vlc_ accessCode  = $('#vlc _accessCod e').val();
  242                var vlc_ esignature Code = $(' #vlc_esign atureCode' ).val();
  243                var vlc_ verifyCode  = $('#vlc _verifyCod e').val();
  244  
  245                if (vlc_ loginRespo nse.Data[0 ].Duz != n ull) { vlc _duz = vlc _loginResp onse.Data[ 0].Duz; }
  246                if (vlc_ loginRespo nse.Data[0 ].Provider Name != nu ll) { var  vlc_provid ername = v lc_loginRe sponse.Dat a[0].Provi derName; }
  247                if (vlc_ loginRespo nse.Data[0 ].VistaDUZ  != null)  { vlc_vist aduz = vlc _loginResp onse.Data[ 0].VistaDU Z; }
  248  
  249                //Check  that there  are value s returned
  250                if (vlc_ duz == ""  || vlc_pro vidername  == "") {
  251                    //Ch eck for Fa ult, set d efault mes sage
  252                    var  vlc_viaLog inFault =  "The Login  is invali d, please  try your l ogin again !";
  253                    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;  }
  254                    aler t("Error:  " + vlc_vi aLoginFaul t);
  255                    //En able login  fields an d button
  256                    if ( !vlc_ssoiC hecked) {
  257                         document.g etElementB yId('vlc_a ccessCode' ).disabled  = false;
  258                         document.g etElementB yId('vlc_v erifyCode' ).disabled  = false;
  259                    }
  260                    docu ment.getEl ementById( 'vlc_esign atureCode' ).disabled  = false;
  261                    docu ment.getEl ementById( 'vlc_login buttonid') .disabled  = false;
  262  
  263                    //Hi de Busy Sp inner
  264                    docu ment.getEl ementById( "BusySpinn er").style .display =  "none";
  265                    retu rn false;
  266                }
  267  
  268                //Write  values to  Browser Co okie
  269                vlc_setC ookie("via sessionlin k", vlc_du z + "~~~~"  + vlc_pro vidername  + "~~~~" +  vlc_esign atureCode,  vlc_ViaLo ginMinutes );
  270  
  271                //Update  Cross Ref erence
  272                vlc_upda teCrossRef erence(vlc _userId, v lc_userNam e, vlc_vis taduz, vlc _providern ame);
  273  
  274                //Clear  login fiel ds and hid e control
  275                if (vlc_ USDdata !=  "USD") {
  276                    pare nt.Xrm.Pag e.ui.clear FormNotifi cation("VI ASERVICE") ;
  277                }
  278                document .getElemen tById('vlc _accessCod e').disabl ed = false ;
  279                document .getElemen tById('vlc _esignatur eCode').di sabled = f alse;
  280                document .getElemen tById('vlc _verifyCod e').disabl ed = false ;
  281                document .getElemen tById('vlc _loginbutt onid').dis abled = fa lse;
  282                document .getElemen tById('vlc _accessCod e').value  = '';
  283                document .getElemen tById('vlc _esignatur eCode').va lue = '';
  284                document .getElemen tById('vlc _verifyCod e').value  = '';
  285                //Hide t he login t ab
  286                if (vlc_ USDdata !=  "USD") {
  287                    pare nt.Xrm.Pag e.ui.tabs. get('Tab_V istALogin' ).setVisib le(false);
  288  
  289                    //** TRIGGER FO RM SCRIPT  CODE TO RE CREATE DEP ENDENT WEB  RESOURCES **
  290                    pare nt.vcmn_in itViaDropd ownControl s();
  291                }
  292  
  293                if (vlc_ USDdata ==  "USD") {
  294                    //Ca ll USD Fun ction pass ing VISTA  data
  295                    var  vlc_pData  = ["Access Code=" + v lc_accessC ode, "Veri fyCode=" +  vlc_verif yCode, "Si teNumber="  + vlc_Use rSiteNo.to String()];
  296                    VCCM .USDHelper .CopyDataT oReplaceme ntParamete rs("VISTA" , vlc_pDat a, true);
  297  
  298                    //Wa it a few s econds bef ore closin g tab to a llow USD t o receive  the values
  299                    setT imeout(fun ction () {
  300                         //Hide Bus y Spinner
  301                         document.g etElementB yId("BusyS pinner").s tyle.displ ay = "none ";
  302                         //Close th e USD Cred ential Man ager tab
  303                         window.ope n("http:// uii/" + VC CM.USDHelp er._global ManagerNam e + "/Call DoAction?a pplication =Credentia l Manager"  + VCCM.US DHelper._c rlf + "act ion=Close" );
  304                    }, 1 000);
  305                }
  306                else {
  307                    //Hi de Busy Sp inner
  308                    docu ment.getEl ementById( "BusySpinn er").style .display =  "none";
  309                }
  310           }
  311       }
  312       catch  (err) {
  313           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_vis taLogin_re sponse): '  + err.mes sage);
  314           // Hide Busy  Spinner
  315           do cument.get ElementByI d("BusySpi nner").sty le.display  = "none";
  316       }
  317   }
  318  
  319   function v lc_loginKe yPress(eve nt) {
  320       try {
  321           // Determine  if 'enter'  key was p ressed if  so attempt  login
  322           va r vlc_keyp ressed = e vent.which  || event. keyCode;
  323           if  (vlc_keyp ressed ==  13) { vlc_ vistaLogin (); }
  324       }
  325       catch  (err) {
  326           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_log inKeyPress ): ' + err .message);
  327       }
  328   }
  329  
  330   function v lc_getCook ie(cname)  {
  331       try {
  332           va r name = c name + "=" ;
  333           va r ca = doc ument.cook ie.split(' ;');
  334           fo r (var i =  0; i < ca .length; i ++) {
  335                var c =  ca[i];
  336                while (c .charAt(0)  == ' ') {
  337                    c =  c.substrin g(1);
  338                }
  339                if (c.in dexOf(name ) == 0) {
  340                    retu rn c.subst ring(name. length, c. length);
  341                }
  342           }
  343           re turn "";
  344       }
  345       catch  (err) {
  346           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_get Cookie): '  + err.mes sage);
  347       }
  348   }
  349  
  350   function v lc_setCook ie(cname,  cvalue, ex minutes) {
  351       try {
  352           va r d = new  Date();
  353           d. setMinutes (d.getMinu tes() + (e xminutes)) ;
  354           va r expires  = "expires =" + d.toU TCString() ;
  355           do cument.coo kie = cnam e + "=" +  cvalue + " ; " + expi res + "; p ath=/" + v lc_orgName  + "/";
  356       }
  357       catch  (err) {
  358           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_get Cookie): '  + err.mes sage);
  359       }
  360   }
  361  
  362   function v lc_updateC rossRefere nce(vlc_cr mUserGuid,  vlc_crmUs erName, vl c_viaUserI en, vlc_vi aUserName)  {
  363       try {
  364           // Check that  the requi red parame ters has a  value
  365           if  (vlc_crmU serGuid !=  "" && vlc _crmUserGu id != null  && vlc_vi aUserIen ! = "" && vl c_viaUserI en != null ) {
  366                //Check  if a recor d already  exists for  the CRM u ser, if so  preserve  the cross  reference  record gui d
  367                var vlc_ crossRefer enceId = n ull;
  368                var vlc_ conditiona lFilter =  "ftp_crmus er/Id eq ( guid'" + v lc_crmUser Guid + "') ";
  369                var vlc_ crossRefer enceData =  vlc_getMu ltipleEnti tyDataSync ('ftp_user idSet', 'f tp_useridI d', vlc_co nditionalF ilter, 'ft p_name', ' asc', 0);
  370                if (vlc_ crossRefer enceData ! = null) {
  371                    for  (var i = 0 ; i <= vlc _crossRefe renceData. d.results. length - 1 ; i++) {
  372                         //Get Info
  373                         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; }
  374                         break;
  375                    }
  376                }
  377                //Determ ine to add  new recor d or updat e existing
  378                if (vlc_ crossRefer enceId !=  null) {
  379                    //Ex isting Rec ord, perfo rm update
  380                    var  vlc_crossR eferenceRe cord = new  Object();
  381                    vlc_ crossRefer enceRecord .ftp_crmgu id = vlc_c rmUserGuid ;
  382                    vlc_ crossRefer enceRecord .ftp_vista duz = vlc_ viaUserIen ;
  383                    vlc_ crossRefer enceRecord .ftp_vista username =  vlc_viaUs erName;
  384                    vlc_ crossRefer enceRecord .ftp_crmus er = { Id:  vlc_crmUs erGuid, Lo gicalName:  "systemus er", Name:  vlc_crmUs erName };
  385                    vlc_ crossRefer enceRecord .ftp_name  = "CROSS R EFERENCE -  " + vlc_c rmUserName ;
  386                    vlc_ crossRefer enceRecord .ftp_lastv ialogin =  new Date() ;
  387  
  388                    //ma ke it a js on object
  389                    var  jsonEntity  = JSON.st ringify(vl c_crossRef erenceReco rd);
  390  
  391                    $.aj ax({
  392                         type: "POS T",
  393                         contentTyp e: "applic ation/json ; charset= utf-8",
  394                         datatype:  "json",
  395                         url: vlc_s erverUrl +  vlc_crmOd ataEndPoin t + "/" +  'ftp_useri dSet' + "( guid'" + v lc_crossRe ferenceId  + "')",
  396                         data: json Entity,
  397                         beforeSend : function  (XMLHttpR equest) {
  398                             XMLHtt pRequest.s etRequestH eader("X-H TTP-Method ", "MERGE" );
  399                         },
  400                         success: f unction (t extStatus,  XmlHttpRe quest) {
  401                             //aler t("The Vis ta User Cr oss Refere nce Record  was updat ed success fully.");
  402                         },
  403                         error: fun ction (Xml HttpReques t, textSta tus, error Thrown) {
  404                             alert( 'Ajax Erro r in Updat e of Vista  User Cros s Referenc e Record:  ' + errorT hrown);
  405                         }
  406                    });
  407                }
  408                else {
  409                    //Ne w Record,  perform ad d
  410                    var  vlc_crossR eferenceRe cord = new  Object();
  411                    vlc_ crossRefer enceRecord .ftp_crmgu id = vlc_c rmUserGuid ;
  412                    vlc_ crossRefer enceRecord .ftp_vista duz = vlc_ viaUserIen ;
  413                    vlc_ crossRefer enceRecord .ftp_vista username =  vlc_viaUs erName;
  414                    vlc_ crossRefer enceRecord .ftp_crmus er = { Id:  vlc_crmUs erGuid, Lo gicalName:  "systemus er", Name:  vlc_crmUs erName };
  415                    vlc_ crossRefer enceRecord .ftp_name  = "CROSS R EFERENCE -  " + vlc_c rmUserName ;
  416                    vlc_ crossRefer enceRecord .ftp_lastv ialogin =  new Date() ;
  417  
  418                    //ma ke it a js on object
  419                    var  jsonEntity  = JSON.st ringify(vl c_crossRef erenceReco rd);
  420  
  421                    $.aj ax({
  422                         type: "POS T",
  423                         contentTyp e: "applic ation/json ; charset= utf-8",
  424                         datatype:  "json",
  425                         url: vlc_s erverUrl +  vlc_crmOd ataEndPoin t + "/" +  'ftp_useri dSet',
  426                         data: json Entity,
  427                         beforeSend : function  (XMLHttpR equest) {
  428                             XMLHtt pRequest.s etRequestH eader('Acc ept', 'app lication/j son');
  429                         },
  430                         success: f unction (t extStatus,  XmlHttpRe quest) {
  431                             //aler t("The Vis ta User Cr oss Refere nce Record  was added  successfu lly.");
  432                         },
  433                         error: fun ction (Xml HttpReques t, textSta tus, error Thrown) {
  434                             alert( 'Ajax Erro r in Addin g a Vista  User Cross  Reference  Record: '  + errorTh rown);
  435                         }
  436                    });
  437                }
  438           }
  439       }
  440       catch  (err) {
  441           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_upd ateCrossRe ference):  ' + err.me ssage);
  442       }
  443   }
  444  
  445   function v lc_ssoiChe cked() {
  446       try {
  447           // Update Log in screen  based on s soi checke d/unchecke d
  448           va r vlc_ssoi Checked =  document.g etElementB yId("ssoic heck").che cked;
  449           if  (vlc_ssoi Checked) {
  450                //update  labels
  451                document .getElemen tById("lbl SubTitle") .innerHTML  = "Enter  your eSign ature Code  &nbsp;&nb sp;&nbsp;& nbsp;&nbsp ;&nbsp;(Pl ease note  that SSOi  is current ly not sup ported for  automatic  VSE login  !)";
  452                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 !)";
  453                //Disabl e login fi elds
  454                document .getElemen tById('vlc _accessCod e').disabl ed = true;
  455                document .getElemen tById('vlc _verifyCod e').disabl ed = true;
  456                //Initia lize PIV C ard Login  Form
  457                var apiN ame = "sta rtLoginSSO i";
  458                try {
  459                    SSOi Services.s tartLogin( vlc_ViaSSO iPivCardUr l);
  460                } catch  (err) {
  461                    aler t("PIV Car d Error: "  + apiName  + ': ' +  err.messag e);
  462                }
  463           }
  464           el se {
  465                //update  labels
  466                document .getElemen tById("lbl SubTitle") .innerHTML  = "Enter  your Acces s Code, Ve rify Code  and eSigna ture Code" ;
  467                document .getElemen tById("lbl SubTitle") .title = " Enter your  Access Co de, Verify  Code and  eSignature  Code";
  468                //Enable  login fie lds
  469                document .getElemen tById('vlc _accessCod e').disabl ed = false ;
  470                document .getElemen tById('vlc _verifyCod e').disabl ed = false ;
  471           }
  472       }
  473       catch  (err) {
  474           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_sso iChecked):  ' + err.m essage);
  475       }
  476   }
  477  
  478   function v lc_ssoiLog in() {
  479       try {
  480           // Verify tha t required  URL's hav e data
  481           if  (vlc_ViaS SOiLoginUr l == '' ||  vlc_ViaSS OiRefreshT okenUrl ==  '' || vlc _ViaSSOiPi vCardUrl = = '') {
  482                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!");
  483                return f alse;
  484           }
  485  
  486           // Get Login  Field data
  487           va r vlc_esig natureCode  = $('#vlc _esignatur eCode').va l();
  488           // Verify tha t fields a re not emp ty
  489           if  (vlc_esig natureCode  == null | | vlc_esig natureCode  == "") {  alert("Ple ase enter  your VISTA  eSignatur e Code!");  return fa lse; }
  490           // Disable lo gin fields  and butto n
  491           do cument.get ElementByI d('vlc_esi gnatureCod e').disabl ed = true;
  492           do cument.get ElementByI d('vlc_log inbuttonid ').disable d = true;
  493  
  494           // Show Busy  Spinner
  495           do cument.get ElementByI d("BusySpi nner").sty le.display  = "inline -block";
  496           // Check for  SAML Token
  497           if  (isBlank( _SAMLToken )) {
  498                SSOiServ ices.refre shSSOi(vlc _ViaSSOiRe freshToken Url, callL oginVIA_SS Oi);
  499           }  else {
  500                callLogi nVIA_SSOi( );
  501           }
  502       }
  503       catch  (err) {
  504           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_sso iLogin): '  + err.mes sage);
  505           // Hide Busy  Spinner
  506           do cument.get ElementByI d("BusySpi nner").sty le.display  = "none";
  507       }
  508   }
  509  
  510   function i sBlank(val ue) {
  511       return  (value == = undefine d || value  == null | | value.le ngth <= 0)  ? true :  false;
  512   }
  513  
  514   function c allLoginVI A_SSOi() {
  515  
  516       var ap iName = "l oginVIA: S SOi";
  517       var si teId = vlc _UserSiteN o;
  518  
  519       try {
  520           // Check Toke n
  521           if  (isBlank( _SAMLToken ) || _SAML Token == " undefined" ) {
  522                //SSOi t oken faile d
  523                alert("N o SSOi tok en retriev ed. SSOi l ogin was n ot success ful, pleas e try agai n.");
  524                document .getElemen tById("Bus ySpinner") .style.dis play = "no ne";
  525                document .getElemen tById('vlc _esignatur eCode').di sabled = f alse;
  526                document .getElemen tById('vlc _loginbutt onid').dis abled = fa lse;
  527           }  else {
  528                if (apiN ame !== nu ll && !isB lank(_SAML Token) &&  !isBlank(s iteId)) {
  529                    //Ca ll VIA_SSO i_Login se rvice
  530                    vlc_ loginVIA_S SOi(siteId , _SAMLTok en, _IAMSe ssion);
  531                } else {
  532                    aler t("Please  verify the  SSOi logi n and that  the Site  ID is fill ed out, pl ease try a gain.");
  533                    docu ment.getEl ementById( "BusySpinn er").style .display =  "none";
  534                    docu ment.getEl ementById( 'vlc_esign atureCode' ).disabled  = false;
  535                    docu ment.getEl ementById( 'vlc_login buttonid') .disabled  = false;
  536                }
  537           }
  538       } catc h (err) {
  539           al ert(apiNam e + ': ' +  err.messa ge);
  540       }
  541   }
  542  
  543   function v lc_loginVI A_SSOi_OLD (siteId, s amlToken,  iamSession ) {
  544       //This  version o f the comm and has be en depreca ted
  545       //This  version w as used wi th version  2.0, nw r eplaced by  2.1
  546       try {
  547           va r b64token  = window. btoa(samlT oken);
  548           va r viamessa ge = {};
  549           vi amessage.A ccessCode  = "donotus e";
  550           vi amessage.V erifyCode  = "donotus e";
  551           vi amessage.S iteId = si teId;
  552  
  553           va r vlc_logi nResponse  = "";
  554  
  555           $. ajax({
  556                url: vlc _ViaSSOiLo ginUrl,  
  557                type: 'P OST',
  558                beforeSe nd: functi on (reques t) {
  559                    requ est.setReq uestHeader ("CRMSSOiS ession", i amSession) ,
  560                    requ est.setReq uestHeader ("CRMSSOiS essionSaml ", b64toke n)
  561                },
  562                dataType : 'json',
  563                data: JS ON.stringi fy(viamess age),
  564                contentT ype: 'appl ication/js on',
  565                success:  function  (data) {
  566                    vlc_ loginRespo nse = data ;
  567                    vlc_ vistaLogin _response( null, vlc_ loginRespo nse);
  568                },
  569                error: f unction (j qXHR, text Status, er rorThrown)  {
  570                    //Sy stem Error
  571                    vlc_ vistaLogin _response( errorThrow n, null);
  572                },
  573                async: t rue,
  574                cache: f alse
  575           }) ;
  576       }
  577       catch  (err) {
  578           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_log inVIA_SSOi ): ' + err .message);
  579       }
  580   }
  581  
  582   function v lc_loginVI A_SSOi(sit eId, samlT oken, iamS ession) {
  583       try {
  584           va r b64token  = window. btoa(samlT oken);
  585           va r viamessa ge = {};
  586           vi amessage.S iteId = si teId;
  587           vi amessage.S amlToken =  b64token;
  588  
  589           va r vlc_logi nResponse  = "";
  590  
  591           $. ajax({
  592                url: vlc _ViaSSOiLo ginUrl,
  593                type: 'P OST',
  594                dataType : 'json',
  595                data: JS ON.stringi fy(viamess age),
  596                contentT ype: 'appl ication/js on',
  597                success:  function  (data) {
  598                    vlc_ loginRespo nse = data ;
  599                    vlc_ vistaLogin _response( null, vlc_ loginRespo nse);
  600                },
  601                error: f unction (j qXHR, text Status, er rorThrown)  {
  602                    //Sy stem Error
  603                    vlc_ vistaLogin _response( errorThrow n, null);
  604                },
  605                async: t rue,
  606                cache: f alse
  607           }) ;
  608       }
  609       catch  (err) {
  610           al ert('VistA  Login Con trol Web R esource Fu nction Err or(vlc_log inVIA_SSOi ): ' + err .message);
  611       }
  612   }
  613  
  614   function v lc_execute CrmOdataGe tRequest(v lc_jsonQue ry, vlc_aS ync, vlc_a SyncCallba ck, vlc_sk ipCount, v lc_optionA rray) {
  615       //This  function  executes a  CRM Odata  web servi ce call to  retrieve  Crm data
  616       //*vlc _jsonQuery * - a prop erly forma tted CRM O data Query  string (r equired)
  617       //*vlc _aSync* -  specify 't rue' to ex ecute asyn chronously  otherwise  'false' ( required)
  618       //*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 '')
  619       //*vlc _skipCount * - Initia l setting  is always  '0', incre ments by 5 0 per CRM  SDK Odata  standards  (required)
  620       //*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)
  621       try {
  622           va r vlc_enti tyData = n ull;
  623           $. ajax({
  624                type: 'G ET',
  625                contentT ype: 'appl ication/js on; charse t=utf-8',
  626                datatype : 'json',
  627                url: vlc _jsonQuery ,
  628                beforeSe nd: functi on (XMLHtt pRequest)  {
  629                    XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json');
  630                },
  631                success:  function  (data, tex tStatus, X mlHttpRequ est) {
  632                    vlc_ entityData  = data;
  633                    if ( vlc_aSync  == true) {
  634                         vlc_aSyncC allback(vl c_entityDa ta, vlc_sk ipCount, v lc_optionA rray);
  635                    }
  636                },
  637                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  638                    aler t('Fail: A jax Error  in vlc_exe cuteCrmOda taGetReque st: ' + er rorThrown  + " Reques t: " + vlc _jsonQuery );
  639                },
  640                async: v lc_aSync,
  641                cache: f alse
  642           }) ;
  643           re turn vlc_e ntityData;
  644       }
  645       catch  (err) {
  646           al ert('An er ror occure d in the v lc_execute CrmOdataGe tRequest f unction.   Error Deta il Message : ' + err) ;
  647       }
  648   }
  649  
  650   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) {
  651       //This  function  returns a  CRM JSON d ataset for  all entit y records  matching c riteria pr ovided Asy ncronously
  652       //*vlc _entitySet Name* - is  the name  of the ent ity set e. g 'Contact Set'
  653       //*vlc _attribute Set* -  is  a string  containing  the Crm A ttributes  to retriev e e.g. 'Fi rstName, L astName, T elephone1,  EMailAddr ess1'
  654       //*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
  655       //*vlc _sortAttri bute* - is  a string  containing  the name  of the att ribute to  sort the r esult set  by e.g. 'L astName'
  656       //*vlc _sortDirec tion* - is  a string  specifying  the sort  as Ascendi ng or Desc ending e.g . 'asc' or  'desc'
  657       //*vlc _skipCount * - is the  starting  point in t he result  (use if mo re than 50 ), (Put 0  if not use d)
  658       //*vlc _aSyncCall back* - is  the name  of the fun ction to c all when r eturning t he result
  659       //*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
  660  
  661       try {
  662           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 ;
  663           vl c_executeC rmOdataGet Request(vl c_jsonQuer y, true, v lc_aSyncCa llback, vl c_skipCoun t, vlc_opt ionArray);
  664       }
  665       catch  (err) {
  666           al ert('An er ror occure d in the v lc_getMult ipleEntity DataAsync  function.   Error Det ail Messag e: ' + err );
  667       }
  668   }
  669  
  670   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 ) {
  671       //This  function  returns a  CRM JSON d ataset for  all entit y records  matching c riteria pr ovided Syn cronously
  672       //*vlc _entitySet Name* - is  the name  of the ent ity set e. g 'Contact Set'
  673       //*vlc _attribute Set* -  is  a string  containing  the Crm A ttributes  to retriev e e.g. 'Fi rstName, L astName, T elephone1,  EMailAddr ess1'
  674       //*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
  675       //*vlc _sortAttri bute* - is  a string  containing  the name  of the att ribute to  sort the r esult set  by e.g. 'L astName'
  676       //*vlc _sortDirec tion* - is  a string  specifying  the sort  as Ascendi ng or Desc ending e.g . 'asc' or  'desc'
  677       //*vlc _skipCount * - is the  starting  point in t he result  (use if mo re than 50 ), (Put 0  if not use d)
  678  
  679       try {
  680           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 ;
  681           va r vlc_enti tyData = v lc_execute CrmOdataGe tRequest(v lc_jsonQue ry, false,  '', vlc_s kipCount,  null);
  682           re turn vlc_e ntityData;
  683       }
  684       catch  (err) {
  685           al ert('An er ror occure d in the v lc_getMult ipleEntity DataSync f unction.   Error Deta il Message : ' + err) ;
  686       }
  687   }
  688  
  689   function v lc_getSing leEntityDa taSync(vlc _entitySet Name, vlc_ attributeS et, vlc_en tityId) {
  690       //This  function  returns a  CRM JSON d ataset for  a single  entity rec ord based  on the ent ity id pro vided Sync ronously
  691       //*vlc _entitySet Name* - is  the name  of the ent ity set e. g 'Contact Set'
  692       //*vlc _attribute Set* -  is  a string  containing  the Crm A ttributes  to retriev e e.g. 'Fi rstName, L astName, T elephone1,  EMailAddr ess1'
  693       //*vlc _entityId*  - is the  Guid for t he entity  record
  694  
  695       try {
  696           va r vlc_enti tyIdNoBrac ket = vlc_ entityId.r eplace(/({ |})/g, '') ;
  697           va r vlc_sele ctString =  '(guid' +  "'" + vlc _entityIdN oBracket +  "'" + ')? $select='  + vlc_attr ibuteSet;
  698           va r vlc_json Query = vl c_serverUr l + vlc_cr mOdataEndP oint + '/'  + vlc_ent itySetName  + vlc_sel ectString;
  699           va r vlc_enti tyData = v lc_execute CrmOdataGe tRequest(v lc_jsonQue ry, false,  '', 0, nu ll);
  700           re turn vlc_e ntityData;
  701       }
  702       catch  (err) {
  703           al ert('An er ror occure d in the v lc_getSing leEntityDa taSync fun ction.  Er ror Detail  Message:  ' + err);
  704       }
  705   }