Home Forums Development Business Processes – running function on value of question(s)

Viewing 2 reply threads
  • Author
    • #21346
      Max WidmaierMax Widmaier

      I am building out business processes for NexJ Finance and have been doing different tests to get a better feel for them and their mechanics. Currently, I am looking at section/page collections. I am trying to add all the values of a question within that collection. In my tests, I have a collection of sections which contain a assetName text field and assetValue currency field.

      What I am attempting to do is add all of the values of the estimated value question and output that into another currency field called netAssetValue. To do this I defined a helper (Defined as add-all) function, since it would seem that the foldr Scheme function is not defined as part of NexJ’s Scheme implementation. When referencing the assetValue field using @ section cAssets [Name of collection section] assetValue. I get this error: Undefined variable "this".

      Full code:

      I have also tried this:

      In this case, however, I get a different error when rendering the preview in the sandbox: Attempt to call a non-function.

      Where else would I define the add-all function? Further testing proves that add-all is defined and usable out of the scope of the (: ) expression. But if one were to reference other questions, sections, etc, one would get an error. If one uses that function within a (: ) expression, one gets a different error of that function being undefined.

      Is there an alternate method of referencing other questions that could be used? If not, is this type of data processing (iterating over a list from a collection) still possible through a different method?

    • #21530
      Shahzad Qureshishahzad.qureshi

      Apologies for a delay¬† in responding to this Max. We’ll be looking into it today.

    • #21555
      Sean ChungSean Chung

      I did brief investigation and found out that all the custom functions that can run on the client should be added bpclientutil.scm and add a compatible javascript function in .js as well.

      Also, current cpm doesn’t support getting all the answers from dynamic collection of sections.

      To access a property of an Object in collection section, “you can use the index to retrieve the answer, then invoke the name of the property to access it.
      For example, if you want to access address property of Telcom of the first instance in a (bp:objects telcoms) question, you can do (@ sectionName ‘(telcoms 0) address)”

Viewing 2 reply threads
  • You must be logged in to reply to this topic.