Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to get the index # of a comment inside iterateandprint function for comment field

jenni February 19, 2023

I would like to check if there is a way to get the index number of a certain comment. I'm trying to use the iterateandprint function to print all the comments in DESC fashion. However, I also want to print the index number of a certain comment to use as an Update #.

This is what I used: 


updatedDetails2=[entry.updatedDetails.sort(timestamp DESC).iterateAndPrint(<strong>Update [entry.content.asLength] - [entry.timestamp.formatDate]:</strong> [entry.content]<br><br>).renderAsHtml]

I'm trying to replace this [entry.content.asLength] to the index # of the comment. I have not found anything that works yet since Length counts the length of the text of the content and not the index #.

This one works [entry.updatedDetails.asLength] but only outside the iterateandprint function so it only returns the number of comments. e.g. 3 if there are currently 3 comments.

I'm trying to display all Updates in a comment so it prints like this:

Update 3 - Feb 15, 2023 02:46: Text
Update 2 - Feb 16, 2023 22:44: Text
Update 1 - Feb 16, 2023 22:42: Text

So the the sequence in the Update number is what I'm trying to retrieve via the index # of the comment field. So far I have not found any Virtual function in confiform that will help me retrieve the Index number of the comment.

I hope my question makes sense.

1 answer

0 votes
Alex Medved _ConfiForms_
Community Champion
February 19, 2023

Hi @jenni 

Your question does make sense, but this is currently not possible in ConfiForms

It does not keep the index of the element it prints out in the context for your to access

Alex

jenni February 19, 2023

Thanks for the response @Alex Medved _ConfiForms_. Would you have any suggestion on how I can probably get to print a series of numbers inside the IterateandPrint function for the Comment field to be able to display something like this?

 

Update 3 - Feb 15, 2023 02:46: Text
Update 2 - Feb 16, 2023 22:44: Text
Update 1 - Feb 16, 2023 22:42: Text

 

This already displays the format I want except for the number after the update.

updatedDetails2=[entry.updatedDetails.sort(timestamp DESC).iterateAndPrint(<strong>Update [entry.content.asLength] - [entry.timestamp.formatDate]:</strong> [entry.content]<br><br>).renderAsHtml]

Alex Medved _ConfiForms_
Community Champion
February 20, 2023

Index is not maintained when iterateAndPrint is applied.

So, there is nowhere to take it. Sorry

 

BTW, why do you need to copy data as you have and not using it directly?

I mean you can just have the full expression like that in the ConfiForms Field macro (field name parameter)

updatedDetails.sort(timestamp DESC).iterateAndPrint(<strong>Update [entry.content.asLength] - [entry.timestamp.formatDate]:</strong> [entry.content]<br><br>).renderAsHtml

It will be transformed for you realtime from the original field

Alex

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events