It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to autopopulate data in confiforms

I have built a confiform and now I want to autopopulate data in some field by using my database by seeing which user is logged in for e.g. , I would not want the user to enter his name and instead get his name by using the current logged in user. Please tell me how to go forward with this.

3 answers

1 accepted

2 votes
Answer accepted
Davin Studer Community Leader Jun 14, 2016

In the ConfiForms Registration Control macro there is a field for setting default values. See the below screenshot.

image2016-6-14 11:54:27.png

Thanks It works this way.

But if I try to use  "user.fullName" with default value by making my Name field as Readonly . This does not work.

And also where did you get this command user.fullName . Can you provide me a link to its documentation.

Thanks

Davin Studer Community Leader Jun 15, 2016

Readonly should work. I have a form with a field called lastEditedBy that is a readonly and it populates the current user when the entry is created or edited. The ConfiForms documentation link is below. It is on that page. Do a page search for [user.fullName] and you should find it. Second link is also a good one for knowing how to access a field and its properties.

https://wiki.vertuna.com/display/CONFIFORMS/Documentation

https://wiki.vertuna.com/display/CONFIFORMS/Accessing+field+values+and+properties

The answer depends on your goal for wanting to auto-populate the field.

If the goal is to auto-populate the field so that the user cannot override the value (a read-only field), then
define the field as either a Calculated field-type, or a Formula.   The difference is that a Calculated field is populated once at registration time, and a Formula is re-calculated every time the user updates the record.

If the goal is that the field is auto-populated with a default value, which the user can then override, then yes, Davin's answer is correct -- you can configure the Registration Controls macro to pre-populate one or multiple fields at registration time.  However, if you display the Registration Controls in several places (e.g. on different pages), then you need to remember to configure the Registration Controls each time.

An alternative is to add a Field Definition Rule in the form itself. I believe the trick is to give it the Condition id:[empty], which only executes at registration time (because that's the only time the id is empty).  The advantage here is that this is defined in the form itself, rather than in the Registration Controls, which may be one less thing to worry about if you're putting Registration Controls in several places (like different pages). 

These last two alternatives are explained on https://wiki.vertuna.com/display/TEST/Form+with+default+values+set+by+Field+def+rules+and+by+registration+control

Finally, if your goal is to auto-populate a field for multiple records that have already been created -- e.g. if you add a field later, after people have already entered data -- then you need to run the REST API update.action to batch-update the field on multiple records.  This is necessary even for Calculated or Formula fields, as those only get calculated at registration time, or when the user updates the record.  The caveat I would add is to test this on test data first.  I've found that the REST API is very reliable, but if you make a mistake in the syntax, you could end up overriding some data you want to keep.

The REST API is described on https://wiki.vertuna.com/display/CONFIFORMS/REST+API

0 votes
Davin Studer Community Leader Jun 14, 2016

If you are using ConfiForms then you are not using Confluence Cloud, so your question should not be tagged as such.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Introducing Confluence Cloud and Jira Software Cloud Premium

Wherever you are in your team’s journey , our goal is to support your big ambitions. We’re a cloud-first company with the mission of unleashing the potential of every team, and to address the range ...

600 views 4 17
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you