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 Champion 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 Champion 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

0 votes
Davin Studer Community Champion Jun 14, 2016

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

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

467 views 2 13
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you