79. EPMO Open Source Coordination Office Redaction File Detail Report

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

79.1 Files compared

# Location File Last Modified
1 VCCM.zip\VCCM\CRM_solutions\VCCMResources\VCCMResources_1_0_0_21.zip\WebResources ftp_VistaAddendumIntegrationFormScriptVistaAddendu9B734B60-18FD-E611-944C-0050568D743D Fri Aug 18 14:55:00 2017 UTC
2 VCCM.zip\VCCM\CRM_solutions\VCCMResources\VCCMResources_1_0_0_21.zip\WebResources ftp_VistaAddendumIntegrationFormScriptVistaAddendu9B734B60-18FD-E611-944C-0050568D743D Thu Nov 30 17:20:49 2017 UTC

79.2 Comparison summary

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

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

79.4 Active regular expressions

No regular expressions were active.

79.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:// qacrmdac.n p.crm.vrm. vba. DNS     /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://qacr mdac.np.cr m.vrm.vba. DNS     /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:// qacrmdac.n p.crm.vrm. vba. DNS     /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://qacrmd ac.np.crm. vrm.vba. DNS     /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  
  361           $. ajax({
  362                type: "P OST",
  363                url: vad i_CreateAd dendumUrl,
  364                data: JS ON.stringi fy(vadi_vi aAddendum) ,
  365                contentT ype: "appl ication/js on; charse t=utf-8",
  366                dataType : "json",
  367                success:  function  (data) {
  368                    var  vadi_newda ta = data. Data;
  369                    vadi _requestRe sponse = v adi_newdat a;
  370                    vadi _executeVi staAddendu mIntegrati on_respons e(null, va di_request Response,  vadi_noteD escription , vadi_eSi gnatureCod e);
  371                },
  372                error: f unction (j qXHR, text Status, er rorThrown)  {
  373                    //Sy stem Error
  374                    vadi _executeVi staAddendu mIntegrati on_respons e(errorThr own, null,  vadi_note Descriptio n, vadi_eS ignatureCo de);
  375                },
  376                async: f alse,
  377                cache: f alse
  378           }) ;
  379  
  380       }
  381       catch  (err) {
  382           al ert('Adden dum Ribbon  Function  Error(vadi _executeVi staAddendu mIntegrati on): ' + e rr.message );
  383           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  384       }
  385   }
  386  
  387   function v adi_execut eVistaAdde ndumIntegr ation_resp onse(vadi_ errorThrow n, vadi_re questRespo nse, vadi_ noteDescri ption, vad i_eSignatu reCode) {
  388       try {
  389           // Process In tegration  Request Re sponse
  390           if  (vadi_err orThrown ! = null) {
  391                //Write  Error
  392                Xrm.Page .getAttrib ute('ftp_i ntegration status').s etValue('E RROR');
  393                Xrm.Page .getAttrib ute('ftp_i ntegration status').s etSubmitMo de('always ');
  394                Xrm.Page .getAttrib ute('ftp_i ntegration error').se tValue(Str ing(vadi_e rrorThrown ));
  395                Xrm.Page .getAttrib ute('ftp_i ntegration error').se tSubmitMod e('always' );
  396                Xrm.Page .getAttrib ute('ftp_i ntegration date').set Value(new  Date());
  397                Xrm.Page .getAttrib ute('ftp_i ntegration date').set SubmitMode ('always') ;
  398                Xrm.Page .getAttrib ute('ftp_a ddendumnot eid').setV alue('');
  399                Xrm.Page .getAttrib ute('ftp_a ddendumnot eid').setS ubmitMode( 'always');
  400                alert('T he addendu m creation  in VistA/ CPRS faile d!\nPlease  see the i ntegration  error fie ld for det ails.');
  401                Xrm.Page .getContro l('ftp_int egrationer ror').setF ocus();
  402                Xrm.Page .data.enti ty.save();
  403                Xrm.Page .ui.clearF ormNotific ation("SAV EVISTA");
  404                return f alse;
  405           }
  406           el se {
  407                //Write  web servic e response  Success o r Failure
  408                if (vadi _requestRe sponse[0]. Fault == n ull) {
  409                    //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)
  410                    if ( isNaN(vadi _requestRe sponse[0]. Text) == f alse) {
  411                         //Call Add itional Si gners & Fi nalize Add endum func tion
  412                         vadi_final izeAddendu mCreation( "OK", vadi _requestRe sponse[0]. Text, vadi _noteDescr iption, va di_eSignat ureCode)
  413                    }
  414                    else  {
  415                         //Write Fa ilure entr y since th e NoteId i s not a nu mber
  416                         Xrm.Page.g etAttribut e('ftp_int egrationst atus').set Value('ERR OR');
  417                         Xrm.Page.g etAttribut e('ftp_int egrationst atus').set SubmitMode ('always') ;
  418                         Xrm.Page.g etAttribut e('ftp_int egrationer ror').setV alue(vadi_ requestRes ponse[0].T ext);
  419                         Xrm.Page.g etAttribut e('ftp_int egrationer ror').setS ubmitMode( 'always');
  420                         Xrm.Page.g etAttribut e('ftp_int egrationda te').setVa lue(new Da te());
  421                         Xrm.Page.g etAttribut e('ftp_int egrationda te').setSu bmitMode(' always');
  422                         Xrm.Page.g etAttribut e('ftp_add endumnotei d').setVal ue('');
  423                         Xrm.Page.g etAttribut e('ftp_add endumnotei d').setSub mitMode('a lways');
  424                         alert('The  addendum  creation i n VistA/CP RS failed! \nPlease s ee the int egration e rror field  for detai ls.');
  425                         Xrm.Page.g etControl( 'ftp_integ rationerro r').setFoc us();
  426                         Xrm.Page.d ata.entity .save();
  427                         Xrm.Page.u i.clearFor mNotificat ion("SAVEV ISTA");
  428                         return fal se;
  429                    }
  430                }
  431                else {
  432                    //Wr ite Failur e entry
  433                    Xrm. Page.getAt tribute('f tp_integra tionstatus ').setValu e('ERROR') ;
  434                    Xrm. Page.getAt tribute('f tp_integra tionstatus ').setSubm itMode('al ways');
  435                    Xrm. Page.getAt tribute('f tp_integra tionerror' ).setValue (vadi_requ estRespons e[0].Fault .Message);
  436                    Xrm. Page.getAt tribute('f tp_integra tionerror' ).setSubmi tMode('alw ays');
  437                    Xrm. Page.getAt tribute('f tp_integra tiondate') .setValue( new Date() );
  438                    Xrm. Page.getAt tribute('f tp_integra tiondate') .setSubmit Mode('alwa ys');
  439                    Xrm. Page.getAt tribute('f tp_addendu mnoteid'). setValue(' ');
  440                    Xrm. Page.getAt tribute('f tp_addendu mnoteid'). setSubmitM ode('alway s');
  441                    aler t('The add endum crea tion in Vi stA/CPRS f ailed!\nPl ease see t he integra tion error  field for  details.' );
  442                    Xrm. Page.getCo ntrol('ftp _integrati onerror'). setFocus() ;
  443                    Xrm. Page.data. entity.sav e();
  444                    Xrm. Page.ui.cl earFormNot ification( "SAVEVISTA ");
  445                    retu rn false;
  446                }
  447           }
  448       }
  449       catch  (err) {
  450           al ert('Adden dum Ribbon  Function  Error(vadi _executeVi staAddendu mIntegrati on_respons e): ' + er r.message) ;
  451           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  452       }
  453   }
  454  
  455   function v adi_finali zeAddendum Creation(v adi_integr ationStatu s, vadi_in tegrationN oteId, vad i_noteDesc ription, v adi_eSigna tureCode)  {
  456       //The  Addendum w as sucessf ully creat ed in Vist a/CPRS, ad d addition al signers  if needed
  457       try {
  458           // Determine  if additio nal signer s exists
  459           if  (vadi_Add lSignersNa meArray !=  null && v adi_AddlSi gnersIenAr ray != nul l) {
  460                //Get th e current  CRM User's  assigned  site/facil ity
  461                var vadi _userSiteI d = "";
  462                var vadi _UserSiteN o = "";
  463                var vadi _duz = "";
  464                var vadi _providern ame = "";
  465  
  466                var vadi _userData  = vadi_get SingleEnti tyDataSync ('SystemUs erSet', 'f tp_Facilit ySiteId',  Xrm.Page.c ontext.get UserId());
  467                if (vadi _userData  != null) {
  468                    if ( vadi_userD ata.d.ftp_ FacilitySi teId != nu ll) {
  469                         vadi_userS iteId = va di_userDat a.d.ftp_Fa cilitySite Id.Id;
  470                    }
  471                }
  472  
  473                //Lookup  the Facil ity/Site #
  474                if (vadi _userSiteI d != null  && vadi_us erSiteId ! = '') {
  475                    var  vadi_facil ityData =  vadi_getSi ngleEntity DataSync(' ftp_facili tySet', 'f tp_facilit ycode', va di_userSit eId);
  476                    if ( vadi_facil ityData !=  null) {
  477                         if (vadi_f acilityDat a.d.ftp_fa cilitycode  != null)  { vadi_Use rSiteNo =  vadi_facil ityData.d. ftp_facili tycode; }
  478                    }
  479                }
  480  
  481                //Check  if VIA Log in cookie  exist (not  expired)
  482                var vadi _ViaLoginC ookie = va di_getCook ie("viases sionlink") ;
  483                if (vadi _ViaLoginC ookie != n ull && vad i_ViaLogin Cookie !=  '') {
  484                    var  vadi_cooki earray = v adi_ViaLog inCookie.s plit("~~~~ ", 2);
  485                    vadi _duz = vad i_cookiear ray[0];
  486                    vadi _providern ame = vadi _cookiearr ay[1];
  487                }
  488  
  489                //Create  text stri ngs from a dditional  signers ar ray
  490                var vadi _SignerIEN  = "";
  491                for (var  i = 0; i  <= vadi_Ad dlSignersI enArray.le ngth - 1;  i++) {
  492                    if ( i == 1) {  vadi_Signe rIEN = vad i_AddlSign ersIenArra y[i]; }
  493                    if ( i > 1) { v adi_Signer IEN = vadi _SignerIEN  + " " + v adi_AddlSi gnersIenAr ray[i]; }
  494                }
  495  
  496                //Create  the Addit ional Sign ers
  497                var vadi _viaSigner s = new Ob ject();
  498                vadi_via Signers.Pr oviderName  = vadi_pr ovidername ;
  499                vadi_via Signers.Du z = vadi_d uz;
  500                vadi_via Signers.Lo ginSiteCod e = vadi_U serSiteNo;
  501                vadi_via Signers.Ta rget = vad i_integrat ionNoteId;
  502                vadi_via Signers.Su pplemental Parameters  = vadi_Si gnerIEN;
  503  
  504                $.ajax({
  505                    type : "POST",
  506                    url:  vadi_AddS ignersUrl,
  507                    data : JSON.str ingify(vad i_viaSigne rs),
  508                    cont entType: " applicatio n/json; ch arset=utf- 8",
  509                    data Type: "jso n",
  510                    succ ess: funct ion (data)  {
  511                         vadi_viaSi gnersRespo nse = JSON .stringify (data.Data );
  512                         //Test for  Failure
  513                         if (vadi_v iaSignersR esponse.Er rorOccurre d == true)  {
  514                             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!");
  515                         }
  516                    },
  517                    erro r: functio n (jqXHR,  textStatus , errorThr own) {
  518                         //System E rror
  519                         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 !");
  520                    },
  521                    asyn c: false,
  522                    cach e: false
  523                });
  524  
  525                if (vadi _localStor ageVarName  != "" &&  vadi_local StorageVar Name != nu ll) {
  526                    //Cl ear existi ng session  storage v ariable.
  527                    loca lStorage.r emoveItem( vadi_local StorageVar Name);
  528                }
  529           }
  530  
  531           // **NOTE: TH E SECTION  BELOW IS T EMPORARILY  DISABLED  DUE TO THE  SIGN NOTE  SERVICE F AILING WIT H ADDENDUM S....
  532  
  533           /*
  534           // Add primar y signer's  e-signatu re
  535           if  (vadi_eSi gnatureCod e != null  && vadi_eS ignatureCo de != '')  {
  536                //****
  537                //Get th e current  CRM User's  assigned  site/facil ity
  538                var vadi _userSiteI d = "";
  539                var vadi _UserSiteN o = "";
  540                var vadi _duz = "";
  541                var vadi _providern ame = "";
  542  
  543                var vadi _userData  = vadi_get SingleEnti tyDataSync ('SystemUs erSet', 'f tp_Facilit ySiteId',  Xrm.Page.c ontext.get UserId());
  544                if (vadi _userData  != null) {
  545                    if ( vadi_userD ata.d.ftp_ FacilitySi teId != nu ll) {
  546                         vadi_userS iteId = va di_userDat a.d.ftp_Fa cilitySite Id.Id;
  547                    }
  548                }
  549  
  550                //Lookup  the Facil ity/Site #
  551                if (vadi _userSiteI d != null  && vadi_us erSiteId ! = '') {
  552                    var  vadi_facil ityData =  vadi_getSi ngleEntity DataSync(' ftp_facili tySet', 'f tp_facilit ycode', va di_userSit eId);
  553                    if ( vadi_facil ityData !=  null) {
  554                         if (vadi_f acilityDat a.d.ftp_fa cilitycode  != null)  { vadi_Use rSiteNo =  vadi_facil ityData.d. ftp_facili tycode; }
  555                    }
  556                }
  557  
  558                //Check  if VIA Log in cookie  exist (not  expired)
  559                var vadi _ViaLoginC ookie = va di_getCook ie("viases sionlink") ;
  560                if (vadi _ViaLoginC ookie != n ull && vad i_ViaLogin Cookie !=  '') {
  561                    var  vadi_cooki earray = v adi_ViaLog inCookie.s plit("~~~~ ", 2);
  562                    vadi _duz = vad i_cookiear ray[0];
  563                    vadi _providern ame = vadi _cookiearr ay[1];
  564                }
  565  
  566  
  567                //****
  568  
  569                var vadi _viaSignAd dendum = n ew Object( );
  570                vadi_via SignAddend um.Provide rName = va di_provide rname;
  571                vadi_via SignAddend um.Duz = v adi_duz;
  572                vadi_via SignAddend um.LoginSi teCode = v adi_UserSi teNo;
  573                vadi_via SignAddend um.NoteIEN  = vadi_in tegrationN oteId;
  574                vadi_via SignAddend um.ESig =  vadi_eSign atureCode;
  575  
  576                $.ajax({
  577                    type : "POST",
  578                    url:  vadi_Sign NoteUrl,
  579                    data : JSON.str ingify(vad i_viaSignA ddendum),
  580                    cont entType: " applicatio n/json; ch arset=utf- 8",
  581                    data Type: "jso n",
  582                    succ ess: funct ion (data)  {
  583                         vadi_viaSi gnAddendum Response =  JSON.stri ngify(data .Data);
  584                         //Test for  Failure
  585                         if (vadi_v iaSignAdde ndumRespon se.ErrorOc curred ==  true) {
  586                             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 !");
  587  
  588                             alert( "MORE DETA ILS: " + v adi_viaSig nAddendumR esponse.Er rorMessage );
  589  
  590                         }
  591                         else {
  592                             //Upda te esign f ields on f orm
  593  
  594                             alert( "NO ESIGN  ERROR..");
  595  
  596                         }
  597                    },
  598                    erro r: functio n (jqXHR,  textStatus , errorThr own) {
  599                         //System E rror
  600                         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!");
  601                    },
  602                    asyn c: false,
  603                    cach e: false
  604                });
  605           }
  606           */
  607  
  608           // Perform st andard for m updates  to signify  completio n
  609           // Write Succ ess entry
  610           Xr m.Page.get Attribute( 'descripti on').setVa lue(vadi_n oteDescrip tion);
  611           Xr m.Page.get Attribute( 'descripti on').setSu bmitMode(' always');
  612           Xr m.Page.get Attribute( 'ftp_integ rationstat us').setVa lue(vadi_i ntegration Status);
  613           Xr m.Page.get Attribute( 'ftp_integ rationstat us').setSu bmitMode(' always');
  614           Xr m.Page.get Attribute( 'ftp_integ rationerro r').setVal ue(null);
  615           Xr m.Page.get Attribute( 'ftp_integ rationerro r').setSub mitMode('a lways');
  616           Xr m.Page.get Attribute( 'ftp_integ rationdate ').setValu e(new Date ());
  617           Xr m.Page.get Attribute( 'ftp_integ rationdate ').setSubm itMode('al ways');
  618           Xr m.Page.get Attribute( 'ftp_adden dumnoteid' ).setValue (vadi_inte grationNot eId);
  619           Xr m.Page.get Attribute( 'ftp_adden dumnoteid' ).setSubmi tMode('alw ays');
  620           Xr m.Page.get Control('f tp_integra tionstatus ').setFocu s();
  621           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!');
  622           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  623           Xr m.Page.dat a.entity.s ave();
  624       }
  625       catch  (err) {
  626           al ert('Adden dum Ribbon  Function  Error(vadi _finalizeA ddendumCre ation): '  + err.mess age);
  627           Xr m.Page.ui. clearFormN otificatio n("SAVEVIS TA");
  628       }
  629   }
  630  
  631   function v adi_UserHa sTeam(team Name, user Guid) {
  632       try {
  633           va r vadi_tea mid = null ;
  634           va r vadi_cur rentUserId  = userGui d;
  635           va r vadi_con ditionalFi lter = "(N ame eq '"  + teamName  + "')";
  636           va r vadi_tea mData = va di_getMult ipleEntity DataSync(' TeamSet',  'TeamId',  vadi_condi tionalFilt er, 'Name' , 'asc', 0 );
  637           if  (vadi_tea mData != n ull) {
  638                for (var  i = 0; i  <= vadi_te amData.d.r esults.len gth - 1; i ++) {
  639                    //Ge t Info
  640                    if ( vadi_teamD ata.d.resu lts[i].Tea mId != nul l) { vadi_ teamid = v adi_teamDa ta.d.resul ts[i].Team Id; }
  641                    brea k;
  642                }
  643           }
  644           // If Team ex ists, chec k if the c urrent use r is part  of that te am
  645           va r vadi_tea mMembershi pId = null ;
  646           if  (vadi_tea mid != nul l && vadi_ currentUse rId != nul l) {
  647                var vadi _condition alFilter =  "(TeamId  eq (guid'"  + vadi_te amid + "')  and Syste mUserId eq  (guid'" +  vadi_curr entUserId  + "'))";
  648                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);
  649                if (vadi _teamMembe rshipData  != null) {
  650                    for  (var i = 0 ; i <= vad i_teamMemb ershipData .d.results .length -  1; i++) {
  651                         //Get Info
  652                         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; }
  653                         break;
  654                    }
  655                }
  656           }
  657           if  (vadi_tea mMembershi pId != nul l) { retur n true; }
  658  
  659           // otherwise  return fal se                 
  660           re turn false ;
  661       }
  662       catch  (err) {
  663           // Display Er ror
  664           al ert("An er ror occure d in the v adi_UserHa sTeam func tion.  Err or Detail  Message: "  + err);
  665       }
  666   }
  667  
  668   function v adi_getCoo kie(cname)  {
  669       try {
  670           va r name = c name + "=" ;
  671           va r ca = doc ument.cook ie.split(' ;');
  672           fo r (var i =  0; i < ca .length; i ++) {
  673                var c =  ca[i];
  674                while (c .charAt(0)  == ' ') {
  675                    c =  c.substrin g(1);
  676                }
  677                if (c.in dexOf(name ) == 0) {
  678                    retu rn c.subst ring(name. length, c. length);
  679                }
  680           }
  681           re turn "";
  682       }
  683       catch  (err) {
  684           al ert('Adden dum Ribbon  Function  Error(vadi _getCookie ): ' + err .message);
  685       }
  686   }
  687  
  688   function v adi_wordWr ap(str, in tWidth, st rBreak, cu t) {
  689       try {
  690           // Takes a st ring that  exceeds a  set length  and inser ts word wr ap
  691           va r m = ((ar guments.le ngth >= 2)  ? argumen ts[1] : 75 )
  692           va r b = ((ar guments.le ngth >= 3)  ? argumen ts[2] : '\ n')
  693           va r c = ((ar guments.le ngth >= 4)  ? argumen ts[3] : fa lse)
  694  
  695           va r i, j, l,  s, r
  696  
  697           st r += ''
  698  
  699           if  (m < 1) {
  700                return s tr
  701           }
  702  
  703           fo r (i = -1,  l = (r =  str.split( /\r\n|\n|\ r/)).lengt h; ++i < l ; r[i] +=  s) {
  704                for (s =  r[i], r[i ] = '';
  705                    s.le ngth > m;
  706                    r[i]  += s.slic e(0, j) +  ((s = s.sl ice(j)).le ngth ? b :  '')) {
  707                    j =  c === 2 ||  (j = s.sl ice(0, m +  1).match( /\S*(\s)?$ /))[1]
  708                         ? m
  709                         : j.input. length - j [0].length  || c ===  true && m  ||
  710                         j.input.le ngth + (j  = s.slice( m).match(/ ^\S*/))[0] .length
  711                }
  712           }
  713  
  714           re turn r.joi n('\n')
  715       }
  716       catch  (err) {
  717           al ert('Adden dum Ribbon  Function  Error(vadi _wordWrap) : ' + err. message);
  718       }
  719   }
  720  
  721  
  722   function v adi_execut eCrmOdataG etRequest( vadi_jsonQ uery, vadi _aSync, va di_aSyncCa llback, va di_skipCou nt, vadi_o ptionArray ) {
  723       //This  function  executes a  CRM Odata  web servi ce call to  retrieve  Crm data
  724       //*vad i_jsonQuer y* - a pro perly form atted CRM  Odata Quer y string ( required)
  725       //*vad i_aSync* -  specify ' true' to e xecute asy nchronousl y otherwis e 'false'  (required)
  726       //*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 '')
  727       //*vad i_skipCoun t* - Initi al setting  is always  '0', incr ements by  50 per CRM  SDK Odata  standards  (required )
  728       //*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)
  729       try {
  730           va r vadi_ent ityData =  null;
  731           $. ajax({
  732                type: 'G ET',
  733                contentT ype: 'appl ication/js on; charse t=utf-8',
  734                datatype : 'json',
  735                url: vad i_jsonQuer y,
  736                beforeSe nd: functi on (XMLHtt pRequest)  {
  737                    XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json');
  738                },
  739                success:  function  (data, tex tStatus, X mlHttpRequ est) {
  740                    vadi _entityDat a = data;
  741                    if ( vadi_aSync  == true)  {
  742                         vadi_aSync Callback(v adi_entity Data, vadi _skipCount , vadi_opt ionArray);
  743                    }
  744                },
  745                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  746                    aler t('Fail: A jax Error  in vadi_ex ecuteCrmOd ataGetRequ est: ' + e rrorThrown  + " Reque st: " + va di_jsonQue ry);
  747                },
  748                async: v adi_aSync,
  749                cache: f alse
  750           }) ;
  751           re turn vadi_ entityData ;
  752       }
  753       catch  (err) {
  754           al ert('An er ror occure d in the v adi_execut eCrmOdataG etRequest  function.   Error Det ail Messag e: ' + err );
  755       }
  756   }
  757  
  758   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) {
  759       //This  function  returns a  CRM JSON d ataset for  all entit y records  matching c riteria pr ovided Asy ncronously
  760       //*vad i_entitySe tName* - i s the name  of the en tity set e .g 'Contac tSet'
  761       //*vad i_attribut eSet* -  i s a string  containin g the Crm  Attributes  to retrie ve e.g. 'F irstName,  LastName,  Telephone1 , EMailAdd ress1'
  762       //*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
  763       //*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'
  764       //*vad i_sortDire ction* - i s a string  specifyin g the sort  as Ascend ing or Des cending e. g. 'asc' o r 'desc'
  765       //*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)
  766       //*vad i_aSyncCal lback* - i s the name  of the fu nction to  call when  returning  the result
  767       //*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
  768  
  769       try {
  770           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;
  771           va di_execute CrmOdataGe tRequest(v adi_jsonQu ery, true,  vadi_aSyn cCallback,  vadi_skip Count, vad i_optionAr ray);
  772       }
  773       catch  (err) {
  774           al ert('An er ror occure d in the v adi_getMul tipleEntit yDataAsync  function.   Error De tail Messa ge: ' + er r);
  775       }
  776   }
  777  
  778   function v adi_getSin gleEntityD ataSync(va di_entityS etName, va di_attribu teSet, vad i_entityId ) {
  779       //This  function  returns a  CRM JSON d ataset for  a single  entity rec ord based  on the ent ity id pro vided Sync ronously
  780       //*vad i_entitySe tName* - i s the name  of the en tity set e .g 'Contac tSet'
  781       //*vad i_attribut eSet* -  i s a string  containin g the Crm  Attributes  to retrie ve e.g. 'F irstName,  LastName,  Telephone1 , EMailAdd ress1'
  782       //*vad i_entityId * - is the  Guid for  the entity  record
  783  
  784       try {
  785           va r vadi_ent ityIdNoBra cket = vad i_entityId .replace(/ ({|})/g, ' ');
  786           va r vadi_sel ectString  = '(guid'  + "'" + va di_entityI dNoBracket  + "'" + ' )?$select= ' + vadi_a ttributeSe t;
  787           va r vadi_jso nQuery = v adi_server Url + vadi _crmOdataE ndPoint +  '/' + vadi _entitySet Name + vad i_selectSt ring;
  788           va r vadi_ent ityData =  vadi_execu teCrmOdata GetRequest (vadi_json Query, fal se, '', 0,  null);
  789           re turn vadi_ entityData ;
  790       }
  791       catch  (err) {
  792           al ert('An er ror occure d in the v adi_getSin gleEntityD ataSync fu nction.  E rror Detai l Message:  ' + err);
  793       }
  794   }
  795  
  796   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) {
  797       //This  function  returns a  CRM JSON d ataset for  all entit y records  matching c riteria pr ovided Syn cronously
  798       //*vad i_entitySe tName* - i s the name  of the en tity set e .g 'Contac tSet'
  799       //*vad i_attribut eSet* -  i s a string  containin g the Crm  Attributes  to retrie ve e.g. 'F irstName,  LastName,  Telephone1 , EMailAdd ress1'
  800       //*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
  801       //*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'
  802       //*vad i_sortDire ction* - i s a string  specifyin g the sort  as Ascend ing or Des cending e. g. 'asc' o r 'desc'
  803       //*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)
  804  
  805       try {
  806           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;
  807           va r vadi_ent ityData =  vadi_execu teCrmOdata GetRequest (vadi_json Query, fal se, '', va di_skipCou nt, null);
  808           re turn vadi_ entityData ;
  809       }
  810       catch  (err) {
  811           al ert('An er ror occure d in the v adi_getMul tipleEntit yDataSync  function.   Error Det ail Messag e: ' + err );
  812       }
  813   }