376. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/22/2018 1:29:26 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

376.1 Files compared

# Location File Last Modified
1 v1603_release_60.zip\CRM_solutions\VCCMResources.zip\WebResources ftp_ProgressNoteSignerSearchjsProgressNoteSignerSe15D67D37-6253-E611-943F-0050568D743D Tue May 22 14:39:24 2018 UTC
2 v1603_release_60.zip\CRM_solutions\VCCMResources.zip\WebResources ftp_ProgressNoteSignerSearchjsProgressNoteSignerSe15D67D37-6253-E611-943F-0050568D743D Wed Jun 20 16:38:26 2018 UTC

376.2 Comparison summary

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

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

376.4 Active regular expressions

No regular expressions were active.

376.5 Comparison detail

  1   /// <refer ence path= '../../tri ipcrm_/TR_ KU_V2015_2 _902/js/jq uery.min.j s' />
  2   /// <refer ence path= '../../tri ipcrm_/TR_ KU_V2015_2 _902/js/ke ndo.all.mi n.js' />
  3  
  4   //Progress NoteSigner SearchScri ptLib.js
  5   //Contains  variables  and funct ions used  by the Pro gressNoteS ignerSearc h.html pag e
  6  
  7   //Static V ariables
  8   var pnss_c rmOdataEnd Point = '/ XRMService s/2011/Org anizationD ata.svc';
  9   var pnss_c ontext = G etGlobalCo ntext();
  10   var pnss_s erverUrl =  pnss_cont ext.getCli entUrl();
  11  
  12   var pnss_o rgName = p nss_contex t.getOrgUn iqueName() ;
  13   var pnss_u serId = pn ss_context .getUserId ();
  14   var pnss_u serSiteId  = '';
  15   var pnss_U serSiteNo  = '';
  16   var pnss_d uz = '';
  17   var pnss_p rovidernam e = '';
  18   var pnss_b aseService EndpointUr l = null;
  19   var pnss_r equestingA pp = null;
  20   var pnss_c onsumingAp pToken = n ull;
  21   var pnss_c onsumingAp pPassword  = null;
  22  
  23   var pnss_i ncidentEnt ity = fals e;
  24   var pnss_s ignerPrefi x = "PN";
  25  
  26   //var pnss _VistaUser sURLbase =  'https:// URL /WebParts/ DEV/api/Vi staUsers/1 .0/json/ft pCRM/john/ smith/1234 ?noFilter= true';    //OLD MANU AL DEV URL
  27   var pnss_V istaUsersU RLbase = ' ';
  28  
  29   function p nss_Settin gsWebServi ceURL_resp onse(pnss_ settingDat a, pnss_la stSkip, pn ss_Blank_N A) {
  30       try {
  31           // pnss_lastS kip is the  starting  point in t he result  (use if mo re than 50  records)  //Not used  in this s cenario
  32           va r pnss_Dac Url = null ;
  33           va r pnss_Vis taUserApiU rl = null;
  34  
  35           fo r (var i =  0; i <= p nss_settin gData.d.re sults.leng th - 1; i+ +) {
  36                //Get in fo
  37                if (pnss _settingDa ta.d.resul ts[i].ftp_ DACURL !=  null) { pn ss_DacUrl  = pnss_set tingData.d .results[i ].ftp_DACU RL; }
  38                if (pnss _settingDa ta.d.resul ts[i].ftp_ VistaUsers APIURL !=  null) { pn ss_VistaUs erApiUrl =  pnss_sett ingData.d. results[i] .ftp_Vista UsersAPIUR L; }
  39                if (pnss _settingDa ta.d.resul ts[i].ftp_ VIAService BaseURL !=  null) { p nss_baseSe rviceEndpo intUrl = p nss_settin gData.d.re sults[i].f tp_VIAServ iceBaseURL ; }
  40                if (pnss _settingDa ta.d.resul ts[i].ftp_ VIARequest ingApplica tionCode ! = null) {  pnss_reque stingApp =  pnss_sett ingData.d. results[i] .ftp_VIARe questingAp plicationC ode; }
  41                if (pnss _settingDa ta.d.resul ts[i].ftp_ VIAConsumi ngApplicat ionToken ! = null) {  pnss_consu mingAppTok en = pnss_ settingDat a.d.result s[i].ftp_V IAConsumin gApplicati onToken; }
  42                if (pnss _settingDa ta.d.resul ts[i].ftp_ VIAConsumi ngApplicat ionPasswor d != null)  { pnss_co nsumingApp Password =  pnss_sett ingData.d. results[i] .ftp_VIACo nsumingApp licationPa ssword; }
  43                break;
  44           }
  45           if  (pnss_Dac Url != nul l && pnss_ VistaUserA piUrl != n ull) {
  46                //Constr uct full w eb service  URL
  47                pnss_Vis taUsersURL base = pns s_DacUrl +  pnss_Vist aUserApiUr l;
  48           }
  49           el se {
  50                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 ");
  51           }
  52  
  53           if  (pnss_bas eServiceEn dpointUrl  == null ||  pnss_requ estingApp  == null ||  pnss_cons umingAppTo ken == nul l || pnss_ consumingA ppPassword  == null)  {
  54                parent.X rm.Page.ui .setFormNo tification ("ERROR: T HE 'VIA Se rvice Conn ector' CON FIGURATION  IS MISSIN G DATA IN  THE 'Setti ngs Entity ', PLEASE  CONTACT TE CHNICAL SU PPORT!", " ERROR", "V ISTASERVIC E");
  55           }
  56           // Decrypt VI A Service  Connector  Items
  57           pn ss_request ingApp = p nss_decryp tServiceCo nnector(pn ss_request ingApp, 4) ;
  58           pn ss_consumi ngAppToken  = pnss_de cryptServi ceConnecto r(pnss_con sumingAppT oken, 6);
  59           pn ss_consumi ngAppPassw ord = pnss _decryptSe rviceConne ctor(pnss_ consumingA ppPassword , 8);
  60       }
  61       catch  (err) {
  62           al ert('Progr ess Note S igner Sear ch Web Res ource Func tion Error (pnss_Sett ingsWebSer viceURL_re sponse): '  + err.mes sage);
  63       }
  64   }
  65  
  66   function p nss_decryp tServiceCo nnector(pn ss_connect orArray, p nss_connec torValue)  {
  67       var pn ss_decrypt edString =  "";
  68       if (pn ss_connect orArray !=  null && p nss_connec torArray ! = "") {
  69           va r pnss_new Array = pn ss_connect orArray.to String().s plit(',');
  70           pn ss_newArra y.reverse( );
  71           fo r (i = 0;  i < pnss_n ewArray.le ngth; i++)  {
  72                var pnss _curChar =  "";
  73                if (i ==  0) {
  74                    pnss _curChar =  pnss_newA rray[i] -  pnss_conne ctorValue;
  75                }
  76                else {
  77                    pnss _curChar =  pnss_newA rray[i] -  (i + pnss_ connectorV alue);
  78                }
  79                pnss_dec ryptedStri ng = pnss_ decryptedS tring + St ring.fromC harCode(pn ss_curChar );
  80           }
  81       }
  82       return  pnss_decr yptedStrin g;
  83   }
  84  
  85   function p nss_formLo ad() {
  86       try {
  87           // Check if p arent enti ty is of t ype 'incid ent'
  88           if  (parent.X rm.Page.da ta.entity. getEntityN ame() == ' incident')  {
  89                pnss_inc identEntit y = true;
  90                pnss_sig nerPrefix  = "RN"
  91           }
  92  
  93           // Proceed to  grid data  load....
  94           pn ss_createL ookupContr ol();
  95           pn ss_createS electedCon trol();
  96  
  97           // Set focus  to cancel  button if  Tab_Additi onalSigner s is Visib le
  98           if  (pnss_inc identEntit y == false ) {
  99                if (pare nt.Xrm.Pag e.ui.tabs. get('Tab_A dditionalS igners').g etVisible( ) == true)  {
  100                    docu ment.getEl ementById( 'btnCancel ').focus() ;
  101                }
  102           }
  103  
  104           // Check if V IA Login c ookie exis t (not exp ired)
  105           va r pnss_Via LoginCooki e = pnss_g etCookie(" viasession link");
  106  
  107           if  (pnss_Via LoginCooki e != null  && pnss_Vi aLoginCook ie != '')  {
  108                var pnss _cookiearr ay = pnss_ ViaLoginCo okie.split ("~~~~", 2 );
  109                pnss_duz  = pnss_co okiearray[ 0];
  110                pnss_pro vidername  = pnss_coo kiearray[1 ];
  111           }
  112  
  113           // Check Cook ie return  values if  missing ex it
  114           if  (pnss_duz  == '' ||  pnss_provi dername ==  '') { ret urn false;  }
  115  
  116           // GET CRM SE TTINGS WEB  SERVICE U RLS
  117           va r pnss_con ditionalFi lter = "(m cs_name eq  'Active S ettings')" ;
  118           pn ss_getMult ipleEntity DataAsync( 'mcs_setti ngSet', 'f tp_VIAServ iceBaseURL , ftp_VIAR equestingA pplication Code, ftp_ VIAConsumi ngApplicat ionToken,  ftp_VIACon sumingAppl icationPas sword, ftp _DACURL, f tp_VistaUs ersAPIURL' , pnss_con ditionalFi lter, 'mcs _name', 'a sc', 0, pn ss_Setting sWebServic eURL_respo nse, '');
  119  
  120           // Get the cu rrent CRM  User's ass igned site /facility
  121           va r pnss_use rData = pn ss_getSing leEntityDa taSync('Sy stemUserSe t', 'ftp_F acilitySit eId', pnss _userId);
  122           if  (pnss_use rData != n ull) {
  123                if (pnss _userData. d.ftp_Faci litySiteId  != null)  {
  124                    pnss _userSiteI d = pnss_u serData.d. ftp_Facili tySiteId.I d;
  125                }
  126           }
  127  
  128           // Lookup the  Facility/ Site #
  129           if  (pnss_use rSiteId !=  null && p nss_userSi teId != '' ) {
  130                var pnss _facilityD ata = pnss _getSingle EntityData Sync('ftp_ facilitySe t', 'ftp_f acilitycod e', pnss_u serSiteId) ;
  131                if (pnss _facilityD ata != nul l) {
  132                    if ( pnss_facil ityData.d. ftp_facili tycode !=  null) { pn ss_UserSit eNo = pnss _facilityD ata.d.ftp_ facilityco de; }
  133                }
  134           }
  135       }
  136       catch  (err) {
  137           al ert('Progr ess Note S igner Sear ch Web Res ource Func tion Error (pnss_form Load): ' +  err.messa ge);
  138       }
  139   }
  140  
  141   function p nss_select AddGridRow (arg) {
  142       try {
  143           va r pnss_sel ectedRows  = this.sel ect();
  144           va r pnss_sel ectedDataI tems = [];
  145           va r pnss_rec ordID = nu ll;
  146           va r pnss_rec ordType =  null;
  147           va r pnss_rec ordIconURL  = null;
  148           va r pnss_rec ordName =  null;
  149           va r pnss_rec ordIEN = n ull;
  150           fo r (var i =  0; i < pn ss_selecte dRows.leng th; i++) {
  151                pnss_gri dDataItem  = this.dat aItem(pnss _selectedR ows[i]);
  152                pnss_rec ordID = pn ss_gridDat aItem.ID
  153                pnss_rec ordType =  pnss_gridD ataItem.Ty pe;
  154                pnss_rec ordIconURL  = pnss_gr idDataItem .IconURL;
  155                pnss_rec ordName =  pnss_gridD ataItem.Na me;
  156                pnss_rec ordIEN = p nss_gridDa taItem.IEN ;
  157           }
  158  
  159           va r pnss_ent itySearchG rid = $('# ku_lookupg rid').data ('kendoGri d');
  160           va r pnss_ent itySelecte dGrid = $( '#ku_selec tedgrid'). data('kend oGrid');
  161  
  162           if  (pnss_rec ordID != n ull) {
  163                //Add to  selected  grid
  164                //Determ ine if it  already ex ist, if so  cancel ad d...
  165                if (pnss _entitySel ectedGrid. dataSource .get(pnss_ recordID)  == null) {
  166                    pnss _entitySel ectedGrid. dataSource .pushCreat e({
  167                         ID: pnss_r ecordID,
  168                         Type: pnss _recordTyp e,
  169                         IconURL: p nss_record IconURL,
  170                         Name: pnss _recordNam e,
  171                         IEN: pnss_ recordIEN
  172                    });
  173                }
  174                //Remove  row from  lookup gri d
  175                pnss_ent itySearchG rid.dataSo urce.remov e(pnss_gri dDataItem) ;
  176           }
  177       }
  178       catch  (err) {
  179           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_selectA ddGridRow) : ' + err. message);
  180       }
  181   }
  182  
  183   function p nss_select RemoveGrid Row(arg) {
  184       try {
  185           // Disable se lect if di sabled
  186           if  (document .getElemen tById('btn Select').d isabled ==  true) { r eturn fals e; }
  187  
  188           va r pnss_sel ectedRows  = this.sel ect();
  189           va r pnss_sel ectedDataI tems = [];
  190           va r pnss_rec ordID = nu ll;
  191           va r pnss_rec ordType =  null;
  192           va r pnss_rec ordIconURL  = null;
  193           va r pnss_rec ordName =  null;
  194           fo r (var i =  0; i < pn ss_selecte dRows.leng th; i++) {
  195                pnss_gri dDataItem  = this.dat aItem(pnss _selectedR ows[i]);
  196                pnss_rec ordID = pn ss_gridDat aItem.ID
  197                pnss_rec ordType =  pnss_gridD ataItem.Ty pe;
  198                pnss_rec ordIconURL  = pnss_gr idDataItem .IconURL;
  199                pnss_rec ordName =  pnss_gridD ataItem.Na me;
  200           }
  201  
  202           va r pnss_ent itySearchG rid = $('# ku_lookupg rid').data ('kendoGri d');
  203           va r pnss_ent itySelecte dGrid = $( '#ku_selec tedgrid'). data('kend oGrid');
  204  
  205           if  (pnss_rec ordID != n ull) {
  206                //Remove  row from  selected g rid
  207                pnss_ent itySelecte dGrid.data Source.rem ove(pnss_g ridDataIte m);
  208           }
  209       }
  210       catch  (err) {
  211           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_selectR emoveGridR ow): ' + e rr.message );
  212       }
  213   }
  214  
  215   function p nss_clickA ddGridRow( e) {
  216       try {
  217           va r pnss_gri dDataItem  = this.dat aItem($(e. currentTar get).close st('tr'));
  218           va r pnss_rec ordID = pn ss_gridDat aItem.ID;
  219           va r pnss_rec ordType =  pnss_gridD ataItem.Ty pe;
  220           va r pnss_rec ordIconURL  = pnss_gr idDataItem .IconURL;
  221           va r pnss_rec ordName =  pnss_gridD ataItem.Na me;
  222           va r pnss_rec ordIEN = p nss_gridDa taItem.IEN ;
  223  
  224           va r pnss_ent itySearchG rid = $('# ku_lookupg rid').data ('kendoGri d');
  225           va r pnss_ent itySelecte dGrid = $( '#ku_selec tedgrid'). data('kend oGrid');
  226  
  227           if  (pnss_rec ordID != n ull) {
  228                //Add to  selected  grid
  229                //Determ ine if it  already ex ist, if so  cancel ad d...
  230                if (pnss _entitySel ectedGrid. dataSource .get(pnss_ recordID)  == null) {
  231                    pnss _entitySel ectedGrid. dataSource .pushCreat e({
  232                         ID: pnss_r ecordID,
  233                         Type: pnss _recordTyp e,
  234                         IconURL: p nss_record IconURL,
  235                         Name: pnss _recordNam e,
  236                         IEN: pnss_ recordIEN
  237                    });
  238                }
  239                //Remove  row from  lookup gri d
  240                pnss_ent itySearchG rid.dataSo urce.remov e(pnss_gri dDataItem) ;
  241           }
  242       }
  243       catch  (err) {
  244           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_clickAd dGridRow):  ' + err.m essage);
  245       }
  246   }
  247  
  248   function p nss_clickR emoveGridR ow(e) {
  249       try {
  250           // Disable se lect if di sabled
  251           if  (document .getElemen tById('btn Select').d isabled ==  true) { r eturn fals e; }
  252  
  253           va r pnss_gri dDataItem  = this.dat aItem($(e. currentTar get).close st('tr'));
  254           va r pnss_rec ordID = pn ss_gridDat aItem.ID;
  255           va r pnss_rec ordType =  pnss_gridD ataItem.Ty pe;
  256           va r pnss_rec ordIconURL  = pnss_gr idDataItem .IconURL;
  257           va r pnss_rec ordName =  pnss_gridD ataItem.Na me;
  258  
  259           va r pnss_ent itySearchG rid = $('# ku_lookupg rid').data ('kendoGri d');
  260           va r pnss_ent itySelecte dGrid = $( '#ku_selec tedgrid'). data('kend oGrid');
  261  
  262           if  (pnss_rec ordID != n ull) {
  263                //Remove  row from  selected g rid
  264                pnss_ent itySelecte dGrid.data Source.rem ove(pnss_g ridDataIte m);
  265           }
  266       }
  267       catch  (err) {
  268           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_clickRe moveGridRo w): ' + er r.message) ;
  269       }
  270   }
  271  
  272   function p nss_create LookupCont rol() {
  273       try {
  274           va r pnss_add ButtonText  = " Add " ;
  275           $( '#ku_looku pgrid').ke ndoGrid({
  276                columns:  [
  277                    { fi eld: 'ID',  type: 'st ring', hid den: true  },
  278                    { fi eld: 'Type ', type: ' string', h idden: tru e },
  279                    { fi eld: 'Icon URL', type : 'string' , hidden:  true },
  280                    {
  281                         template:  "<div clas s='entity- icon'" +
  282                               "sty le='backgr ound-image : url(#:da ta.IconURL #);' title ='#: Type  # - #: Nam e #'></div >" +
  283                               "<di v title='# : Type # -  #: Name # ' class='e ntity-labe l'>#: Name  #</div>",
  284                         field: 'Na me', title : 'Name',  type: 'str ing'
  285                    },
  286                    { fi eld: 'IEN' , type: 's tring', hi dden: true  },
  287                    { co mmand: { t ext: pnss_ addButtonT ext, click : pnss_cli ckAddGridR ow }, titl e: ' ', wi dth: '110p x' }
  288                ],
  289                dataSour ce: {
  290                    sche ma: {
  291                         model: {
  292                             id: 'I D'
  293                         }
  294                    }
  295                },
  296                groupabl e: false,
  297                sortable : false,
  298                editable : false,
  299                height:  300,
  300                resizabl e: true,
  301                navigata ble: true,
  302                selectab le: "row",
  303                noRecord s: true,
  304                change:  pnss_selec tAddGridRo w
  305           }) ;
  306       }
  307       catch  (err) {
  308           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_createL ookupContr ol) Error  Detail: '  + err.mess age);
  309           re turn null;
  310       }
  311   }
  312  
  313   function p nss_create SelectedCo ntrol() {
  314       try {
  315           va r pnss_rem oveButtonT ext = " Re move ";
  316           $( '#ku_selec tedgrid'). kendoGrid( {
  317                columns:  [
  318                    { fi eld: 'ID',  type: 'st ring', hid den: true  },
  319                    { fi eld: 'Type ', type: ' string', h idden: tru e },
  320                    { fi eld: 'Icon URL', type : 'string' , hidden:  true },
  321                    {
  322                         template:  "<div clas s='entity- icon'" +
  323                               "sty le='backgr ound-image : url(#:da ta.IconURL #);' title ='#: Type  # - #: Nam e #'></div >" +
  324                               "<di v title='# : Type # -  #: Name # ' class='e ntity-labe l'>#: Name  #</div>",
  325                         field: 'Na me', title : 'Name',  type: 'str ing'
  326                    },
  327                    { fi eld: 'IEN' , type: 's tring', hi dden: true  },
  328                    { co mmand: { t ext: pnss_ removeButt onText, cl ick: pnss_ clickRemov eGridRow } , title: '  ', width:  '110px' }
  329                ],
  330                dataSour ce: {
  331                    sche ma: {
  332                         model: {
  333                             id: 'I D'
  334                         }
  335                    }
  336                },
  337                groupabl e: false,
  338                sortable : false,
  339                editable : false,
  340                height:  300,
  341                resizabl e: true,
  342                navigata ble: true,
  343                selectab le: "row",
  344                noRecord s: true,
  345                change:  pnss_selec tRemoveGri dRow
  346           }) ;
  347  
  348           // Initalize  the select ed control  with valu es from CR M if they  exist
  349           va r pnss_sel ectedSigne rs = paren t.Xrm.Page .getAttrib ute('ftp_s electedsig ners').get Value();
  350           if  (pnss_sel ectedSigne rs != null  && pnss_s electedSig ners != '' ) {
  351                pnss_pop ulateSelec tedGrid(pn ss_selecte dSigners);
  352           }
  353       }
  354       catch  (err) {
  355           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_createS electedCon trol) Erro r Detail:  ' + err.me ssage);
  356           re turn null;
  357       }
  358   }
  359  
  360   function p nss_popula teSelected Grid(pnss_ selectedSi gners) {
  361       try {
  362           va r pnss_sel ectedArray  = pnss_se lectedSign ers.split( '~~~');
  363           va r pnss_sel ectedArray RecordCoun t = pnss_s electedArr ay.length;
  364           va r pnss_ent itySelecte dGrid = $( '#ku_selec tedgrid'). data('kend oGrid');
  365  
  366           va r pnss_sel ectedIENAr ray = '';
  367           va r pnss_sel ectedIENAr rayRecordC ount = 0;
  368           va r pnss_pro gressNoteI d = parent .Xrm.Page. data.entit y.getId();
  369  
  370           va r pnss_arr ayMismatch  = false;
  371  
  372           // Determine  if NEW or  INT status  of array.  (NEW - no t processe d, INT - I NT is inte grated not e)
  373           if  (pnss_sel ectedArray [0] == 'IN T') {
  374                //Disabl e controls  when not  NEW
  375                document .getElemen tById('sea rchtext'). disabled =  true;
  376                document .getElemen tById('sea rchbuttoni d').disabl ed = true;
  377                document .getElemen tById('btn Select').d isabled =  true;
  378                //Change  title of  the cancel  button
  379                document .getElemen tById('btn Cancel').v alue = 'Cl ose Search ';
  380                document .getElemen tById('btn Cancel').t itle = 'Cl ick here t o close th e search f orm.';
  381                //Hide t he grid's  remove but ton column
  382                pnss_ent itySelecte dGrid.hide Column(4);
  383           }
  384  
  385           // Get Note's  Browser L ocal Stora ge Values
  386           if  (pnss_pro gressNoteI d != null  && pnss_pr ogressNote Id != '')  {
  387                var pnss _localStor ageVarName  = pnss_si gnerPrefix  + pnss_pr ogressNote Id;
  388                var pnss _localStor ageStringV alue = loc alStorage. getItem(pn ss_localSt orageVarNa me);
  389                if (pnss _localStor ageStringV alue != nu ll && pnss _localStor ageStringV alue != '' ) {
  390                    //al ert("local  storage v alue: " +  pnss_local StorageStr ingValue);
  391                    pnss _selectedI ENArray =  pnss_local StorageStr ingValue.s plit('~~~' );
  392                    pnss _selectedI ENArrayRec ordCount =  pnss_sele ctedIENArr ay.length;
  393                    //al ert("Local StorageArr ayLength:  " + pnss_s electedIEN ArrayRecor dCount);
  394                }
  395           }
  396  
  397           // Compare CR M signer a rray lengt h with Loc alStorage  array leng th
  398           if  (pnss_sel ectedArray RecordCoun t != pnss_ selectedIE NArrayReco rdCount) {  pnss_arra yMismatch  = true; }
  399  
  400           // *****TESTI NG****
  401           if  (pnss_arr ayMismatch  == true)  {
  402                //alert( "TEST MESS AGE: IEN/C RM, select ed signers  mismatch" );
  403           }
  404           el se {
  405                //alert( "TEST MESS AGE: IEN/C RM, select ed signers  MATCH!");
  406           }
  407           // ********** ******
  408  
  409  
  410           // Add previo usly selec ted users
  411           fo r (var i =  1; i < pn ss_selecte dArrayReco rdCount; i ++) {
  412                //***SPL IT ID & NA ME***
  413                var pnss _recordIdN ame = (pns s_selected Array[i]). split('___ ');
  414                //var pn ss_recordI D = (pnss_ selectedAr ray[i]).su bstring(4) ;
  415                var pnss _recordID  = (pnss_re cordIdName [0]).subst ring(4);
  416                //var pn ss_recordT ype = (pns s_selected Array[i]). substring( 0, 4);
  417                var pnss _recordTyp e = (pnss_ recordIdNa me[0]).sub string(0,  4);
  418  
  419                var pnss _recordNam e = pnss_r ecordIdNam e[1];
  420                //alert( pnss_recor dName);
  421  
  422                if (pnss _arrayMism atch != tr ue) {
  423                    var  pnss_recor dIEN = pns s_selected IENArray[i ];
  424                }
  425                else {
  426                    var  pnss_recor dIEN = '0' ;
  427                }
  428  
  429                var pnss _recordIco nURL = '';
  430                if (pnss _recordTyp e == 'USER ') { pnss_ recordIcon URL = 'img /ico_user. gif'; }
  431                //Insert  in select ed grid
  432                pnss_ent itySelecte dGrid.data Source.pus hCreate({
  433                    ID:  pnss_recor dIEN,
  434                    Type : pnss_rec ordType,
  435                    Icon URL: pnss_ recordIcon URL,
  436                    Name : pnss_rec ordName,
  437                    IEN:  pnss_reco rdIEN
  438                });
  439           }
  440  
  441       }
  442       catch  (err) {
  443           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_populat eSelectedG rid) Error  Detail: '  + err.mes sage);
  444           re turn null;
  445       }
  446   }
  447  
  448   function p nss_search LookupEnti ty() {
  449       try {
  450           // Populate S ystemUser  Lookup Gri d
  451           va r pnss_ent itySearchG rid = $('# ku_lookupg rid').data ('kendoGri d');
  452           pn ss_getViaU sersData(p nss_entity SearchGrid );
  453       }
  454       catch  (err) {
  455           // Display Er ror
  456           al ert('Progr ess Note S igner Sear ch Script  Failure Fu nction(pns s_searchLo okupEntity ) Error De tail: ' +  err);
  457       }
  458   }
  459  
  460   function p nss_getVia UsersData( pnss_cprsU serGridCon trol) {
  461       try {
  462           va r pnss_sea rchString  = document .getElemen tById('sea rchtext'). value;
  463           // Clear exis ting grid
  464           pn ss_cprsUse rGridContr ol.dataSou rce.data([ ]);
  465           // Make sure  there is a  text valu e
  466           if  (pnss_sea rchString  == null ||  pnss_sear chString = = '') { re turn false ; }
  467           // Verify the  user is l ogged in t o VIA
  468           if  (pnss_duz  == '' ||  pnss_provi dername ==  '') {
  469                alert("P lease logi n to VistA , before y ou begin a  search!")
  470                return f alse;
  471           }
  472           // Execute cp rsUserLook up Service
  473           vi alib_cprsU serLookup( pnss_reque stingApp,  pnss_consu mingAppTok en, pnss_c onsumingAp pPassword,  pnss_base ServiceEnd pointUrl,  pnss_provi dername, p nss_duz, p nss_UserSi teNo, pnss _searchStr ing, pnss_ getViaUser sData_resp onse, pnss _cprsUserG ridControl );
  474       }
  475       catch  (err) {
  476           // Display Er ror
  477           al ert('Progr ess Note S igner Sear ch Script  Failure Fu nction(pns s_getViaUs ersData) E rror Detai l: ' + err );
  478       }
  479   }
  480  
  481   function p nss_getVia UsersData_ response(p nss_error,  pnss_cprs userlookup response,  pnss_exter nalObject)  {
  482       try {
  483           // Check for  non VIA se rvice erro r
  484           if  (pnss_err or != null ) {
  485                alert("T he VIA cpr sUserLooku p service  failed wit h error: "  + pnss_cp rsuserlook upresponse );
  486                return f alse;
  487           }
  488           // Test for V IA Service  Error
  489           if  (pnss_cpr suserlooku presponse. getElement sByTagName ("fault"). length > 0 ) {
  490                alert("V IA cprsUse rLookup Se rvice Erro r: " + pns s_cprsuser lookupresp onse.getEl ementsByTa gName("fau lt")[0].te xtContent) ;
  491                return f alse;
  492           }
  493           // Get VIA se rvice Resp onse
  494           if  (pnss_cpr suserlooku presponse. getElement sByTagName ("users")[ 0].childNo des.length  > 0) {
  495                var pnss _userlooku pArray = p nss_cprsus erlookupre sponse.get ElementsBy TagName("u sers")[0]. childNodes ;
  496                //Add us ers in res ult to gri d
  497                for (var  i = 0; i  <= pnss_us erlookupAr ray.length  - 1; i++)  {
  498                    //ch ildNodes[0 ] holds th e name, ch ildnodes[1 ] holds th e IEN, chi ldNodes[2]  holds the  title
  499                    var  pnss_ViaIE N = '';
  500                    var  pnss_ViaFu llName = ' ';
  501                    var  pnss_ViaTi tle = '';
  502                    if ( pnss_userl ookupArray [i].childN odes[1]) {  pnss_ViaI EN = pnss_ userlookup Array[i].c hildNodes[ 1].textCon tent; }
  503                    if ( pnss_userl ookupArray [i].childN odes[0]) {  pnss_ViaF ullName =  pnss_userl ookupArray [i].childN odes[0].te xtContent;  }
  504                    if ( pnss_userl ookupArray [i].childN odes[2]) {  pnss_ViaT itle = pns s_userlook upArray[i] .childNode s[2].textC ontent; }
  505                    if ( pnss_ViaIE N != '' &&  pnss_ViaF ullName !=  '') {
  506                         //Add to t he Grid
  507                         if (pnss_V iaTitle !=  '') { pns s_ViaFullN ame = pnss _ViaFullNa me + " " +  pnss_ViaT itle; }
  508                         pnss_exter nalObject. dataSource .pushCreat e({
  509                             ID: pn ss_ViaIEN,
  510                             Type:  'USER',
  511                             IconUR L: 'img/ic o_user.gif ',
  512                             Name:  pnss_ViaFu llName,
  513                             IEN: p nss_ViaIEN
  514                         });
  515                    }
  516                }
  517                return f alse;
  518           }
  519           el se {
  520                alert("* *No Via Us er Data Re turned**") ;
  521                return f alse;
  522           }
  523       }
  524       catch  (err) {
  525           // Display Er ror
  526           al ert('Progr ess Note S igner Sear ch Script  Failure Fu nction(pns s_getViaUs ersData_re sponse) Er ror Detail : ' + err) ;
  527       }
  528   }
  529  
  530   function p nss_search KeyPress(e vent) {
  531       try {
  532           // Determine  if 'enter'  key was p ressed if  so initiat e search
  533           va r pnss_key pressed =  event.whic h || event .keyCode;
  534           if  (pnss_key pressed ==  13) { pns s_searchLo okupEntity (); }
  535       }
  536       catch  (err) {
  537           // Display Er ror
  538           al ert('Progr ess Note S igner Sear ch Script  Failure Fu nction(pns s_searchKe yPress) Er ror Detail : ' + err) ;
  539       }
  540   }
  541  
  542   function p nss_applyP rogressNot eSigners()  {
  543       try {
  544           // Write the  selected u ser string ...
  545           va r pnss_sel ectedSigne rs = '';
  546           va r pnss_sel ectedIEN =  '';
  547           va r pnss_ent itySelecte dGrid = $( '#ku_selec tedgrid'). data('kend oGrid');
  548           // Determine  if records  have been  selected
  549           va r pnss_tot alSelected Records =  pnss_entit ySelectedG rid.dataSo urce.total ();
  550           if  (pnss_tot alSelected Records >  0) {
  551                //Add ea ch record  to the sel ected reco rd string  to be stor ed in CRM  (NEW indic ates that  it is an u nprocessed  array)
  552                pnss_sel ectedSigne rs = 'NEW' ;
  553                pnss_sel ectedIEN =  'NEW';
  554                var pnss _gridData  = pnss_ent itySelecte dGrid.data Source.dat a();
  555                var pnss _totalNumG ridRows =  pnss_gridD ata.length ;
  556  
  557                for (var  i = 0; i  < pnss_tot alNumGridR ows; i++)  {
  558                    var  pnss_curre ntGridData Row = pnss _gridData[ i];
  559                    var  pnss_gridR owID = (10 00 + i).to String();
  560                    pnss _selectedS igners = p nss_select edSigners  + '~~~' +  pnss_curre ntGridData Row.Type +  pnss_grid RowID + '_ __' + pnss _currentGr idDataRow. Name;
  561                    pnss _selectedI EN = pnss_ selectedIE N + '~~~'  + pnss_cur rentGridDa taRow.IEN;
  562                }
  563           }
  564  
  565           // Write to C RM field
  566           pa rent.Xrm.P age.getAtt ribute('ft p_selected signers'). setValue(p nss_select edSigners) ;
  567           // Enforce sa ve of valu es in read  only fiel d
  568           pa rent.Xrm.P age.getAtt ribute('ft p_selected signers'). setSubmitM ode('alway s');
  569  
  570           // Write to B rowser Loc alStorage
  571           va r pnss_pro gressNoteI d = parent .Xrm.Page. data.entit y.getId();
  572           if  (pnss_pro gressNoteI d != null)  {
  573                var pnss _localStor ageVarName  = pnss_si gnerPrefix  + pnss_pr ogressNote Id;
  574                if (pnss _selectedS igners !=  '') {
  575                    loca lStorage.s etItem(pns s_localSto rageVarNam e, pnss_se lectedIEN) ;
  576                }
  577                else {
  578                    //If  Selected  Signers is  blank, th en remove  LocalStora ge values
  579                    loca lStorage.r emoveItem( pnss_local StorageVar Name);
  580                }
  581           }
  582  
  583           if  (pnss_inc identEntit y == false ) {
  584                //Set fo cus to the  main top  tab and hi de current  tab
  585                parent.X rm.Page.ui .tabs.get( 'Tab_Gener al').setFo cus();
  586                parent.X rm.Page.ui .tabs.get( 'Tab_Addit ionalSigne rs').setVi sible(fals e);
  587  
  588                //Save t he current  CRM data
  589                parent.X rm.Page.da ta.entity. save();
  590           }
  591           el se {
  592                parent.v cmn_collap seSignerSe lection();
  593           }
  594       }
  595       catch  (err) {
  596           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_applyPr ogressNote Signers) E rror Detai l: ' + err .message);
  597           re turn null;
  598       }
  599   }
  600  
  601   function p nss_cancel ProgressNo teSigners( ) {
  602       try {
  603           if  (pnss_inc identEntit y == false ) {
  604                //Set fo cus to the  main top  tab and hi de current  tab
  605                parent.X rm.Page.ui .tabs.get( 'Tab_Gener al').setFo cus();
  606                parent.X rm.Page.ui .tabs.get( 'Tab_Addit ionalSigne rs').setVi sible(fals e);
  607           }
  608           el se {
  609                parent.v cmn_collap seSignerSe lection();
  610           }
  611       }
  612       catch  (err) {
  613           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction(pn ss_cancelP rogressNot eSigners)  Error Deta il: ' + er r.message) ;
  614           re turn null;
  615       }
  616   }
  617  
  618   function p nss_getCoo kie(cname)  {
  619       try {
  620           va r name = c name + "=" ;
  621           va r ca = doc ument.cook ie.split(' ;');
  622           fo r (var i =  0; i < ca .length; i ++) {
  623                var c =  ca[i];
  624                while (c .charAt(0)  == ' ') {
  625                    c =  c.substrin g(1);
  626                }
  627                if (c.in dexOf(name ) == 0) {
  628                    retu rn c.subst ring(name. length, c. length);
  629                }
  630           }
  631           re turn "";
  632       }
  633       catch  (err) {
  634           al ert('Progr ess Note S igner Sear ch Script  Failure: F unction Er ror(pnss_g etCookie):  ' + err.m essage);
  635       }
  636   }
  637  
  638   function p nss_execut eCrmOdataG etRequest( pnss_jsonQ uery, pnss _aSync, pn ss_aSyncCa llback, pn ss_skipCou nt, pnss_o ptionArray ) {
  639       //This  function  executes a  CRM Odata  web servi ce call to  retrieve  Crm data
  640       //*pns s_jsonQuer y* - a pro perly form atted CRM  Odata Quer y string ( required)
  641       //*pns s_aSync* -  specify ' true' to e xecute asy nchronousl y otherwis e 'false'  (required)
  642       //*pns s_aSyncCal lback* - s pecify the  name of t he return  function t o call upo n completi on (requir ed if pnss _aSync = t rue.  Othe rwise '')
  643       //*pns s_skipCoun t* - Initi al setting  is always  '0', incr ements by  50 per CRM  SDK Odata  standards  (required )
  644       //*pns s_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)
  645       try {
  646           va r pnss_ent ityData =  null;
  647           $. ajax({
  648                type: 'G ET',
  649                contentT ype: 'appl ication/js on; charse t=utf-8',
  650                datatype : 'json',
  651                url: pns s_jsonQuer y,
  652                beforeSe nd: functi on (XMLHtt pRequest)  {
  653                    XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json');
  654                },
  655                success:  function  (data, tex tStatus, X mlHttpRequ est) {
  656                    pnss _entityDat a = data;
  657                    if ( pnss_aSync  == true)  {
  658                         pnss_aSync Callback(p nss_entity Data, pnss _skipCount , pnss_opt ionArray);
  659                    }
  660                },
  661                error: f unction (X MLHttpRequ est, textS tatus, err orThrown)  {
  662                    aler t('Fail: A jax Error  in pnss_ex ecuteCrmOd ataGetRequ est: ' + e rrorThrown  + " Reque st: " + pn ss_jsonQue ry);
  663                },
  664                async: p nss_aSync,
  665                cache: f alse
  666           }) ;
  667           re turn pnss_ entityData ;
  668       }
  669       catch  (err) {
  670           al ert('An er ror occure d in the p nss_execut eCrmOdataG etRequest  function.   Error Det ail Messag e: ' + err );
  671       }
  672   }
  673  
  674   function p nss_execut eCrmOdataP ostRequest (pnss_json Query, pns s_aSync, p nss_jsonEn tityData,  pnss_recor dAction, p nss_crmGui dFieldName ) {
  675       //This  function  executes a  CRM Odata  web servi ce call to  create/up date a Crm  Record
  676       //*pns s_jsonQuer y* - the c omplete qu ery (url)  to be exec uted
  677       //*pns s_aSync* -  specify ' true' to e xecute asy nchronousl y otherwis e 'false'  (required)
  678       //*pns s_jsonEnti tyData* -  the crm en tity data  record to  be created /updated
  679       //*pns s_recordAc tion* - th e action t o be perfo rmed in CA PS 'CREATE ', 'UPDATE , 'DELETE'
  680       //*pns s_crmGuidF ieldName*  - the name  of the un ique ident ifier fiel d that has  the Guid/ Id for the  crm recor d created
  681  
  682       try {
  683           va r pnss_crm EntityId =  'FAIL';
  684  
  685           $. ajax({
  686                type: 'P OST',
  687                contentT ype: 'appl ication/js on; charse t=utf-8',
  688                datatype : 'json',
  689                url: pns s_jsonQuer y,
  690                data: pn ss_jsonEnt ityData,
  691                beforeSe nd: functi on (XMLHtt pRequest)  {
  692                    XMLH ttpRequest .setReques tHeader('A ccept', 'a pplication /json');
  693                    if ( pnss_recor dAction ==  'UPDATE')  { XMLHttp Request.se tRequestHe ader('X-HT TP-Method' , 'MERGE') ; }
  694                    if ( pnss_recor dAction ==  'DELETE')  { XMLHttp Request.se tRequestHe ader('X-HT TP-Method' , 'DELETE' ); }
  695                },
  696                success:  function  (data, tex tStatus, X mlHttpRequ est) {
  697                    if ( pnss_recor dAction ==  'CREATE')  { pnss_cr mEntityId  = data.d[p nss_crmGui dFieldName ].toString (); }
  698                },
  699                error: f unction (X mlHttpRequ est, textS tatus, err orThrown)  {
  700                    aler t('Ajax Er ror in pns s_executeC rmOdataPos tRequest:  ' + errorT hrown);
  701                    pnss _crmEntity Id = 'FAIL ';
  702                },
  703                async: p nss_aSync
  704           }) ;
  705           if  (pnss_rec ordAction  == 'CREATE ') { retur n pnss_crm EntityId;  }
  706       }
  707       catch  (err) {
  708           al ert('An er ror occure d in the p nss_execut eCrmOdataP ostRequest  function.   Error De tail Messa ge: ' + er r);
  709       }
  710   }
  711  
  712   function p nss_getMul tipleEntit yDataAsync (pnss_enti tySetName,  pnss_attr ibuteSet,  pnss_condi tionalFilt er, pnss_s ortAttribu te, pnss_s ortDirecti on, pnss_s kipCount,  pnss_aSync Callback,  pnss_optio nArray) {
  713       //This  function  returns a  CRM JSON d ataset for  all entit y records  matching c riteria pr ovided Asy ncronously
  714       //*pns s_entitySe tName* - i s the name  of the en tity set e .g 'Contac tSet'
  715       //*pns s_attribut eSet* -  i s a string  containin g the Crm  Attributes  to retrie ve e.g. 'F irstName,  LastName,  Telephone1 , EMailAdd ress1'
  716       //*pns s_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
  717       //*pns s_sortAttr ibute* - i s a string  containin g the name  of the at tribute to  sort the  result set  by e.g. ' LastName'
  718       //*pns s_sortDire ction* - i s a string  specifyin g the sort  as Ascend ing or Des cending e. g. 'asc' o r 'desc'
  719       //*pns s_skipCoun t* - is th e starting  point in  the result  (use if m ore than 5 0), (Put 0  if not us ed)
  720       //*pns s_aSyncCal lback* - i s the name  of the fu nction to  call when  returning  the result
  721       //*pns s_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
  722  
  723       try {
  724           va r pnss_jso nQuery = p nss_server Url + pnss _crmOdataE ndPoint +  '/' + pnss _entitySet Name + '?$ select=' +  pnss_attr ibuteSet +  '&$filter =' + pnss_ conditiona lFilter +  '&$orderby =' + pnss_ sortAttrib ute + ' '  + pnss_sor tDirection  + '&$skip =' + pnss_ skipCount;
  725           pn ss_execute CrmOdataGe tRequest(p nss_jsonQu ery, true,  pnss_aSyn cCallback,  pnss_skip Count, pns s_optionAr ray);
  726       }
  727       catch  (err) {
  728           al ert('An er ror occure d in the p nss_getMul tipleEntit yDataAsync  function.   Error De tail Messa ge: ' + er r);
  729       }
  730   }
  731  
  732   function p nss_getSin gleEntityD ataSync(pn ss_entityS etName, pn ss_attribu teSet, pns s_entityId ) {
  733       //This  function  returns a  CRM JSON d ataset for  a single  entity rec ord based  on the ent ity id pro vided Sync ronously
  734       //*pns s_entitySe tName* - i s the name  of the en tity set e .g 'Contac tSet'
  735       //*pns s_attribut eSet* -  i s a string  containin g the Crm  Attributes  to retrie ve e.g. 'F irstName,  LastName,  Telephone1 , EMailAdd ress1'
  736       //*pns s_entityId * - is the  Guid for  the entity  record
  737  
  738       try {
  739           va r pnss_ent ityIdNoBra cket = pns s_entityId .replace(/ ({|})/g, ' ');
  740           va r pnss_sel ectString  = '(guid'  + "'" + pn ss_entityI dNoBracket  + "'" + ' )?$select= ' + pnss_a ttributeSe t;
  741           va r pnss_jso nQuery = p nss_server Url + pnss _crmOdataE ndPoint +  '/' + pnss _entitySet Name + pns s_selectSt ring;
  742           va r pnss_ent ityData =  pnss_execu teCrmOdata GetRequest (pnss_json Query, fal se, '', 0,  null);
  743           re turn pnss_ entityData ;
  744       }
  745       catch  (err) {
  746           al ert('An er ror occure d in the p nss_getSin gleEntityD ataSync fu nction.  E rror Detai l Message:  ' + err);
  747       }
  748   }