118. 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.

118.1 Files compared

# Location File Last Modified
1 VCCM.zip\VCCM\CRM_solutions\VCCMResources\WebResources ftp_VistaAddendumIntegrationFormScriptVistaAddendu9B734B60-18FD-E611-944C-0050568D743D Tue Nov 7 11:34:40 2017 UTC
2 VCCM.zip\VCCM\CRM_solutions\VCCMResources\WebResources ftp_VistaAddendumIntegrationFormScriptVistaAddendu9B734B60-18FD-E611-944C-0050568D743D Mon Dec 4 13:06:45 2017 UTC

118.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 5 1612
Changed 4 8
Inserted 0 0
Removed 0 0

118.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

118.4 Active regular expressions

No regular expressions were active.

118.5 Comparison detail

  1   //VistaAdd endumInteg rationForm Script.js
  2   //Contains  variables  and funct ions used  by the CRM  Form and  Ribbon
  3   //Requires  jQuery lo aded on th e CRM Form
  4  
  5   //Static V ariables
  6   var vadi_c rmOdataEnd Point = '/ XRMService s/2011/Org anizationD ata.svc';
  7   var vadi_s erverUrl =  Xrm.Page. context.ge tClientUrl ();
  8  
  9   //var vadi _VistaUser sURLbase =  'https:// se r
v e r
/WebParts/ DEV/api/Vi staUsers/1 .0/json/ft pCRM/john/ smith/1234 ?noFilter= true';    //OLD MANU AL DEV URL
  10   var vadi_V istaUsersU RLbase = ' ';
  11   //var vadi _AddSigner sUrl = 'ht tps:// se r
v e r
/WebParts/ DEV/api/VI A/AddSigne rs/1.0/jso n';    //OLD MANU AL DEV URL
  12   var vadi_A ddSignersU rl = '';
  13   //var vadi _CreateAdd endumUrl =  'https:// se r
v e r
/WebParts/ DEV/api/VI A/CreateAd dendum/1.0 /json';    //OLD MANU AL DEV URL
  14   var vadi_C reateAdden dumUrl = ' ';
  15   //var vadi _SignNoteU rl = 'http s:// se r
v e r
/WebParts/ DEV/api/VI A/SignNote /1.0/json'   //OLD MANU AL DEV URL
  16   var vadi_S ignNoteUrl  = '';
  17  
  18   //Producti on Environ ment Indic ator
  19   var vadi_I sProductio nEnvironme nt = false ;
  20  
  21   //Word Wra p Line Lim it
  22   var vadi_W ordWrapLim it = 75;
  23  
  24   //Addition al Signers  Data
  25   var vadi_A ddlSigners NameArray  = null;
  26   var vadi_A ddlSigners IenArray =  null;
  27   var vadi_l ocalStorag eVarName =  "";
  28  
  29   //Intializ e LoginCon trol Depen decies if  they exist
  30   function v cmn_initVi aDropdownC ontrols()  {
  31       //Init ialize VIA  DropDown  Controls
  32       //Func tion is tr iggered by  The VistA  Login Con trol
  33       try {
  34           Xr m.Page.get Control("W ebResource _AddendumS ignerSearc h").setSrc (Xrm.Page. getControl ("WebResou rce_Addend umSignerSe arch").get Src());
  35       }
  36       catch  (err) {
  37           al ert('Adden dum VIA Lo gin Functi on Error(v cmn_initVi aDropdownC ontrols):  ' + err.me ssage);
  38       }
  39   }
  40  
  41   function v adi_launch AddendumSi gnerSearch () {
  42       try {
  43           // Refresh th e web reso urce URL
  44           va r vadi_Add endumSigne rSearchURL  = Xrm.Pag e.getContr ol('WebRes ource_Adde ndumSigner Search').g etSrc();
  45           Xr m.Page.get Control('W ebResource _AddendumS ignerSearc h').setSrc (vadi_Adde ndumSigner SearchURL) ;
  46           // Prep the t ab
  47           if  (Xrm.Page .ui.tabs.g et('Tab_Ad ditionalSi gners').ge tVisible()  == false)  {
  48                Xrm.Page .ui.tabs.g et('Tab_Ad ditionalSi gners').se tVisible(t rue);
  49           }
  50           if  (Xrm.Page .ui.tabs.g et('Tab_Ad ditionalSi gners').ge tDisplaySt ate() != ' expanded')  {
  51                Xrm.Page .ui.tabs.g et('Tab_Ad ditionalSi gners').se tDisplaySt ate('expan ded');
  52           }
  53           // Set focus  to the sig ners tab
  54           Xr m.Page.ui. tabs.get(' Tab_Additi onalSigner s').setFoc us();
  55       }
  56       catch  (err) {
  57           al ert('Adden dum Signer  Search Ri bbon Funct ion Error( vadi_launc hAddendumS ignerSearc h): ' + er r.message) ;
  58       }
  59   }
  60  
  61   function v adi_newAdd endumLoad( ) {
  62       try {
  63           // GET CRM SE TTINGS WEB  SERVICE U RLS
  64           va r vadi_con ditionalFi lter = "(m cs_name eq  'Active S ettings')" ;
  65           va di_getMult ipleEntity DataAsync( 'mcs_setti ngSet', 'f tp_DACURL,  ftp_Vista UsersAPIUR L, ftp_IsP roductionE nvironment , ftp_VIAA dditionalS ignersURL,  ftp_VIACr eateAddend umURL, ftp _VIASignNo teURL', va di_conditi onalFilter , 'mcs_nam e', 'asc',  0, vadi_n ewAddendum Load_respo nse);
  66       }
  67       catch  (err) {
  68           // Display Er ror
  69           al ert('Adden dum Form L oad Script  Function  Error(vadi _newAddend umLoad): '  + err.mes sage);
  70       }
  71   }
  72  
  73   function v adi_newAdd endumLoad_ response(v adi_settin gData, vad i_lastSkip ) {
  74       try {
  75           // vadi_lastS kip is the  starting  point in t he result  (use if mo re than 50  records)  //Not used  in this s cenario
  76           va r vadi_Dac Url = null ;
  77           va r vadi_Vis taUserApiU rl = null;
  78           va r vadi_Via AddlSigner sApiUrl =  null;
  79           va r vadi_Via CreateAdde ndumApiUrl  = null;
  80           va r vadi_Via SignNoteAp iUrl = nul l;
  81  
  82           fo r (var i =  0; i <= v adi_settin gData.d.re sults.leng th - 1; i+ +) {
  83                //Get in fo
  84                if (vadi _settingDa ta.d.resul ts[i].ftp_ DACURL !=  null) { va di_DacUrl  = vadi_set tingData.d .results[i ].ftp_DACU RL; }
  85                if (vadi _settingDa ta.d.resul ts[i].ftp_ VistaUsers APIURL !=  null) { va di_VistaUs erApiUrl =  vadi_sett ingData.d. results[i] .ftp_Vista UsersAPIUR L; }
  86                if (vadi _settingDa ta.d.resul ts[i].ftp_ IsProducti onEnvironm ent != nul l) { vadi_ IsProducti onEnvironm ent = vadi _settingDa ta.d.resul ts[i].ftp_ IsProducti onEnvironm ent; }
  87                if (vadi _settingDa ta.d.resul ts[i].ftp_ VIAAdditio nalSigners URL != nul l) { vadi_ ViaAddlSig nersApiUrl  = vadi_se ttingData. d.results[ i].ftp_VIA Additional SignersURL ; }
  88                if (vadi _settingDa ta.d.resul ts[i].ftp_ VIACreateA ddendumURL  != null)  { vadi_Via CreateAdde ndumApiUrl  = vadi_se ttingData. d.results[ i].ftp_VIA CreateAdde ndumURL; }
  89                if (vadi _settingDa ta.d.resul ts[i].ftp_ VIASignNot eURL != nu ll) { vadi _ViaSignNo teApiUrl =  vadi_sett ingData.d. results[i] .ftp_VIASi gnNoteURL;  }
  90                break;
  91           }
  92  
  93           if  (vadi_Dac Url != nul l && vadi_ VistaUserA piUrl != n ull) {
  94                //Constr uct full w eb service  URL
  95                vadi_Vis taUsersURL base = vad i_DacUrl +  vadi_Vist aUserApiUr l;
  96           }
  97           el se {
  98                Xrm.Page .ui.setFor mNotificat ion("ERROR : THE VIST A USERS SE RVICE URL  IS MISSING , PLEASE C ONTACT TEC HNICAL SUP PORT!", "E RROR", "VI STASERVICE ");
  99           }
  100           if  (vadi_Dac Url != nul l && vadi_ ViaAddlSig nersApiUrl  != null)  {
  101                //Constr uct full w eb service  URL
  102                vadi_Add SignersUrl  = vadi_Da cUrl + vad i_ViaAddlS ignersApiU rl;
  103           }
  104           el se {
  105                Xrm.Page .ui.setFor mNotificat ion("ERROR : THE VIA  ADDITIONAL  SIGNERS S ERVICE URL  IS MISSIN G, PLEASE  CONTACT TE CHNICAL SU PPORT!", " ERROR", "V ISTASERVIC E");
  106           }
  107  
  108           if  (vadi_Dac Url != nul l && vadi_ ViaCreateA ddendumApi Url != nul l) {
  109                //Constr uct full w eb service  URL
  110                vadi_Cre ateAddendu mUrl = vad i_DacUrl +  vadi_ViaC reateAdden dumApiUrl;
  111           }
  112           el se {
  113                Xrm.Page .ui.setFor mNotificat ion("ERROR : THE VIA  CREATE ADD ENDUM SERV ICE URL IS  MISSING,  PLEASE CON TACT TECHN ICAL SUPPO RT!", "ERR OR", "VIST ASERVICE") ;
  114           }
  115  
  116           if  (vadi_Dac Url != nul l && vadi_ ViaSignNot eApiUrl !=  null) {
  117                //Constr uct full w eb service  URL
  118                vadi_Sig nNoteUrl =  vadi_DacU rl + vadi_ ViaSignNot eApiUrl;
  119           }
  120           el se {
  121                Xrm.Page .ui.setFor mNotificat ion("ERROR : THE VIA  SIGN NOTE  SERVICE UR L IS MISSI NG, PLEASE  CONTACT T ECHNICAL S UPPORT!",  "ERROR", " VISTASERVI CE");
  122           }
  123       }
  124       catch  (err) {
  125           al ert('Adden dum Form L oad Script  Function  Error(vadi _newAddend umLoad_res ponse): '  + err.mess age);
  126       }
  127   }
  128  
  129   function v adi_ribbon ButtonSave ToVistA()  {
  130       try {
  131           // Check the  value of t he Integra tion Statu s Field, i f = 'OK',  stop and e xit this s cript
  132           va r vadi_int egrationSt atus = Xrm .Page.getA ttribute(' ftp_integr ationstatu s').getVal ue();
  133           if  (vadi_int egrationSt atus == 'O K') { retu rn false;  }
  134  
  135           // Check for  additional  signers,  if they ex ist, the s igners mus t be in sy nc with ma tching Ses sion varia bles
  136           va di_AddlSig nersNameAr ray = null ;
  137           va di_AddlSig nersIenArr ay = null;
  138  
  139           va r vadi_sel ectedSigne rs = Xrm.P age.getAtt ribute('ft p_selected signers'). getValue() ;
  140           if  (vadi_sel ectedSigne rs != null  && vadi_s electedSig ners != '' ) {
  141                //Additi onal Signe rs exist i n CRM, ver ify sessio n variable s
  142                var vadi _selectedA rray = vad i_selected Signers.sp lit('~~~') ;
  143                var vadi _selectedA rrayRecord Count = va di_selecte dArray.len gth;
  144                if (vadi _selectedA rrayRecord Count > 1)  {
  145                    vadi _AddlSigne rsNameArra y = vadi_s electedArr ay;
  146                }
  147  
  148                var vadi _selectedI ENArray =  '';
  149                var vadi _selectedI ENArrayRec ordCount =  0;
  150                var vadi _addendumI d = Xrm.Pa ge.data.en tity.getId ();  //Use d to be pr ogressNote Id
  151  
  152                var vadi _arrayMism atch = fal se;
  153  
  154                //Get No te's Brows er Local S torage Val ues
  155                if (vadi _addendumI d != null  && vadi_ad dendumId ! = '') {
  156                    vadi _localStor ageVarName  = "PN" +  vadi_adden dumId;
  157                    var  vadi_local StorageStr ingValue =  localStor age.getIte m(vadi_loc alStorageV arName);
  158                    if ( vadi_local StorageStr ingValue ! = null &&  vadi_local StorageStr ingValue ! = '') {
  159                         vadi_selec tedIENArra y = vadi_l ocalStorag eStringVal ue.split(' ~~~');
  160                         vadi_selec tedIENArra yRecordCou nt = vadi_ selectedIE NArray.len gth;
  161                         if (vadi_s electedIEN ArrayRecor dCount > 1 ) {
  162                             vadi_A ddlSigners IenArray =  vadi_sele ctedIENArr ay;
  163                         }
  164                    }
  165                }
  166                //Compar e CRM sign er array l ength with  LocalStor age array  length
  167                if (vadi _selectedA rrayRecord Count != v adi_select edIENArray RecordCoun t) { vadi_ arrayMisma tch = true ; }
  168  
  169                if (vadi _arrayMism atch == tr ue) {
  170                    aler t("The cou nt of Addi tional Sig ners selec ted in CRM , does not  match the  count of  Additional  Signers i n VISTA!\n \nPlease r emove all  the additi onal signe rs on this  Addemdum  and perfor m the sele ction proc ess again! \n\nThis a ddendum ca nnot be in tegrated w ith VISTA/ CPRS until  this has  been resol ved.");
  171                    retu rn false;
  172                }
  173           }
  174  
  175           // Check if V IA Login c ookie exis t (not exp ired)
  176           va r vadi_Via LoginCooki e = vadi_g etCookie(" viasession link");
  177           if  (vadi_Via LoginCooki e == "") {
  178                alert("Y our VISTA  session ha s expired.  In order  to integra te an adde ndum, you  must be lo gged into  VISTA!");
  179                Xrm.Page .ui.tabs.g et('Tab_Vi stALogin') .setVisibl e(true);
  180                Xrm.Page .ui.tabs.g et('Tab_Vi stALogin') .setFocus( );
  181                return f alse;
  182           }
  183  
  184           // Save the c urrent CRM  data
  185           Xr m.Page.dat a.entity.s ave();
  186           // Display YE LLOW Progr ess....
  187           Xr m.Page.ui. setFormNot ification( "Verifying  addendum  data, plea se wait.." , "INFO",  "SAVEVISTA ");
  188  
  189           va r vadi_con firmSaveTo Vista = co nfirm('Are  you sure  you want t o save thi s addendum  to VistA/ CPRS?\nThi s action c annot be c ancelled!\ n\nUpon co mpletion o f this pro cess, the  addendum w ill automa tically be  marked as  completed  and you w ill be pro mpted to e xit the re cord!');
  190           if  (vadi_con firmSaveTo Vista == f alse) {
  191                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  192                return f alse;
  193           }
  194  
  195           // Get VistA  Note Id to  relate ad dedndum to  existing  note in Vi stA
  196           va r vadi_vis taNoteId =  Xrm.Page. getAttribu te('ftp_vi stanoteid' ).getValue ();
  197           if  (vadi_vis taNoteId = = null ||  vadi_vista NoteId ==  '') {
  198                alert('T he VistA N ote Id fie ld does no t have a v alue, the  addendum c annot be c reated in  VistA/CPRS !');
  199                Xrm.Page .getContro l('ftp_vis tanoteid') .setFocus( );
  200                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  201                return f alse;
  202           }
  203  
  204           // Get Addend um Note Te xt
  205           va r vadi_add endumText  = Xrm.Page .getAttrib ute('descr iption').g etValue();
  206           if  (vadi_add endumText  == null ||  vadi_adde ndumText = = '') {
  207                alert('T he Note fi eld does n ot have te xt, the ad dendum can not be cre ated in Vi stA/CPRS!' );
  208                Xrm.Page .getContro l('descrip tion').set Focus();
  209                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  210                return f alse;
  211           }
  212          
  213           // Get user d ata
  214           va r vadi_crm UserId = X rm.Page.ge tAttribute ('ownerid' ).getValue ();
  215           va r vadi_use rDomainId  = '';
  216           va r vadi_use rFirstName  = '';
  217           va r vadi_use rLastName  = '';
  218           va r vadi_use rMiddleNam e = '';
  219           va r vadi_use rSiteId =  '';
  220  
  221           if  (vadi_crm UserId !=  null) {
  222                //Verify  the owner  type
  223                if (vadi _crmUserId [0].entity Type != 's ystemuser' ) {
  224                    aler t('The add endum owne r must be  an individ ual user a nd not a t eam, the a ddendum ca nnot be cr eated in V istA/CPRS! ');
  225                    Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA ");
  226                    retu rn false;
  227                }
  228  
  229                var vadi _userData  = vadi_get SingleEnti tyDataSync ('SystemUs erSet', 'D omainName,  FirstName , LastName , MiddleNa me, ftp_Fa cilitySite Id', vadi_ crmUserId[ 0].id);
  230                if (vadi _userData  != null) {
  231                    if ( vadi_userD ata.d.Doma inName !=  null) { va di_userDom ainId = va di_userDat a.d.Domain Name; }
  232                    if ( vadi_userD ata.d.Firs tName != n ull) { vad i_userFirs tName = va di_userDat a.d.FirstN ame; }
  233                    if ( vadi_userD ata.d.Last Name != nu ll) { vadi _userLastN ame = vadi _userData. d.LastName ; }
  234                    if ( vadi_userD ata.d.Midd leName !=  null) { va di_userMid dleName =  vadi_userD ata.d.Midd leName; }
  235                    if ( vadi_userD ata.d.ftp_ FacilitySi teId != nu ll) { vadi _userSiteI d = vadi_u serData.d. ftp_Facili tySiteId.I d; }
  236                }
  237           }
  238           el se {
  239                alert('U nable to v erify the  user accou nt for the  current a uthor/owne r assigned  to this a ddendum, t he addendu m cannot b e created  in VistA/C PRS!');
  240                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  241                return f alse;
  242           }
  243  
  244           // Verify tha t the curr ent owner  and the cu rrent user  is the sa me person,  if not do  not proce ed
  245           if  ((vadi_cr mUserId[0] .id).toUpp erCase() ! = (Xrm.Pag e.context. getUserId( )).toUpper Case()) {
  246                alert('T he current  author/ow ner does n ot match t he current  CRM user,  the adden dum cannot  be create d in VistA /CPRS!');
  247                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  248                return f alse;
  249           }
  250           va r vadi_Not eUserTeam  = "NONE";
  251           // Check Team  membershi p
  252           if  (vadi_Use rHasTeam(" Pharmacy",  Xrm.Page. context.ge tUserId()) ) { vadi_N oteUserTea m = "PHARM ACY"; }
  253           if  (vadi_Use rHasTeam(" CCA Team",  Xrm.Page. context.ge tUserId()) ) { vadi_N oteUserTea m = "CCA";  }
  254           if  (vadi_Use rHasTeam(" TAN", Xrm. Page.conte xt.getUser Id())) { v adi_NoteUs erTeam = " TAN"; }
  255           // **TEMP, ve rify these  team valu es that th ey are cor rect **FUT URE NEED**
  256           if  (vadi_Use rHasTeam(" PACT User" , Xrm.Page .context.g etUserId() )) { vadi_ NoteUserTe am = "PACT "; }
  257           if  (vadi_Use rHasTeam(" MSA User",  Xrm.Page. context.ge tUserId()) ) { vadi_N oteUserTea m = "MSA";  }
  258  
  259           // Verify Tea m Value, t hat one ha s been ass igned
  260           if  (vadi_Not eUserTeam  == "NONE")  {
  261                alert('T he current  author/ow ner does n ot belong  to a CRM t eam that c an integra te addendu ms, the ad dendum can not be cre ated in Vi stA/CPRS!' );
  262                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  263                return f alse;
  264           }
  265  
  266           // Get eSigna ture code
  267           va r vadi_eSi gnatureCod e = prompt ("Please e nter your  eSignature  Code belo w.\n");
  268           if  (vadi_eSi gnatureCod e == null  || vadi_eS ignatureCo de == "" | | vadi_eSi gnatureCod e == "unde fined") {
  269                alert('T he eSignat ure Code e ntered is  invalid, t he addendu m cannot b e created  in VistA/C PRS!');
  270                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  271                return f alse;
  272           }
  273  
  274           // Execute In tegration
  275           va di_execute VistaAdden dumIntegra tion(vadi_ vistaNoteI d, vadi_ad dendumText , vadi_eSi gnatureCod e);
  276       }
  277       catch  (err) {
  278           al ert('Adden dum Ribbon  Function  Error(vadi _ribbonBut tonSaveToV istA): ' +  err.messa ge);
  279           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  280       }
  281   }
  282  
  283   function v adi_execut eVistaAdde ndumIntegr ation(vadi _originalN oteId, vad i_noteDesc ription, v adi_eSigna tureCode)  {
  284       try {
  285           // Reformat N ote Descri ption as n eeded to h andle long  lines of  text (Word Wrap)
  286           va r vadi_Not eText = va di_noteDes cription;
  287           va r vadi_Rev isedNoteTe xt = "";
  288  
  289           // Do Breakdo wn of line s
  290           va r vadi_Tex tLines = v adi_NoteTe xt.split(' \n');
  291           if  (vadi_Tex tLines.len gth > 0) {
  292                //Reform at text
  293                for (var  i = 0; i  < vadi_Tex tLines.len gth; i++)  {
  294                    //Te st for a l ong line
  295                    if ( vadi_TextL ines[i].le ngth > vad i_WordWrap Limit) {
  296                         //Break do wn line
  297                         var vadi_N ewString =  vadi_word Wrap(vadi_ TextLines[ i], vadi_W ordWrapLim it, '\n');
  298                         //Add revi sed text b ack
  299                         vadi_Revis edNoteText  = vadi_Re visedNoteT ext + vadi _NewString  + "\n";   //Add back  the CR/LF  used to s plit on
  300                    }
  301                    else  {
  302                         //Add text  to new no te
  303                         vadi_Revis edNoteText  = vadi_Re visedNoteT ext + vadi _TextLines [i] + "\n" ; //Add ba ck the CR/ LF used to  split on
  304                    }
  305                }
  306           }
  307           if  (vadi_Rev isedNoteTe xt != "" & & vadi_Rev isedNoteTe xt != null ) {
  308                vadi_not eDescripti on = vadi_ RevisedNot eText;
  309           }
  310  
  311           // Add list o f addition al signer  names to N ote Text i f they exi sts
  312           if  (vadi_Add lSignersNa meArray !=  null && v adi_AddlSi gnersIenAr ray != nul l) {
  313                //Create  text stri ngs from a dditional  signers ar ray
  314                var vadi _SignerNam es = "\nAd ditional N ote Signer s\n" + "-- ---------- ---------- -------\n" ;
  315                for (var  i = 0; i  <= vadi_Ad dlSignersN ameArray.l ength - 1;  i++) {
  316                    if ( i >= 1) {
  317                         var vadi_s ingleSigne rName = va di_AddlSig nersNameAr ray[i].spl it("___");
  318                         vadi_Signe rNames = v adi_Signer Names + va di_singleS ignerName[ 1] + "\n";
  319                    }
  320                }
  321                //Add to  Note Desc ription
  322                vadi_not eDescripti on = vadi_ noteDescri ption + va di_SignerN ames;
  323           }
  324  
  325           va r vadi_use rSiteId =  "";
  326           va r vadi_Use rSiteNo =  "";
  327           va r vadi_duz  = "";
  328           va r vadi_pro vidername  = "";
  329  
  330           va r vadi_use rData = va di_getSing leEntityDa taSync('Sy stemUserSe t', 'ftp_F acilitySit eId', Xrm. Page.conte xt.getUser Id());
  331           if  (vadi_use rData != n ull) {
  332                if (vadi _userData. d.ftp_Faci litySiteId  != null)  {
  333                    vadi _userSiteI d = vadi_u serData.d. ftp_Facili tySiteId.I d;
  334                }
  335           }
  336  
  337           // Lookup the  Facility/ Site #
  338           if  (vadi_use rSiteId !=  null && v adi_userSi teId != '' ) {
  339                var vadi _facilityD ata = vadi _getSingle EntityData Sync('ftp_ facilitySe t', 'ftp_f acilitycod e', vadi_u serSiteId) ;
  340                if (vadi _facilityD ata != nul l) {
  341                    if ( vadi_facil ityData.d. ftp_facili tycode !=  null) { va di_UserSit eNo = vadi _facilityD ata.d.ftp_ facilityco de; }
  342                }
  343           }
  344  
  345           // Check if V IA Login c ookie exis t (not exp ired)
  346           va r vadi_Via LoginCooki e = vadi_g etCookie(" viasession link");
  347           if  (vadi_Via LoginCooki e != null  && vadi_Vi aLoginCook ie != '')  {
  348                var vadi _cookiearr ay = vadi_ ViaLoginCo okie.split ("~~~~", 2 );
  349                vadi_duz  = vadi_co okiearray[ 0];
  350                vadi_pro vidername  = vadi_coo kiearray[1 ];
  351           }
  352  
  353           // Create the  VIA Adden dum Record
  354           va r vadi_via Addendum =  new Objec t();
  355           va di_viaAdde ndum.Provi derName =  vadi_provi dername;
  356           va di_viaAdde ndum.Duz =  vadi_duz;
  357           va di_viaAdde ndum.Login SiteCode =  vadi_User SiteNo;
  358           va di_viaAdde ndum.Targe t = vadi_o riginalNot eId;
  359           va di_viaAdde ndum.Adden dumNote =  vadi_noteD escription ;
  360           // vadi_viaAd dendum.Cri teria = "C riteria -  Test of ne w attribut e.";
  361           va di_viaAdde ndum.Crite ria = vadi _noteDescr iption;
  362  
  363           $. ajax({
  364                type: "P OST",
  365                url: vad i_CreateAd dendumUrl,
  366                data: JS ON.stringi fy(vadi_vi aAddendum) ,
  367                contentT ype: "appl ication/js on; charse t=utf-8",
  368                dataType : "json",
  369                success:  function  (data) {
  370                    var  vadi_newda ta = data. Data;
  371                    vadi _requestRe sponse = v adi_newdat a;
  372                    vadi _executeVi staAddendu mIntegrati on_respons e(null, va di_request Response,  vadi_noteD escription , vadi_eSi gnatureCod e);
  373                },
  374                error: f unction (j qXHR, text Status, er rorThrown)  {
  375                    //Sy stem Error
  376                    vadi _executeVi staAddendu mIntegrati on_respons e(errorThr own, null,  vadi_note Descriptio n, vadi_eS ignatureCo de);
  377                },
  378                async: f alse,
  379                cache: f alse
  380           }) ;
  381  
  382       }
  383       catch  (err) {
  384           al ert('Adden dum Ribbon  Function  Error(vadi _executeVi staAddendu mIntegrati on): ' + e rr.message );
  385           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  386       }
  387   }
  388  
  389   function v adi_execut eVistaAdde ndumIntegr ation_resp onse(vadi_ errorThrow n, vadi_re questRespo nse, vadi_ noteDescri ption, vad i_eSignatu reCode) {
  390       try {
  391           // Process In tegration  Request Re sponse
  392           if  (vadi_err orThrown ! = null) {
  393                //Write  Error
  394                Xrm.Page .getAttrib ute('ftp_i ntegration status').s etValue('E RROR');
  395                Xrm.Page .getAttrib ute('ftp_i ntegration status').s etSubmitMo de('always ');
  396                Xrm.Page .getAttrib ute('ftp_i ntegration error').se tValue(Str ing(vadi_e rrorThrown ));
  397                Xrm.Page .getAttrib ute('ftp_i ntegration error').se tSubmitMod e('always' );
  398                Xrm.Page .getAttrib ute('ftp_i ntegration date').set Value(new  Date());
  399                Xrm.Page .getAttrib ute('ftp_i ntegration date').set SubmitMode ('always') ;
  400                Xrm.Page .getAttrib ute('ftp_a ddendumnot eid').setV alue('');
  401                Xrm.Page .getAttrib ute('ftp_a ddendumnot eid').setS ubmitMode( 'always');
  402                alert('T he addendu m creation  in VistA/ CPRS faile d!\nPlease  see the i ntegration  error fie ld for det ails.');
  403                Xrm.Page .getContro l('ftp_int egrationer ror').setF ocus();
  404                Xrm.Page .data.enti ty.save();
  405                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  406                return f alse;
  407           }
  408           el se {
  409                //Write  web servic e response  Success o r Failure
  410                if (vadi _requestRe sponse[0]. Fault == n ull) {
  411                    //Ve rify that  a Note Id  was create d for the  addendum a nd that it  is a numb er (not er ror messag e)
  412                    if ( isNaN(vadi _requestRe sponse[0]. Text) == f alse) {
  413                         //Call Add itional Si gners & Fi nalize Add endum func tion
  414                         vadi_final izeAddendu mCreation( "OK", vadi _requestRe sponse[0]. Text, vadi _noteDescr iption, va di_eSignat ureCode)
  415                    }
  416                    else  {
  417                         //Write Fa ilure entr y since th e NoteId i s not a nu mber
  418                         Xrm.Page.g etAttribut e('ftp_int egrationst atus').set Value('ERR OR');
  419                         Xrm.Page.g etAttribut e('ftp_int egrationst atus').set SubmitMode ('always') ;
  420                         Xrm.Page.g etAttribut e('ftp_int egrationer ror').setV alue(vadi_ requestRes ponse[0].T ext);
  421                         Xrm.Page.g etAttribut e('ftp_int egrationer ror').setS ubmitMode( 'always');
  422                         Xrm.Page.g etAttribut e('ftp_int egrationda te').setVa lue(new Da te());
  423                         Xrm.Page.g etAttribut e('ftp_int egrationda te').setSu bmitMode(' always');
  424                         Xrm.Page.g etAttribut e('ftp_add endumnotei d').setVal ue('');
  425                         Xrm.Page.g etAttribut e('ftp_add endumnotei d').setSub mitMode('a lways');
  426                         alert('The  addendum  creation i n VistA/CP RS failed! \nPlease s ee the int egration e rror field  for detai ls.');
  427                         Xrm.Page.g etControl( 'ftp_integ rationerro r').setFoc us();
  428                         Xrm.Page.d ata.entity .save();
  429                         Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA");
  430                         return fal se;
  431                    }
  432                }
  433                else {
  434                    //Wr ite Failur e entry
  435                    Xrm. Page.getAt tribute('f tp_integra tionstatus ').setValu e('ERROR') ;
  436                    Xrm. Page.getAt tribute('f tp_integra tionstatus ').setSubm itMode('al ways');
  437                    Xrm. Page.getAt tribute('f tp_integra tionerror' ).setValue (vadi_requ estRespons e[0].Fault .Message);
  438                    Xrm. Page.getAt tribute('f tp_integra tionerror' ).setSubmi tMode('alw ays');
  439                    Xrm. Page.getAt tribute('f tp_integra tiondate') .setValue( new Date() );
  440                    Xrm. Page.getAt tribute('f tp_integra tiondate') .setSubmit Mode('alwa ys');
  441                    Xrm. Page.getAt tribute('f tp_addendu mnoteid'). setValue(' ');
  442                    Xrm. Page.getAt tribute('f tp_addendu mnoteid'). setSubmitM ode('alway s');
  443                    aler t('The add endum crea tion in Vi stA/CPRS f ailed!\nPl ease see t he integra tion error  field for  details.' );
  444                    Xrm. Page.getCo ntrol('ftp _integrati onerror'). setFocus() ;
  445                    Xrm. Page.data. entity.sav e();
  446                    Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA ");
  447                    retu rn false;
  448                }
  449           }
  450       }
  451       catch  (err) {
  452           al ert('Adden dum Ribbon  Function  Error(vadi _executeVi staAddendu mIntegrati on_respons e): ' + er r.message) ;
  453           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  454       }
  455   }
  456  
  457   function v adi_finali zeAddendum Creation(v adi_integr ationStatu s, vadi_in tegrationN oteId, vad i_noteDesc ription, v adi_eSigna tureCode)  {
  458       //The  Addendum w as sucessf ully creat ed in Vist a/CPRS, ad d addition al signers  if needed
  459       try {
  460           // Determine  if additio nal signer s exists
  461           if  (vadi_Add lSignersNa meArray !=  null && v adi_AddlSi gnersIenAr ray != nul l) {
  462                //Get th e current  CRM User's  assigned  site/facil ity
  463                var vadi _userSiteI d = "";
  464                var vadi _UserSiteN o = "";
  465                var vadi _duz = "";
  466                var vadi _providern ame = "";
  467  
  468                var vadi _userData  = vadi_get SingleEnti tyDataSync ('SystemUs erSet', 'f tp_Facilit ySiteId',  Xrm.Page.c ontext.get UserId());
  469                if (vadi _userData  != null) {
  470                    if ( vadi_userD ata.d.ftp_ FacilitySi teId != nu ll) {
  471                         vadi_userS iteId = va di_userDat a.d.ftp_Fa cilitySite Id.Id;
  472                    }
  473                }
  474  
  475                //Lookup  the Facil ity/Site #
  476                if (vadi _userSiteI d != null  && vadi_us erSiteId ! = '') {
  477                    var  vadi_facil ityData =  vadi_getSi ngleEntity DataSync(' ftp_facili tySet', 'f tp_facilit ycode', va di_userSit eId);
  478                    if ( vadi_facil ityData !=  null) {
  479                         if (vadi_f acilityDat a.d.ftp_fa cilitycode  != null)  { vadi_Use rSiteNo =  vadi_facil ityData.d. ftp_facili tycode; }
  480                    }
  481                }
  482  
  483                //Check  if VIA Log in cookie  exist (not  expired)
  484                var vadi _ViaLoginC ookie = va di_getCook ie("viases sionlink") ;
  485                if (vadi _ViaLoginC ookie != n ull && vad i_ViaLogin Cookie !=  '') {
  486                    var  vadi_cooki earray = v adi_ViaLog inCookie.s plit("~~~~ ", 2);
  487                    vadi _duz = vad i_cookiear ray[0];
  488                    vadi _providern ame = vadi _cookiearr ay[1];
  489                }
  490  
  491                //Create  text stri ngs from a dditional  signers ar ray
  492                var vadi _SignerIEN  = "";
  493                for (var  i = 0; i  <= vadi_Ad dlSignersI enArray.le ngth - 1;  i++) {
  494                    if ( i == 1) {  vadi_Signe rIEN = vad i_AddlSign ersIenArra y[i]; }
  495                    if ( i > 1) { v adi_Signer IEN = vadi _SignerIEN  + " " + v adi_AddlSi gnersIenAr ray[i]; }
  496                }
  497  
  498                //Create  the Addit ional Sign ers
  499                var vadi _viaSigner s = new Ob ject();
  500                vadi_via Signers.Pr oviderName  = vadi_pr ovidername ;
  501                vadi_via Signers.Du z = vadi_d uz;
  502                vadi_via Signers.Lo ginSiteCod e = vadi_U serSiteNo;
  503                vadi_via Signers.Ta rget = vad i_integrat ionNoteId;
  504                vadi_via Signers.Su pplemental Parameters  = vadi_Si gnerIEN;
  505  
  506                $.ajax({
  507                    type : "POST",
  508                    url:  vadi_AddS ignersUrl,
  509                    data : JSON.str ingify(vad i_viaSigne rs),
  510                    cont entType: " applicatio n/json; ch arset=utf- 8",
  511                    data Type: "jso n",
  512                    succ ess: funct ion (data)  {
  513                         vadi_viaSi gnersRespo nse = JSON .stringify (data.Data );
  514                         //Test for  Failure
  515                         if (vadi_v iaSignersR esponse.Er rorOccurre d == true)  {
  516                             alert( "Error: Un able to ad d the addi tional sig ners selec ted to thi s addendum .\n\nPleas e review t he addendu m and sign ers in you r Vista/CP RS applica tion!");
  517                         }
  518                    },
  519                    erro r: functio n (jqXHR,  textStatus , errorThr own) {
  520                         //System E rror
  521                         alert("Err or: Unable  to add th e addition al signers  selected  to this ad dendum.\n\ nPlease re view the a ddendum an d signers  in your Vi sta/CPRS a pplication !");
  522                    },
  523                    asyn c: false,
  524                    cach e: false
  525                });
  526  
  527                if (vadi _localStor ageVarName  != "" &&  vadi_local StorageVar Name != nu ll) {
  528                    //Cl ear existi ng session  storage v ariable.
  529                    loca lStorage.r emoveItem( vadi_local StorageVar Name);
  530                }
  531           }
  532  
  533           // **NOTE: TH E SECTION  BELOW IS T EMPORARILY  DISABLED  DUE TO THE  SIGN NOTE  SERVICE F AILING WIT H ADDENDUM S....
  534           // Temporaril y undid co mment out  for testin g of VIA f ix 11/6/20 17
  535           
  536           // Add primar y signer's  e-signatu re
  537           if  (vadi_eSi gnatureCod e != null  && vadi_eS ignatureCo de != '')  {
  538                //Get th e current  CRM User's  assigned  site/facil ity
  539                var vadi _userSiteI d = "";
  540                var vadi _UserSiteN o = "";
  541                var vadi _duz = "";
  542                var vadi _providern ame = "";
  543  
  544                var vadi _userData  = vadi_get SingleEnti tyDataSync ('SystemUs erSet', 'f tp_Facilit ySiteId',  Xrm.Page.c ontext.get UserId());
  545                if (vadi _userData  != null) {
  546                    if ( vadi_userD ata.d.ftp_ FacilitySi teId != nu ll) {
  547                         vadi_userS iteId = va di_userDat a.d.ftp_Fa cilitySite Id.Id;
  548                    }
  549                }
  550  
  551                //Lookup  the Facil ity/Site #
  552                if (vadi _userSiteI d != null  && vadi_us erSiteId ! = '') {
  553                    var  vadi_facil ityData =  vadi_getSi ngleEntity DataSync(' ftp_facili tySet', 'f tp_facilit ycode', va di_userSit eId);
  554                    if ( vadi_facil ityData !=  null) {
  555                         if (vadi_f acilityDat a.d.ftp_fa cilitycode  != null)  { vadi_Use rSiteNo =  vadi_facil ityData.d. ftp_facili tycode; }
  556                    }
  557                }
  558  
  559                //Check  if VIA Log in cookie  exist (not  expired)
  560                var vadi _ViaLoginC ookie = va di_getCook ie("viases sionlink") ;
  561                if (vadi _ViaLoginC ookie != n ull && vad i_ViaLogin Cookie !=  '') {
  562                    var  vadi_cooki earray = v adi_ViaLog inCookie.s plit("~~~~ ", 2);
  563                    vadi _duz = vad i_cookiear ray[0];
  564                    vadi _providern ame = vadi _cookiearr ay[1];
  565                }
  566  
  567                var vadi _viaSignAd dendum = n ew Object( );
  568                vadi_via SignAddend um.Provide rName = va di_provide rname;
  569                vadi_via SignAddend um.Duz = v adi_duz;
  570                vadi_via SignAddend um.LoginSi teCode = v adi_UserSi teNo;
  571                vadi_via SignAddend um.NoteIEN  = vadi_in tegrationN oteId;
  572                vadi_via SignAddend um.ESig =  vadi_eSign atureCode;
  573  
  574                $.ajax({
  575                    type : "POST",
  576                    url:  vadi_Sign NoteUrl,
  577                    data : JSON.str ingify(vad i_viaSignA ddendum),
  578                    cont entType: " applicatio n/json; ch arset=utf- 8",
  579                    data Type: "jso n",
  580                    succ ess: funct ion (data)  {
  581                         vadi_viaSi gnAddendum Response =  JSON.stri ngify(data .Data);
  582                         //Test for  Failure
  583                         if (vadi_v iaSignAdde ndumRespon se.ErrorOc curred ==  true) {
  584                             alert( "Error: Un able to si gn the add endum usin g the e-Si gnature pr ovided.\n\ nPlease re view the a ddendum an d signers  in your Vi sta/CPRS a pplication !");
  585  
  586                             //aler t("MORE DE TAILS: " +  vadi_viaS ignAddendu mResponse. ErrorMessa ge);
  587  
  588                         }
  589                         else {
  590                             //Upda te esign f ields on f orm
  591  
  592                             //aler t("NO ESIG N ERROR.." );
  593  
  594                         }
  595                    },
  596                    erro r: functio n (jqXHR,  textStatus , errorThr own) {
  597                         //System E rror
  598                         alert("Err or: Unable  to sign t he addendu m using th e e-Signat ure provid ed.\n\nPle ase review  the adden dum and si gners in y our Vista/ CPRS appli cation!");
  599                    },
  600                    asyn c: false,
  601                    cach e: false
  602                });
  603           }
  604  
  605           // Perform st andard for m updates  to signify  completio n
  606           // Write Succ ess entry
  607           Xr m.Page.get Attribute( 'descripti on').setVa lue(vadi_n oteDescrip tion);
  608           Xr m.Page.get Attribute( 'descripti on').setSu bmitMode(' always');
  609           Xr m.Page.get Attribute( 'ftp_integ rationstat us').setVa lue(vadi_i ntegration Status);
  610           Xr m.Page.get Attribute( 'ftp_integ rationstat us').setSu bmitMode(' always');
  611           Xr m.Page.get Attribute( 'ftp_integ rationerro r').setVal ue(null);
  612           Xr m.Page.get Attribute( 'ftp_integ rationerro r').setSub mitMode('a lways');
  613           Xr m.Page.get Attribute( 'ftp_integ rationdate ').setValu e(new Date ());
  614           Xr m.Page.get Attribute( 'ftp_integ rationdate ').setSubm itMode('al ways');
  615           Xr m.Page.get Attribute( 'ftp_adden dumnoteid' ).setValue (vadi_inte grationNot eId);
  616           Xr m.Page.get Attribute( 'ftp_adden dumnoteid' ).setSubmi tMode('alw ays');
  617           Xr m.Page.get Control('f tp_integra tionstatus ').setFocu s();
  618           al ert('The a ddendum cr eation in  VistA/CPRS  was succe ssful, thi s addendum  will now  be marked  as complet ed. \n\nPl ease exit  this adden dum record  after cli cking OK t o this pro mpt!');
  619           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  620           Xr m.Page.dat a.entity.s ave();
  621       }
  622       catch  (err) {
  623           al ert('Adden dum Ribbon  Function  Error(vadi _finalizeA ddendumCre ation): '  + err.mess age);
  624           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  625       }
  626   }
  627  
  628   function v adi_UserHa sTeam(team Name, user Guid) {
  629       try {
  630           va r vadi_tea mid = null ;
  631           va r vadi_cur rentUserId  = userGui d;
  632           va r vadi_con ditionalFi lter = "(N ame eq '"  + teamName  + "')";
  633           va r vadi_tea mData = va di_getMult ipleEntity DataSync(' TeamSet',  'TeamId',  vadi_condi tionalFilt er, 'Name' , 'asc', 0 );
  634           if  (vadi_tea mData != n ull) {
  635                for (var  i = 0; i  <= vadi_te amData.d.r esults.len gth - 1; i ++) {
  636                    //Ge t Info
  637                    if ( vadi_teamD ata.d.resu lts[i].Tea mId != nul l) { vadi_ teamid = v adi_teamDa ta.d.resul ts[i].Team Id; }
  638                    brea k;
  639                }
  640           }
  641           // If Team ex ists, chec k if the c urrent use r is part  of that te am
  642           va r vadi_tea mMembershi pId = null ;
  643           if  (vadi_tea mid != nul l && vadi_ currentUse rId != nul l) {
  644                var vadi _condition alFilter =  "(TeamId  eq (guid'"  + vadi_te amid + "')  and Syste mUserId eq  (guid'" +  vadi_curr entUserId  + "'))";
  645                var vadi _teamMembe rshipData  = vadi_get MultipleEn tityDataSy nc('TeamMe mbershipSe t', 'TeamI d, SystemU serId,Team Membership Id', vadi_ conditiona lFilter, ' TeamId', ' asc', 0);
  646                if (vadi _teamMembe rshipData  != null) {
  647                    for  (var i = 0 ; i <= vad i_teamMemb ershipData .d.results .length -  1; i++) {
  648                         //Get Info
  649                         if (vadi_t eamMembers hipData.d. results[i] .TeamMembe rshipId !=  null) { v adi_teamMe mbershipId  = vadi_te amMembersh ipData.d.r esults[i]. TeamMember shipId; }
  650                         break;
  651                    }
  652                }
  653           }
  654           if  (vadi_tea mMembershi pId != nul l) { retur n true; }
  655  
  656           // otherwise  return fal se                 
  657           re turn false ;
  658       }
  659       catch  (err) {
  660           // Display Er ror
  661           al ert("An er ror occure d in the v adi_UserHa sTeam func tion.  Err or Detail  Message: "  + err);
  662       }
  663   }
  664  
  665   function v adi_getCoo kie(cname)  {
  666       try {
  667           va r name = c name + "=" ;
  668           va r ca = doc ument.cook ie.split(' ;');
  669           fo r (var i =  0; i < ca .length; i ++) {
  670                var c =  ca[i];
  671                while (c .charAt(0)  == ' ') {
  672                    c =  c.substrin g(1);
  673                }
  674                if (c.in dexOf(name ) == 0) {
  675                    retu rn c.subst ring(name. length, c. length);
  676                }
  677           }
  678           re turn "";
  679       }
  680       catch  (err) {
  681           al ert('Adden dum Ribbon  Function  Error(vadi _getCookie ): ' + err .message);
  682       }
  683   }
  684  
  685   function v adi_wordWr ap(str, in tWidth, st rBreak, cu t) {
  686       try {
  687           // Takes a st ring that  exceeds a  set length  and inser ts word wr ap
  688           va r m = ((ar guments.le ngth >= 2)  ? argumen ts[1] : 75 )
  689           va r b = ((ar guments.le ngth >= 3)  ? argumen ts[2] : '\ n')
  690           va r c = ((ar guments.le ngth >= 4)  ? argumen ts[3] : fa lse)
  691  
  692           va r i, j, l,  s, r
  693  
  694           st r += ''
  695  
  696           if  (m < 1) {
  697                return s tr
  698           }
  699  
  700           fo r (i = -1,  l = (r =  str.split( /\r\n|\n|\ r/)).lengt h; ++i < l ; r[i] +=  s) {
  701                for (s =  r[i], r[i ] = '';
  702                    s.le ngth > m;
  703                    r[i]  += s.slic e(0, j) +  ((s = s.sl ice(j)).le ngth ? b :  '')) {
  704                    j =  c === 2 ||  (j = s.sl ice(0, m +  1).match( /\S*(\s)?$ /))[1]
  705                         ? m
  706                         : j.input. length - j [0].length  || c ===  true && m  ||
  707                         j.input.le ngth + (j  = s.slice( m).match(/ ^\S*/))[0] .length
  708                }
  709           }
  710  
  711           re turn r.joi n('\n')
  712       }
  713       catch  (err) {
  714           al ert('Adden dum Ribbon  Function  Error(vadi _wordWrap) : ' + err. message);
  715       }
  716   }
  717  
  718  
  719   function v adi_execut eCrmOdataG etRequest( vadi_jsonQ uery, vadi _aSync, va di_aSyncCa llback, va di_skipCou nt, vadi_o ptionArray ) {
  720       //This  function  executes a  CRM Odata  web servi ce call to  retrieve  Crm data
  721       //*vad i_jsonQuer y* - a pro perly form atted CRM  Odata Quer y string ( required)
  722       //*vad i_aSync* -  specify ' true' to e xecute asy nchronousl y otherwis e 'false'  (required)
  723       //*vad i_aSyncCal lback* - s pecify the  name of t he return  function t o call upo n completi on (requir ed if vadi _aSync = t rue.  Othe rwise '')
  724       //*vad i_skipCoun t* - Initi al setting  is always  '0', incr ements by  50 per CRM  SDK Odata  standards  (required )
  725       //*vad i_optionAr ray* - is  an optiona l array or  single va lue, that  contains a dditional  task speci fic variab les that c an be pass ed between  functions  (pass 'nu ll' if not  used)
  726       try {
  727           va r vadi_ent ityData =  null;
  728           $. ajax({
  729                type: 'G ET',
  730                contentT ype: 'appl ication/js on; charse t=utf-8',
  731                datatype : 'json',
  732                url: vad i_jsonQuer y,
  733                beforeSe nd: functi on (XMLHtt pRequest)  {
  734                    XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json');
  735                },
  736                success:  function  (data, tex tStatus, X mlHttpRequ est) {
  737                    vadi _entityDat a = data;
  738                    if ( vadi_aSync  == true)  {
  739                         vadi_aSync Callback(v adi_entity Data, vadi _skipCount , vadi_opt ionArray);
  740                    }
  741                },
  742                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  743                    aler t('Fail: A jax Error  in vadi_ex ecuteCrmOd ataGetRequ est: ' + e rrorThrown  + " Reque st: " + va di_jsonQue ry);
  744                },
  745                async: v adi_aSync,
  746                cache: f alse
  747           }) ;
  748           re turn vadi_ entityData ;
  749       }
  750       catch  (err) {
  751           al ert('An er ror occure d in the v adi_execut eCrmOdataG etRequest  function.   Error Det ail Messag e: ' + err );
  752       }
  753   }
  754  
  755   function v adi_getMul tipleEntit yDataAsync (vadi_enti tySetName,  vadi_attr ibuteSet,  vadi_condi tionalFilt er, vadi_s ortAttribu te, vadi_s ortDirecti on, vadi_s kipCount,  vadi_aSync Callback,  vadi_optio nArray) {
  756       //This  function  returns a  CRM JSON d ataset for  all entit y records  matching c riteria pr ovided Asy ncronously
  757       //*vad i_entitySe tName* - i s the name  of the en tity set e .g 'Contac tSet'
  758       //*vad i_attribut eSet* -  i s a string  containin g the Crm  Attributes  to retrie ve e.g. 'F irstName,  LastName,  Telephone1 , EMailAdd ress1'
  759       //*vad i_conditio nalFilter*  - is the  conditiona l filter v alue place d on the d ata values  retrived  e.g. 'Stat eCode/Valu e eq 0'  t o retrieve  active co ntact reco rds only
  760       //*vad i_sortAttr ibute* - i s a string  containin g the name  of the at tribute to  sort the  result set  by e.g. ' LastName'
  761       //*vad i_sortDire ction* - i s a string  specifyin g the sort  as Ascend ing or Des cending e. g. 'asc' o r 'desc'
  762       //*vad i_skipCoun t* - is th e starting  point in  the result  (use if m ore than 5 0), (Put 0  if not us ed)
  763       //*vad i_aSyncCal lback* - i s the name  of the fu nction to  call when  returning  the result
  764       //*vad i_optionAr ray* - is  an optiona l array, t hat contai ns additio nal task s pecific va riables th at can be  passed bet ween funct ions
  765  
  766       try {
  767           va r vadi_jso nQuery = v adi_server Url + vadi _crmOdataE ndPoint +  '/' + vadi _entitySet Name + '?$ select=' +  vadi_attr ibuteSet +  '&$filter =' + vadi_ conditiona lFilter +  '&$orderby =' + vadi_ sortAttrib ute + ' '  + vadi_sor tDirection  + '&$skip =' + vadi_ skipCount;
  768           va di_execute CrmOdataGe tRequest(v adi_jsonQu ery, true,  vadi_aSyn cCallback,  vadi_skip Count, vad i_optionAr ray);
  769       }
  770       catch  (err) {
  771           al ert('An er ror occure d in the v adi_getMul tipleEntit yDataAsync  function.   Error De tail Messa ge: ' + er r);
  772       }
  773   }
  774  
  775   function v adi_getSin gleEntityD ataSync(va di_entityS etName, va di_attribu teSet, vad i_entityId ) {
  776       //This  function  returns a  CRM JSON d ataset for  a single  entity rec ord based  on the ent ity id pro vided Sync ronously
  777       //*vad i_entitySe tName* - i s the name  of the en tity set e .g 'Contac tSet'
  778       //*vad i_attribut eSet* -  i s a string  containin g the Crm  Attributes  to retrie ve e.g. 'F irstName,  LastName,  Telephone1 , EMailAdd ress1'
  779       //*vad i_entityId * - is the  Guid for  the entity  record
  780  
  781       try {
  782           va r vadi_ent ityIdNoBra cket = vad i_entityId .replace(/ ({|})/g, ' ');
  783           va r vadi_sel ectString  = '(guid'  + "'" + va di_entityI dNoBracket  + "'" + ' )?$select= ' + vadi_a ttributeSe t;
  784           va r vadi_jso nQuery = v adi_server Url + vadi _crmOdataE ndPoint +  '/' + vadi _entitySet Name + vad i_selectSt ring;
  785           va r vadi_ent ityData =  vadi_execu teCrmOdata GetRequest (vadi_json Query, fal se, '', 0,  null);
  786           re turn vadi_ entityData ;
  787       }
  788       catch  (err) {
  789           al ert('An er ror occure d in the v adi_getSin gleEntityD ataSync fu nction.  E rror Detai l Message:  ' + err);
  790       }
  791   }
  792  
  793   function v adi_getMul tipleEntit yDataSync( vadi_entit ySetName,  vadi_attri buteSet, v adi_condit ionalFilte r, vadi_so rtAttribut e, vadi_so rtDirectio n, vadi_sk ipCount) {
  794       //This  function  returns a  CRM JSON d ataset for  all entit y records  matching c riteria pr ovided Syn cronously
  795       //*vad i_entitySe tName* - i s the name  of the en tity set e .g 'Contac tSet'
  796       //*vad i_attribut eSet* -  i s a string  containin g the Crm  Attributes  to retrie ve e.g. 'F irstName,  LastName,  Telephone1 , EMailAdd ress1'
  797       //*vad i_conditio nalFilter*  - is the  conditiona l filter v alue place d on the d ata values  retrived  e.g. 'Stat eCode/Valu e eq 0'  t o retrieve  active co ntact reco rds only
  798       //*vad i_sortAttr ibute* - i s a string  containin g the name  of the at tribute to  sort the  result set  by e.g. ' LastName'
  799       //*vad i_sortDire ction* - i s a string  specifyin g the sort  as Ascend ing or Des cending e. g. 'asc' o r 'desc'
  800       //*vad i_skipCoun t* - is th e starting  point in  the result  (use if m ore than 5 0), (Put 0  if not us ed)
  801  
  802       try {
  803           va r vadi_jso nQuery = v adi_server Url + vadi _crmOdataE ndPoint +  '/' + vadi _entitySet Name + '?$ select=' +  vadi_attr ibuteSet +  '&$filter =' + vadi_ conditiona lFilter +  '&$orderby =' + vadi_ sortAttrib ute + ' '  + vadi_sor tDirection  + '&$skip =' + vadi_ skipCount;
  804           va r vadi_ent ityData =  vadi_execu teCrmOdata GetRequest (vadi_json Query, fal se, '', va di_skipCou nt, null);
  805           re turn vadi_ entityData ;
  806       }
  807       catch  (err) {
  808           al ert('An er ror occure d in the v adi_getMul tipleEntit yDataSync  function.   Error Det ail Messag e: ' + err );
  809       }
  810   }