First, create a derived work record and add the fields HTMLAREA and EP_STORE_PB
Second, add the fields from step one to the EP_APPR_MAIN1 and EP_APPR_BASE1.
*Make sure you set the EP_STORE_PB to invisible and modifiable via JavaScript and give it a page field name of ZZ_EP_STORE.
Third, add the following PeopleCode to the work records.
Add some FieldChange PeopleCode to the EP_STORE_PB to save the Document. This can be copied from the Delivered Save Logic.
/******************************************* RITM0054746 8.53 TOOLS UPGRADE UMBMOD KCW002 Autosave code changed to for new timout logic in 8.53 *****************************************/ import EP_FUNCTIONS:EP_Utilities; Declare Function TransferToDocumentSelection PeopleCode FUNCLIB_EP.EP_APPRAISAL_ID FieldFormula; Global Record &EP_GBLKEYS_WRK; Component string &PushButton; Evaluate %Component When = Component.EP_APPR_BASE &ReturnCode = "RETURN_EST_SAVE"; &TransferPg = "Page.EP_APPR_BASE1"; Break; When = Component.EP_APPR_MAIN &ReturnCode = "RETURN_EVL_SAVE"; &TransferPg = "Page.EP_APPR_MAIN1"; Break; When-Other Exit; Break; End-Evaluate; /* Clear error messages, if any, and Save */ EP_BTN_LINK_WRK.EP_HTMLAREA_ERROR1.SetDefault(); EP_BTN_LINK_WRK.EP_HTMLAREA_ERROR2.SetDefault(); EP_BTN_LINK_WRK.EP_HTMLAREA_ERROR1.Visible = False; EP_BTN_LINK_WRK.EP_HTMLAREA_ERROR2.Visible = False; &PushButton = "STORE"; DoSaveNow(); Rem: Set Return Status to display a confirmation message; &EP_GBLKEYS_WRK.EP_RETURN_STATUS.Value = &ReturnCode; Rem: Set the Return Status HTML Area; Local EP_FUNCTIONS:EP_Utilities &EP_Utilities = create EP_FUNCTIONS:EP_Utilities(); &EP_Utilities.SetReturnStatusHtmlArea(); Rem: Set focus to the top of the page for the return status message; If ZZ_DERIVED_EP.EP_STORE_PB.Value = "T" Then REM DO TIMEOUT; ZZ_DERIVED_EP.HTMLAREA.Value = GetHTMLText(HTML.ZZ_EP_TIMEOUT); Else ZZ_DERIVED_EP.EP_STORE_PB.Value = ""; End-If;
Also add some PeopleCode to the RowInit of the HTMLAREA.
/******************************************* RITM0054746 8.53 TOOLS UPGRADE UMBMOD KCW002 Autosave code changed to for new timout logic in 8.53 Setup JavaScript for UMB Autosave timeout *****************************************/ ZZ_DERIVED_EP.HTMLAREA.Value = GetHTMLText(HTML.ZZ_EP_AUTOSAVE);
Fourth, create two HTML Objects.
HTML.ZZ_EP_AUTOSAVE below:
<input type="hidden" name="ZZ_EP_STORE" id="ZZ_EP_STORE" value=""/> <script type="text/javascript"> threadLock = false; var xStore = document.getElementById("ZZ_EP_STORE"); function user_function() { //alert('starting process'); //debugger; if (!threadLock) { threadLock = true; if ("%page" == "EP_APPR_MAIN1" || "%page" == "EP_APPR_BASE1" ) { xStore.value = 'T'; //alert(xStore.value); document.%formname.submit(); } } } </script> <script type="text/javascript" language="javascript"> window.onbeforeunload = function(e) { var changes = checkFormChanged(document.%formname); if (changes && !threadLock) { threadLock = true; if ("%page" == "EP_APPR_MAIN1" || "%page" == "EP_APPR_BASE1" ) { return "You have unsaved changes, please save them." }; } } </script> <script type="text/javascript"> function adaptLinks() { var links = document.getElementsByTagName('a'); for (i = 0; i != links.length; i++) { links[i].onclick = (function () { var origOnClick = links[i].onclick; return function (e) { //add logic to save if the user is adding and item to the document //linkId = this.id.split('$'); //if (linkId[0] == 'EP_BTN_LINK_WRK_EP_ADD_ITEM_PB') // { // xStore.value = 'Z'; // } //end mod to auto save if the user is adding an item to the document window.onbeforeunload = function(){}; if (origOnClick != null && !origOnClick()) { return false; } } })(); } } (function() { var originaldisplayTimeoutMsg = displayTimeoutMsg2; displayTimeoutMsg2 = function() { window.onbeforeunload = function(){}; user_function(); } })(); adaptLinks(); </script>
HTML.ZZ_EP_TIMEOUT below:
<input type="hidden" name="TIMEOUT" value=""/> <script type="text/javascript"> self.location=timeOutURL; ; </script>
No comments:
Post a Comment