Quantcast
Channel: Sam's Activities
Viewing all articles
Browse latest Browse all 3363

Javascript error in Model Driven App

$
0
0

Hello!

Please could someone take a look at the below and potentially reveal an answer? Any help would be much appreciated!

I am trying to implement JS to only show the tabs relevant to the business process flow stage.

However, the formContext.ui.tabs.get is returning null:

I have double checked the name of the tabs and business process flow stage name, so I am unsure why it is returning as null.

Code is below.

function onLoadMatt(executionContext) {
  var formContext = executionContext.getFormContext();
  formContext.data.process.addOnStageChange(onStageChangeMatt);
}

function onStageChangeMatt(executionContext) {
  var formContext = executionContext.getFormContext();
  var stage = formContext.data.process.getSelectedStage();
  var stageName = stage.getName();
 
  formContext.ui.tabs.get("tab_Create").setVisible(false);
  formContext.ui.tabs.get("tab_PI").setVisible(false);
  formContext.ui.tabs.get("tab_QR").setVisible(false);
  formContext.ui.tabs.get("tab_PO").setVisible(false);

  switch(stageName) {
    case "Create": {
      formContext.ui.tabs.get("tab_Create").setVisible(true);
      formContext.ui.tabs.get("tab_Create").setFocus();
      if(formContext.getAttribute("createdon").getValue() != null) {
        var tabObj = formContext.ui.tabs.get("tab_Create");
        var sectionObj = tabObj.sections.get("tab_Create_section_3");
        sectionObj.setVisible(true);
      }
      break;
    }
    case "PI": {
      formContext.ui.tabs.get("tab_PI").setVisible(true);
      formContext.ui.tabs.get("tab_PI").setFocus();
      break;
    }
    case "QS": {
      formContext.ui.tabs.get("tab_QR").setVisible(true);
      formContext.ui.tabs.get("tab_QR").setFocus();
      break;
  }
    case "PO": {
      formContext.ui.tabs.get("tab_PO").setVisible(true);
      formContext.ui.tabs.get("tab_PO").setFocus();
      break;
}
    default: {
      formContext.ui.tabs.get("tab_Create").setVisible(true);
      formContext.ui.tabs.get("tab_Create").setFocus();
      break;
    }
  }
}

I am calling the functions on the form onLoad event stage and I have checked that the execution context is being passed as the first parameter, and that the web resources are correct.

I am unsure what to change in the code to make this right?

Thanks


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>