Skip to content
+1-888-319-3663

COMMUNITY FORUM

count function

Vic Manfredi asked 6 years ago
I need to count the line items in an order I am exporting to xml. I do not see the count function in the list of functions. How can I accomplish this?
Answers
Patrick Roth Staff answered 6 years ago
Vic,
SC processes each line of data one by one.  So meaning that as it reads record #1 for a document, it doesn’t know how many there will be.  And of course, we can reject individual records in the mapping so even the number of rows of raw data might not make it to the document.
The only way to do this is to count them yourself.
The only script that runs for _every_ record is the “Restrictions” script on a node.  So in that node, you would use a global variable and increment it as you count your own lines for that mapping row.  Then in the “header” row, make a calculation that returns that global which would be the line count.
I suppose the other way you could do it, since you say that you are exporting to an XML file, is use an after document or after map script.
In it, you’d read the XML file generated by SmartConnect.  Find the node in question and count the child records for it.  Then set the property you wish and re-save the document.
Seems like a lot of extra work though doing it this way.
patrick
 

If you would like to submit an answer or comment, please sign in to the eOne portal.