cancel
Showing results for 
Search instead for 
Did you mean: 

Populate field1 in table, based on dropdown value of a field2 in same row

Former Member
0 Kudos

Hi Experts,

I have created an offline interactive Adobe form and need help with java-script on events. I will describe my scenario below -

I have written an SE38 report program which will generate the PDF. To pre-populate fields in the PDF, I have a structure Default_Values which has a few internal tables. One of the internal tables Employees has 2 fields Emp_Code and Emp_Name. I have written code to obtain a list of employees and populate this internal table Empoyees. I call the Adobe form and along with other parameters, pass this structure Default_Values. Thus all the default values along with the internal table Employees pre-populated with the Employee Code and Employee Names have been passed to the Context.

In the Adobe form I have a table with 10 lines with Employee details (6 columns, 2 of which are Emp_Code and Emp_Name)

In this table control, the column Employee Name is a drop down list. For this column, under List Items, I have created a binding to the internal table Employees with default values. This binding Items looks like this - $record.DEFAULT_VALUES.EMPLOYEES.DATA[*] with Item Text and Item Value having the value EMP_NAME.

When I test the form, I can see all the Employee Names in the drop down list in the column Employee Name of the table control.

My requirement is that when a user selects an Employee Name from the drop-down list, the field Emp_Code for that row in the table control should be automatically populated with the corresponding value of Emp_Code depending on the Emp_Name which the user has selected.

I am new to Java-scripts and Adobe forms. I have searched this and other forums, however I couldn't find the right code which I can place in either the Change or Exit event of the drop-down to accomplish this.

Can someone please provide me with sample code to achieve this.

Any help will be greatly appreciated.

Thanks in advance.

Regards,

Neha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Neha,

I hope you have the stand alone non SAP flavour of Adobe LiveCycle Designer 9 installed locally.

If yes, please follow the following post -

[http://forums.adobe.com/message/2481839#2481839]

It has a sample solution attached - you will probably do a similar thing.

Because you probably shall have more data - it makes sense to have some sort of an hidden table with the Employee Name and Employee Code in it. While using Java scripting, convert the hidden table entries into 2 - D array and try to change the Employee ID drop down based on change of Employee Name Drop Down.

Let me know of your progress.

Regards,

Rohit

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Neha,

What you need to do is :

make both of the fields as drop down list.

Then on exit event(javascript) of EMP_NAME put

j=xfa.form.form name.subform name.Emp_Name.selectedIndex;

xfa.form.form name.subform name.Emp_Code.selectedIndex = j ;

Hope this will help.

Regards,

Subhasish

Former Member
0 Kudos

Thanks All.

I eventually implemented a workaround to fix this. I changed the binding for the drop down with Item Text having the value EMP_NAME and Item Value having the value EMP_CODE. This way the drop-down shows the Employees Name, however in the background its value is actually the Employee Code.

In the exit event of the dropdown I pass the rawvalue() of this field to the Emp_Code field, hence populating it.

Regards,

Neha

Former Member
0 Kudos

Hi Neha,

Yea that can be done but there you have to give the values as well as the corresponding texts manually.Otherwise its ok.

Regards

Subhasish

Former Member
0 Kudos

HI Neha ,

I am new to Java script..

I am also facing a problem like i have material description(MAKTX) as drop down on the form. when the user wants to change the material description(MAKTX) need to change the corresponding Unit of measure(MEINS) and Standard packing(UMREN).

Please can you help me for this..

Regards

Krish

Former Member
0 Kudos

Hi Rohit,

Thanks for this. I downloaded the standalone version of LiveCycle Designer and could view the code. This is very useful.

I have another issue though. The code in this example is using a 2d array. All the values have been hard-coded in this list. My data is however dynamic and comes from the calling program.

If I can convert the array with fixed data into a dynamic one with data being read from the tables in the context, I can re-use the rest of the code with alterations to suit my requirement.

Any idea of how I can integrate this code with the data from the Context.

Regards,

Neha

Former Member
0 Kudos

Hello,

You can read values from your node in dataview and populate your dropdown.

Refer to the post

Thanks & Rehards,

Omkar Mirvankar

Former Member
0 Kudos

Hi Neha,

I would prefer not to use FormCalc for this requirement.

Array Processing shall be done in Java Scripting and you simply cannot have two different scripting language elements in the same scripting block.

First create a table type parameter in the interface or GT_* type in Global variable and pass all the necessary entries of dropdown to the table type parameter. Once included in the context it shall be available in your data view of the form.

To access any repeating instance node of the form in the data view, use te following script -

var theFields = xfa.resolveNodes( 
                  "xfa.datasets.data.data.CUSTOMERS.DATA[*].NAME");

assuming that you have a table named CUSTOMERS in the Data View.

For more details on XFA Data Model refer to

[http://help.adobe.com/en_US/livecycle/es/lcdesigner_scripting_reference.pdf]

Hope these inputs help.

Regards,

Rohit

Former Member
0 Kudos

HI Rohit ,

I am new to Java script..

I am also facing a problem like i have material description(MAKTX) as drop down on the form. when the user wants to change the material description(MAKTX) need to change the corresponding Unit of measure(MEINS) and Standard packing(UMREN).

Please can you help me for this..

Regards

Krish

Former Member
0 Kudos

Hi Rohit,

Thanks for your reply.

I have Adobe LiveCycle Designer version 8 on my machine. Do I need to upgrade to version 9?

I went through the link you sent me, however when I import the sample form into SAP, I can't see the context or binding for these drop-downs. I had a look at the javascript behind the combo box, there are statements like - countryScript.getStatesOther(xfa, stateProv);

I don't have such methods or scripts written in my scenario, any pointers on sample code or how can I get this to work.

Regards,

Neha

Former Member
0 Kudos

Hi Neha,

Basically there are two flavors of Adobe LiveCycle Designer - one that you have in your system downloaded and installed from SAP service marketplace. The other one is from Adobe.com using the following link -

[http://www.adobe.com/cfusion/tdrc/index.cfm?product=livecycle_designer]

Install the trial version and open the sample form (you saw in the forum) in the trial version of LiveCycle Designer.

Follow the scripting and let me know if you have any issues.

Regards,

Rohit