Count items in Infopath field

299 Views Asked by At

I created a form in Infopath with a rich text box field. The field is used to keep a list of usernames (first and last). I want to be able to keep a of count each entry and keep a tally. I then want to use that total # of entries to add or subtract from other fields. Is there any way to do that?

1

There are 1 best solutions below

1
Overhaul Paul On

Is the rich text box field just a large string? If so you could just use python's built in split function, and either split by ("\r\n"), or (","). Example:

u = "Bob, Michael, Jean"
x = u.split(",")

X will be a list of usernames. If you are using line breaks for each new username, then replace (",") with ("\r\n").

Now to count the items in a list you just need to iterate on the list you created with a for loop. Example:

b = 0
u = "Bob, Michael, Jean"
x = u.split(",")

for i in x:
    b += 1 // b will be the number of usernames