Home › Forums › Development › Business Processes – running function on value of question(s)
Tagged: Business Process, Scheme
- This topic has 2 replies, 3 voices, and was last updated 1 year, 10 months ago by Sean Chung.
-
AuthorPosts
-
-
January 4, 2023 at 10:46 pm #21346Max WidmaierParticipant
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:
Scheme123456(bp:text netAssetValue(: caption "Net Asset Value")(: enabled #f)(add-all (@ section cAssets assetValue)) ; In this case add-all adds all values; in the list then returns "(: value val)")I have also tried this:
Scheme123456(bp:text netAssetValue(: caption "Net Asset Value")(: enabled #f)(: value (add-all (@ section cAssets assetValue))) ; In this case add-all simply; the calculated value)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?
0 -
January 18, 2023 at 11:13 am #21530shahzad.qureshiKeymaster
Apologies for a delay in responding to this Max. We’ll be looking into it today.
0 -
January 20, 2023 at 3:39 pm #21555Sean ChungParticipant
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)”0
-
-
AuthorPosts
- You must be logged in to reply to this topic.