I have a requirement for some fairly complex logic to conditionally hide certain fields based on various criteria.

My thought was to store the rules for hiding fields in a custom object and then query that object using the jsForce library to get the rules, store them in a mutidimensional array and then use that array in the isFieldVisible method to hide the fields should the criteria be met on that particular quote line.

Since the isFieldVisible is executed for each field on each quote line (and I have a lot of fields) putting the query logic in that method is not feasible. I thought I could do this in the onInit method and store the result as a variable that could be access later. Is seems that every time isFieldVisible is called that variable is not set with the values I set for it in the onInit.

Is there a way to set some sort of global variable that will retain its value until the onInit is call again?

1 Answer 1


Yes you can have variables declared at Top of QCP above all export functions and there state will also be maintained.

i.e let say you populate the variable in before calculate, you can access it in after calculate

  • This wasn't my experience and I am doing this in isFieldVisible and isFieldEditable which get call for every field on every line and don't seem to maintain any sort of state. If I defined the variable in before calculate, would it be maintained in isFieldVisible?
    – Rostro
    Jun 21, 2021 at 18:16
  • YES you are correct you will not get the variable after full calculation in QCP, i have faced the same scenario, to fix this issue you can create a hidden html tag in outer html of the page via JSQCP itself and create attributes under that tag to store the values which will be retained until the page is refreshed again and you can use those attributes values via standard DOM functions like getElementByID Jul 8, 2021 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .