You are here

Apps Parameters

Apps parameters allow to initialize and set parameters that are relative to a BananaApps, for example:

  • Parameters for the printing.
  • Header of a report that are set once only.

The script should provide a function settingDialog() that is called when the user click on the Set Parameters on the Manage Apps dialog.

The function settinDialog() should:

  1. Read the existing setting with the Banana.document.getScriptSettings();
  2. Request user to enter the information
  3. Set the modified values with the function Banana.document.setScriptSettings(paramToString);
    The JSon text will be saved within the accounting file.
     
function settingsDialog() {
   var param = initParam();
   var savedParam = Banana.document.getScriptSettings();
   if (savedParam.length > 0) {
      param = JSON.parse(savedParam);
   }   
   param = verifyParam(param);
   
   param.isr_bank_name = Banana.Ui.getText('Settings', texts.param_isr_bank_name, param.isr_bank_name);
   if (param.isr_bank_name === undefined)
      return;
   var paramToString = JSON.stringify(param);
   Banana.document.setScriptSettings(paramToString);
}

the function Exec() should then read the setting.
It is a good practice to check and verify if the setting are valid.

function printDocument(jsonInvoice, repDocObj, repStyleObj) {
  var param = initParam();
  var savedParam = Banana.document.getScriptSettings();
  if (savedParam.length > 0) {
    param = JSON.parse(savedParam);
    param = verifyParam(param);
  }
  printInvoice(jsonInvoice, repDocObj, repStyleObj, param);
}

Share this article: Twitter | Facebook | Email


Help us improve the documentation

We welcome feedback on how to improve this page.
Tell us what theme needs a better explanation or how to clarify a topic.