Auto populate text field




I am making a form in live cycle designer. I have text field named "ID" another two fields are named as "Name" and "Dept".

I am trying to do, If a person enter his/her ID no. in "ID" field, automatically that person's name and department will be populated in respective field.

As I have very little knowledge in livecycle, any help from the community would be great.


Accepted Solutions (1)

Accepted Solutions (1)




There are a few ways you could achieve this.

The simplest is just hard coding it into the ID Exit event using a switch or if statement. When you have a new ID though, you would have to update the form.

Example using switch on ID exit event Javascript

//clear these fields first. If the logic condition is not met, these fields will then be blank.
Name.rawValue = null;
Dept.rawValue = null;

case "1":
Name.rawValue = "Duncan";
Dept.rawValue = "R & D";

case "2":
Name.rawValue = "Ron";
Dept.rawValue = "Firmware";

//enter code here to execute if the above conditions are not met."ID Not Found!");


This could also be achieved by connecting a database but i can't help you there.



You can, however, have an in form database of sorts. I have done this in the past.

I have hidden text fields to 'store' the details i want to refer to.

For example: you might have 10 ID, Name and Dept storage fields that are hidden. You would also need a dialog for 'saving' the items into the form. The form itself still needs to be saved to actually save the data.

You would need a button to invoke the adding dialog and a button for saving. The save button would check if there is a free space in your storage fields and save it if there is. You might need to add code to see if an ID is available too.

The exit event code in the ID field would need to check what is in the field compared to what is in storage and return the correct field rawValues when a match is found. It sounds a little complex but in practice it is quite simple....but in this case it would depend how many IDs there are. It could become a quite large code.



Answers (0)