Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.79 KB | None | 0 0
  1. /**
  2. * This method executes on load. Enables and disables Ready-To-Send button in the BPF Window based on the send-to-reviewers' status.
  3. * @param {*} executionContext
  4. */
  5. function lockReadytoSendOnChange(executionContext)
  6. {
  7. var formContext = executionContext.getFormContext();
  8. if(formContext.getControl("nofo_step7sentreviews") != null && formContext.getControl("nofo_step7sentreviews").getAttribute().getValue() == true)
  9. {
  10. if(formContext.getControl("header_process_nofo_step7readytosend").getAttribute().getValue() == true)
  11. {
  12. formContext.getControl("header_process_nofo_step7readytosend").getAttribute().setValue(false);
  13. }
  14. formContext.getControl("header_process_nofo_step7readytosend").setDisabled(true);
  15.  
  16. formContext.ui.clearFormNotification("LoopInProgressMessage");
  17. formContext.ui.setFormNotification("Stage cannot be moved while the review loop is in-progress. Fields on the right pane will be locked until the review loop is complete.","INFO","LoopInProgressMessage");
  18.  
  19. }
  20. else if(formContext.getControl("nofo_step7sentreviews") != null && formContext.getControl("nofo_step7sentreviews").getAttribute().getValue() == false)
  21. {
  22. formContext.getControl("header_process_nofo_step7readytosend").setDisabled(false);
  23. formContext.ui.clearFormNotification("LoopInProgressMessage");
  24. }
  25.  
  26. }
  27. /**
  28. * This method gets executed on load. If step 7 loop has been initiated for either B/O or reviewers(OFAM/OB/Other), additional review section
  29. * is set to visible else it hides it.
  30. * @param {*} executionContext
  31. */
  32. function showHideStep7LoopOptionsOnChange(executionContext)
  33. {
  34. var formContext = executionContext.getFormContext();
  35. if(formContext.getControl("nofo_step7loopsendtobo").getAttribute() != null && formContext.getControl("nofo_step7loopsendtoreviewers").getAttribute() != null)
  36. {
  37. if(formContext.getControl("nofo_step7loopsendtobo").getAttribute().getValue() == true || formContext.getControl("nofo_step7loopsendtoreviewers").getAttribute().getValue() == true)
  38. {
  39. formContext.ui.tabs.get("additionalreviews").sections.get("Step7ReviewLoopOptions").setVisible(true);
  40. }
  41. else
  42. {
  43. formContext.ui.tabs.get("additionalreviews").sections.get("Step7ReviewLoopOptions").setVisible(false);
  44. }
  45. }
  46. }
  47.  
  48. /**
  49. * If step 7 loop has been initiated for either B/O or reviewers(OFAM/OB/Other), additional review section
  50. * is set to visible else it hides it. Invoke from New UI customization.js
  51. * @param {*} formContext
  52. */
  53. function showHideStep7LoopOptions(formContext)
  54. {
  55. if(formContext.getControl("nofo_step7loopsendtobo").getAttribute() != null && formContext.getControl("nofo_step7loopsendtoreviewers").getAttribute() != null)
  56. {
  57. if(formContext.getControl("nofo_step7loopsendtobo").getAttribute().getValue() == true || formContext.getControl("nofo_step7loopsendtoreviewers").getAttribute().getValue() == true)
  58. {
  59. formContext.ui.tabs.get("additionalreviews").sections.get("Step7ReviewLoopOptions").setVisible(true);
  60. }
  61. else
  62. {
  63. formContext.ui.tabs.get("additionalreviews").sections.get("Step7ReviewLoopOptions").setVisible(false);
  64. }
  65. }
  66. }
  67.  
  68. //Listener is trying to get the message send from Html Webresource
  69. function AddListener(executionContext) {
  70. var fc = executionContext.getFormContext();
  71. // For All browsers except Internet Explorer.
  72. if (window.XMLHttpRequest) {
  73. window.parent.addEventListener("message", function(event){ receiveMessage(event,fc); }, false);
  74. } else {
  75. //ie
  76. window.parent.attachEvent("onmessage", function(event){ receiveMessage(event,fc); });
  77. }
  78. }
  79.  
  80. //Method that gets executed when an HTML web resource is clicked
  81. function receiveMessage(event,fc)
  82. {
  83. // btnclick values are set in the HTML webresource code.
  84. var btnClick = JSON.parse(event.data);
  85. if(btnClick.value == "Step7SendReviews")
  86. {
  87. // Step 7 Innitiate review
  88. var stepNO = 7;
  89. step7SendReviews(fc,stepNO);
  90. }
  91. if(btnClick.value == "CompleteReview")
  92. {
  93. // Step 7 Complete entire review loop.
  94. var stepNO = 7;
  95. step7CompleteReview(fc,stepNO);
  96. }
  97. if(btnClick.value == "CompleteOtherReview")
  98. {
  99. // Step 7 Complete Other loop review
  100. var stepNO = 7;
  101. step7CompleteOtherReview(fc,stepNO);
  102. }
  103. if(btnClick.value == "Step8SendReviewstoDGPandBO")
  104. {
  105. // Step 8 Initiate review for DGP and B/O
  106. // Step 8 - Send to BO and DGP ID = 21BD4531-FFEF-4814-B257-DBDADE262A48
  107.  
  108. var stepNO = 8;
  109. var promptMessage = "This action will initiate a review loop. For DGP and B/O, this action will create task and send emails. Do you want to proceed?";
  110. var workflowID = "21BD4531-FFEF-4814-B257-DBDADE262A48";
  111. Step8InitiateReviewWorkflow(fc, promptMessage, workflowID, stepNO);
  112. }
  113. if(btnClick.value == "step8SendReviews")
  114. {
  115. // Step 8 Initiate review for DGMO, DIR and OB
  116. // Step 8 - Send Reviews DGP Workflow
  117. var stepNO = 8;
  118. var promptMessage = "This action will initiate a review loop, create tasks and send emails. Do you want to proceed?";
  119. var workflowID = "D7C4A0B1-3F3C-4072-9B5F-3AB171E15843";
  120. if(validateFormStep8Fields(fc))
  121. {
  122. Step8InitiateReviewWorkflow(fc, promptMessage, workflowID, stepNO);
  123. }
  124. else
  125. {
  126. fc.ui.setFormNotification("At least one reviewer (DGMO, DIR, OB, Others) needs to be selected to initiate the review loop.", "ERROR", "missing fields");
  127. setTimeout(function() {
  128. fc.ui.clearFormNotification("missing fields");
  129. }, 10000);
  130.  
  131. }
  132.  
  133. }
  134. if(btnClick.value == "Step8CompleteReview")
  135. {
  136. // Step 8 complete review loop.
  137. // Step 8 - Watch for Complete Review and reset fields - 443698F6-4570-496F-A514-162F68CE4FB5
  138. var stepNO = 8;
  139. var promptMessage = "This action will complete the loop. If there are any open reviews, this action will close all the tasks. Do you want to proceed?";
  140. var workflowID = "443698F6-4570-496F-A514-162F68CE4FB5";
  141. Step8CompleteReviewWorkflow(fc, promptMessage, workflowID, stepNO);
  142. }
  143. if(btnClick.value == "Step8CompleteOtherReview")
  144. {
  145. // Step 8 complete review loop.
  146. // Step 8 - Watch for Complete Review and reset fields - 443698F6-4570-496F-A514-162F68CE4FB5
  147. var stepNO = 8;
  148. var promptMessage = "This action will complete the Other review loop. Do you want to proceed?";
  149. var workflowID = "F4E64E24-3629-4BB4-B888-01E3B9343D7A";
  150. step8CompleteOtherReview(fc, promptMessage, workflowID, stepNO);
  151. }
  152.  
  153. }
  154. /**
  155. * This function starts progress indicator and runs until close function is called.
  156. */
  157. function openProgressIndicator()
  158. {
  159. Xrm.Utility.showProgressIndicator("Loading...");
  160.  
  161. }
  162.  
  163.  
  164.  
  165. function closeProgressIndicator()
  166. {
  167. Xrm.Utility.closeProgressIndicator();
  168. }
  169. /**
  170. * This method completes the Other review loop. DGP can perform this task by clicking on the complete other review button and then this function will execute.
  171. * @param {*} formContext
  172. */
  173. function step7CompleteOtherReview(formContext, stepNO)
  174. {
  175. formContext.getAttribute("nofo_loopjustificationforclosing").setRequiredLevel("none");
  176. var confirmStrings = { text:"This action will complete the Other review loop. Do you want to proceed?", title:"Confirmation Dialog" };
  177. var confirmOptions = { height: 300, width: 500 };
  178. Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
  179. function (success) {
  180. if (success.confirmed)
  181. {
  182. formContext.getAttribute("nofo_step7loopcompleteotherreview").setValue(true);
  183. formContext.data.save().then(
  184.  
  185. function () {
  186. //Success function call back
  187. openProgressIndicator();
  188. callWorkflow(formContext, "F1FE03A1-A57C-4DFF-BA29-75CB360777BF", stepNO);
  189. refreshReviewButton(formContext);
  190. },
  191. function () {
  192. formContext.ui.setFormNotification("Validation errors needs to be fixed to save the form.", "ERROR", "missing fields");
  193. setTimeout(function() {
  194. formContext.ui.clearFormNotification("missing fields");
  195. }, 10000);
  196. });
  197. }
  198. });
  199. }
  200.  
  201.  
  202. /**
  203. * This method completes the Other review loop. DGP can perform this task by clicking on the complete other review button and then this function will execute.
  204. */
  205. function step8CompleteOtherReview(formContext, promptMessage, workflowId, stepNo)
  206. {
  207. formContext.getAttribute("nofo_loopjustificationforclosing").setRequiredLevel("none");
  208. var confirmStrings = { text:promptMessage, title:"Confirmation Dialog" };
  209. var confirmOptions = { height: 300, width: 500 };
  210. Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
  211. function (success) {
  212. if (success.confirmed)
  213. {
  214. formContext.getAttribute("nofo_step8loopcompleteotherreview").setValue(true);
  215.  
  216. formContext.data.save().then(
  217.  
  218. function () {
  219. //Success function call back
  220. openProgressIndicator();
  221. callWorkflow(formContext, workflowId, stepNo);
  222. refreshReviewButton(formContext);
  223. },
  224. function () {
  225. formContext.ui.setFormNotification("Validation errors needs to be fixed to save the form.", "ERROR", "missing fields");
  226. setTimeout(function() {
  227. formContext.ui.clearFormNotification("missing fields");
  228. }, 10000);
  229. });
  230. }
  231. });
  232. }
  233.  
  234.  
  235. function step7CompleteReview(formContext, stepNO)
  236. {
  237. /**
  238. * Complete the loop review by DGP.
  239. */
  240. var confirmStrings = { text:"This action will complete the loop. If there are any open reviews, this action will close all the tasks. Do you want to proceed?", title:"Confirmation Dialog" };
  241. var confirmOptions = { height: 300, width: 500 };
  242. Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
  243. function (success) {
  244. if (success.confirmed)
  245. {
  246. if(!validateJustification(formContext))
  247. {
  248. formContext.getAttribute("nofo_loopjustificationforclosing").setRequiredLevel("required");
  249. }
  250.  
  251. formContext.data.save().then(
  252. function () {
  253. //Success function call back
  254. // Workflow -> "Step 7 - Watch for Other Reviewed? and Update Fields", ID = 2FE7DE89-88FC-4DA3-9800-DCC63F1CD82F
  255. openProgressIndicator();
  256. callWorkflow(formContext, "2FE7DE89-88FC-4DA3-9800-DCC63F1CD82F", stepNO);
  257. formContext.getAttribute("nofo_loopjustificationforclosing").setRequiredLevel("none");
  258.  
  259. },
  260. function () {
  261. //Error function callback.
  262. formContext.ui.setFormNotification("Validation errors needs to be fixed to save the form.", "ERROR", "missing fields");
  263. setTimeout(function() {
  264. formContext.ui.clearFormNotification("missing fields");
  265. }, 10000);
  266. });
  267.  
  268. }
  269. });
  270.  
  271. }
  272. /**
  273. * This method starts step 7 review loop. Based on user selection creates task for reviewers through the workflow.
  274. * @param {} formContext
  275. */
  276. function step7SendReviews(formContext, stepNO)
  277. {
  278. var confirmStrings = { text:"This action will initiate a review loop, create tasks and send emails. Do you want to proceed?", title:"Confirmation Dialog" };
  279. var confirmOptions = { height: 300, width: 500 };
  280. Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
  281. function (success) {
  282. if (success.confirmed)
  283. {
  284. formContext.data.save().then(
  285. function () {
  286. //If Success function call workflow
  287. var id = formContext.data.entity.getId().replace("{", "").replace("}", "");
  288. var actionUrl = "nofo_nofoguidancedocuments("+ id + ")/Microsoft.Dynamics.CRM.nofo_Step7LoopActionReadytoSendDGMO";
  289. if(validateFormFields(formContext))
  290. {
  291. openProgressIndicator();
  292. callWorkflow(formContext, "A3CAAD65-546D-4E9F-B872-51F87138964A", stepNO);
  293. }else{
  294. formContext.ui.setFormNotification("At least one reviewer (DGMO, DIR, OB, Others) needs to be selected to initiate the review loop.", "ERROR", "missing fields");
  295. setTimeout(function() {
  296. formContext.ui.clearFormNotification("missing fields");
  297. }, 10000);
  298.  
  299. }
  300.  
  301. },
  302. function () {
  303. //Error function callback.
  304. formContext.ui.setFormNotification("Validation errors needs to be fixed to save the form.", "ERROR", "missing fields");
  305. setTimeout(function() {
  306. formContext.ui.clearFormNotification("missing fields");
  307. }, 10000);
  308. });
  309.  
  310. }
  311. });
  312.  
  313.  
  314. }
  315. /**
  316. * This function validates the additional review form field. User needs to select atleast one organization to initiate the review loop.
  317. * @param {} formContext
  318. */
  319. function validateFormFields(formContext)
  320. {
  321. var dgmo = formContext.getControl("nofo_step7loopsendtodgmo").getAttribute().getValue();
  322. var dir = formContext.getControl("nofo_step7loopsendtodir").getAttribute().getValue();
  323. var ob = formContext.getControl("nofo_step7loopsendtoob").getAttribute().getValue();
  324. var other = formContext.getControl("nofo_step7loopsendtoother").getAttribute().getValue();
  325. var bo = formContext.getControl("nofo_step7loopsendtobo").getAttribute().getValue();
  326. if(dgmo || dir || ob || other || bo){
  327. return true;
  328. }else{
  329. return false;
  330. }
  331.  
  332. }
  333.  
  334. function validateFormStep8Fields(formContext)
  335. {
  336. var dgmo = formContext.getControl("nofo_step8loopsendtodgmo").getAttribute().getValue();
  337. var dir = formContext.getControl("nofo_step8loopsendtodir").getAttribute().getValue();
  338. var ob = formContext.getControl("nofo_step8loopsendtoob").getAttribute().getValue();
  339. var other = formContext.getControl("nofo_step8loopsendtoother").getAttribute().getValue();
  340. if(dgmo || dir || ob || other || bo){
  341. return true;
  342. }else{
  343. return false;
  344. }
  345.  
  346. }
  347.  
  348. function validateJustification(formContext)
  349. {
  350.  
  351. var boLoopStatus = formContext. getControl("nofo_boloopstatus").getAttribute().getText();
  352. var dgmoLoopStatus = formContext. getControl("nofo_dgmoloopstatus").getAttribute().getText();
  353. var dirLoopStatus = formContext. getControl("nofo_dirloopstatus").getAttribute().getText();
  354. var obLoopStatus = formContext. getControl("nofo_obloopstatus").getAttribute().getText();
  355. var otherLoopStatus = formContext. getControl("nofo_otherloopstatus").getAttribute().getText();
  356. var justificationForClosing = formContext. getControl("nofo_loopjustificationforclosing").getAttribute().getValue();
  357.  
  358.  
  359. if((boLoopStatus == "Not Complete" || dgmoLoopStatus == "Not Complete" || dirLoopStatus == "Not Complete" || obLoopStatus == "Not Complete" || otherLoopStatus == "Not Complete" ) && (justificationForClosing == null || justificationForClosing == ""))
  360. {
  361. return false;
  362. }
  363. else
  364. {
  365. return true;
  366. }
  367. }
  368.  
  369. /**
  370. * At Step 8 IOA initiates review loop for DGP and B/O. DGP can initiate further to reviewers. This method calls all the Step 8 workflows.
  371. * @param {*} formContext
  372. */
  373. function Step8InitiateReviewWorkflow(formContext, promptMessage, workflowId, stepNo)
  374. {
  375.  
  376. var confirmStrings = { text:promptMessage, title:"Confirmation Dialog" };
  377. var confirmOptions = { height: 300, width: 500 };
  378. Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
  379. function (success) {
  380. if (success.confirmed)
  381. {
  382. formContext.data.save().then(
  383. function () {
  384. //Success function call workflow
  385. openProgressIndicator();
  386. // passing formcontext and workflow ID to the CallWorkflow method.
  387. callWorkflow(formContext, workflowId, stepNo);
  388.  
  389. },
  390. function () {
  391. //Error function callback.
  392. formContext.ui.setFormNotification("Validation errors needs to be fixed to save the form.", "ERROR", "missing fields");
  393. setTimeout(function() {
  394. formContext.ui.clearFormNotification("missing fields");
  395. }, 10000);
  396. });
  397.  
  398. }
  399. });
  400.  
  401. }
  402.  
  403. /**
  404. * At Step 8, DGP completes the review loop. This method calls appropriate workflows
  405. * @param {*} formContext
  406. */
  407. function Step8CompleteReviewWorkflow(formContext, promptMessage, workflowId, stepNo)
  408. {
  409.  
  410. var confirmStrings = { text:promptMessage, title:"Confirmation Dialog" };
  411. var confirmOptions = { height: 300, width: 500 };
  412. Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
  413. function (success) {
  414. if (success.confirmed)
  415. {
  416. if(!validateJustification(formContext))
  417. {
  418. formContext.getAttribute("nofo_loopjustificationforclosing").setRequiredLevel("required");
  419. }
  420. formContext.data.save().then(
  421. function () {
  422. //Success function call workflow
  423. openProgressIndicator();
  424. // passing formcontext and workflow ID to the CallWorkflow method.
  425. callWorkflow(formContext, workflowId, stepNo);
  426.  
  427. //After completing the loop, hide Biz process, Document tab and additional review tabs
  428. hideDocumentTab(formContext);
  429. hideBusinessProcessUI(formContext);
  430. formContext.ui.tabs.get("additionalreviewsstep8").sections.get("Step8ReviewLoopOptions").setVisible(false);
  431. formContext.ui.tabs.get("additionalreviewsstep8").sections.get("invokestep8loop").setVisible(false);
  432. formContext.getAttribute("nofo_loopjustificationforclosing").setRequiredLevel("none");
  433. },
  434. function () {
  435. //Error function callback.
  436. formContext.ui.setFormNotification("Validation errors needs to be fixed to save the form.", "ERROR", "missing fields");
  437. setTimeout(function() {
  438. formContext.ui.clearFormNotification("missing fields");
  439. }, 10000);
  440. });
  441.  
  442. }
  443. });
  444.  
  445. }
  446.  
  447. /**
  448. * Generic method to invoke a dynamics workflow based on the workflow ID.
  449. * @param {*} formContext
  450. * @param {*} workflowId
  451. */
  452. function callWorkflow(formContext, workflowId, stepNo)
  453. {
  454. var workflowId = workflowId;
  455. var clientURL =formContext.context.getClientUrl();
  456. var nofoId = formContext.data.entity.getId().replace("{", "").replace("}", "");
  457. var data = {
  458. "EntityId": nofoId
  459. };
  460.  
  461. var req = new XMLHttpRequest();
  462. req.open("POST", clientURL + "/api/data/v9.0/workflows("+workflowId+")/Microsoft.Dynamics.CRM.ExecuteWorkflow", true);
  463. req.setRequestHeader("Accept", "application/json");
  464. req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
  465. req.setRequestHeader("OData-MaxVersion", "4.0");
  466. req.setRequestHeader("OData-Version", "4.0");
  467. req.onreadystatechange = function () {
  468. if (this.readyState === 4 /* complete */)
  469. {
  470. if (this.status === 204 || this.status === 200) {
  471. var subgrid = formContext.getControl("Step7LoopDetails");
  472. //alert("workflow executed");
  473. refreshWebResources(formContext, stepNo);
  474. showHideStep8SendToDGPandBOOnLoad(formContext)
  475. formContext.data.refresh();
  476. closeProgressIndicator();
  477. Notify.add("Information saved successfully.", "SUCCESS", "testId", null, 30);
  478.  
  479. } else {
  480. //Xrm.Utility.closeProgressIndicator();
  481. alert(this.status +" " +this.responseText);
  482. closeProgressIndicator();
  483. alert("Error executing workflow. Please contact administrator");
  484.  
  485. }
  486. }
  487. };
  488.  
  489.  
  490.  
  491. req.send(JSON.stringify(data));
  492.  
  493. }
  494. /**
  495. * After workflow is invoked web-resources needs to be refreshed.
  496. * Generic method to refresh based on button control object.
  497. * @param {*} formContext
  498. */
  499. function refreshWebResources(formContext, stepNo)
  500. {
  501.  
  502. var sentReview;
  503. var compReview;
  504.  
  505. if(stepNo === 7)
  506. {
  507. sentReview = formContext.getControl("WebResource_Step7SendReviewsButton");
  508. compReview = formContext.getControl("WebResource_Step7CompleteReviewButton");
  509.  
  510. }
  511.  
  512. else if(stepNo === 8){
  513. //alert("refresh step 8 web resource");
  514. sentReview = formContext.getControl("WebResource_step8SendReviewButton");
  515. compReview = formContext.getControl("WebResource_step8CompleteReviewsButton");
  516. }
  517. if(sentReview.getObject() != null && compReview.getObject() != null)
  518. {
  519. var src_rev = sentReview.getObject().src;
  520. sentReview.getObject().src = "about:blank";
  521. var src_comp = compReview.getObject().src;
  522. compReview.getObject().src = "about:blank";
  523. setTimeout(function () {
  524. compReview.getObject().src = src_comp ;
  525. sentReview.getObject().src = src_rev ;
  526.  
  527. }, 1000);
  528. }
  529.  
  530.  
  531. }
  532.  
  533.  
  534.  
  535. /**
  536. * This function hide or show "Complete Other Review Button" based on the Other loop status.
  537. * If status is "Not complete" it makes the button visible else hides it.
  538. * @param {*} executionContext
  539. */
  540. function hideCompleteOtherReviewButton(executionContext)
  541. {
  542. var formContext = executionContext.getFormContext();
  543. var otherLoopStatus= formContext.getControl("nofo_otherloopstatus").getAttribute().getValue();
  544.  
  545. //827580004 - 08. IOA Review Final and 827580007 - 07. DGP Prefinal
  546. var nofoStatus = formContext.getControl("nofo_status").getAttribute().getValue();
  547. var completeOtherReviewButton;
  548. if(nofoStatus == "827580007")
  549. completeOtherReviewButton = formContext.getControl("WebResource_Step7CompleteOtherReviewButton");
  550. else if(nofoStatus == "827580004")
  551. completeOtherReviewButton = formContext.getControl("WebResource_step8CompleteOtherReviewButton");
  552.  
  553. // "Not Complete's" field value is - 827580000, N/A = 827580002, Complete = 827580001
  554. if(otherLoopStatus == "827580000"){
  555. completeOtherReviewButton.setVisible(true);
  556. }
  557. else{
  558. completeOtherReviewButton.setVisible(false);
  559. }
  560. refreshReviewButton(completeOtherReviewButton);
  561. }
  562.  
  563. /**
  564. * This function hide or show "Complete Other Review Button" On load based on the Other loop status.
  565. * If status is "Not complete" it makes the button visible else hides it.
  566. * @param {*} executionContext
  567. */
  568. function hideCompleteOtherReviewButtonOnLoad(formContext)
  569. {
  570. //var formContext = executionContext.getFormContext();
  571. var otherLoopStatus= formContext.getControl("nofo_otherloopstatus").getAttribute().getValue();
  572. //827580004 - 08. IOA Review Final and 827580007 - 07. DGP Prefinal
  573. var nofoStatus = formContext.getControl("nofo_status").getAttribute().getValue();
  574. var completeOtherReviewButton;
  575. if(nofoStatus == "827580007")
  576. completeOtherReviewButton = formContext.getControl("WebResource_Step7CompleteOtherReviewButton");
  577. else if(nofoStatus == "827580004")
  578. completeOtherReviewButton = formContext.getControl("WebResource_step8CompleteOtherReviewButton");
  579.  
  580. // "Not Complete's" field value is - 827580000, N/A = 827580002, Complete = 827580001
  581. if(otherLoopStatus == "827580000"){
  582. completeOtherReviewButton.setVisible(true);
  583. }
  584. else{
  585. completeOtherReviewButton.setVisible(false);
  586. }
  587. refreshReviewButton(completeOtherReviewButton);
  588. }
  589. /**
  590. * After workflow is invoked web-resources needs to be refreshed. Only for the complete other review button.
  591. * @param {*} formContext
  592. */
  593. function refreshReviewButton(buttonControlObj)
  594. {
  595. //var compOtherReview = formContext.getControl("WebResource_Step7CompleteOtherReviewButton");
  596. var src_other;
  597. if(buttonControlObj != null && buttonControlObj.getObject() != null)
  598. {
  599. src_other = buttonControlObj.getObject().src;
  600. buttonControlObj.getObject().src = "about:blank";
  601. setTimeout(function () {
  602. buttonControlObj.getObject().src = src_other ;
  603.  
  604. }, 1000);
  605. }
  606.  
  607. /*if(buttonControlObj != null && buttonControlObj.getObject() != null)
  608. {
  609. buttonControlObj.getObject().src = src_other;
  610.  
  611. }*/
  612.  
  613. }
  614.  
  615. /**
  616. * Function loads on event change. When user selects checkbox"Send to DGP and B/O".
  617. * Hides or show "Send to DGP and B/O" button based on the nofo_step8loopsendtodgpbo field value.
  618. * @param {*} executionContext
  619. */
  620. function showHideStep8SendToDGPandBO(executionContext)
  621. {
  622. var formContext = executionContext.getFormContext();
  623. var sendToDGPandBOStatus = formContext.getControl("nofo_step8loopsendtodgpbo").getAttribute().getValue();
  624. var sendToDGPandBOButton = formContext.getControl("WebResource_sendToDGPandBO");
  625. //refreshReviewButton(sendToDGPandBOButton);
  626. if(sendToDGPandBOStatus)
  627. {
  628. sendToDGPandBOButton.setVisible(true);
  629. }else{
  630. sendToDGPandBOButton.setVisible(false);
  631. }
  632.  
  633.  
  634. //refreshReviewButton(sendToDGPandBOButton);
  635.  
  636. }
  637. /**
  638. * Function executes on load. Hides or show "Send to DGP and B/O" button based on the nofo_step8loopsendtodgpbo field value.
  639. * @param {*} executionContext
  640. */
  641. function showHideStep8SendToDGPandBOOnLoad(formContext)
  642. {
  643. //var formContext = executionContext.getFormContext();
  644. var sendToDGPandBOStatus = formContext.getControl("nofo_step8loopsendtodgpbo").getAttribute().getValue();
  645. var sendToDGPandBOButton = formContext.getControl("WebResource_sendToDGPandBO");
  646. if(!sendToDGPandBOStatus)
  647. {
  648. sendToDGPandBOButton.setVisible(false);
  649. }
  650.  
  651. refreshReviewButton(sendToDGPandBOButton);
  652.  
  653. }
  654.  
  655. function showNotificationWhenStep8LoopInProgressOnChange(executionContext)
  656. {
  657. var formContext = executionContext.getFormContext();
  658. var step8SentReviews = formContext.getControl("nofo_step8sentreviews").getAttribute().getValue();
  659.  
  660. if(step8SentReviews)
  661. {
  662. formContext.ui.clearFormNotification("LoopInProgressMessage");
  663. formContext.ui.setFormNotification("Stage cannot be moved while the revew loop is in-progress. Fields on the right pane will be locked until the review loop is complete.","INFO","LoopInProgressMessage");
  664.  
  665. var sendToHHSOMB = formContext.getControl("header_process_nofo_bp_reviewfinalnofoioa_sendtoob")
  666. if(sendToHHSOMB != null)
  667. {
  668. formContext.getControl("header_process_nofo_bp_reviewfinalnofoioa_sendtoob").setDisabled(true);
  669. }
  670.  
  671. var sendToDGP = formContext.getControl("header_process_nofo_bp_reviewfinalnofoioa_sendtodgp")
  672. if(sendToDGP != null)
  673. {
  674. formContext.getControl("header_process_nofo_bp_reviewfinalnofoioa_sendtodgp").setDisabled(true);
  675. }
  676. }
  677. else
  678. {
  679. formContext.ui.clearFormNotification("LoopInProgressMessage");
  680.  
  681. var sendToHHSOMB = formContext.getControl("header_process_nofo_bp_reviewfinalnofoioa_sendtoob")
  682. if(sendToHHSOMB != null)
  683. {
  684. formContext.getControl("header_process_nofo_bp_reviewfinalnofoioa_sendtoob").setDisabled(false);
  685. }
  686.  
  687. var sendToDGP = formContext.getControl("header_process_nofo_bp_reviewfinalnofoioa_sendtodgp")
  688. if(sendToDGP != null)
  689. {
  690. formContext.getControl("header_process_nofo_bp_reviewfinalnofoioa_sendtodgp").setDisabled(false);
  691. }
  692. }
  693.  
  694.  
  695. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement