Table Values and Services

I have a form with a dropdown for Department and a table. Within the table I have a Category dropdown that is populated based on Department and a single line item (Code) that is based on Department and Category. I have used the following (HCL Leap Wiki Dynamic Dropdowns in a table) as a template to do most of what I wanted; however, the portion of populating the single line item is the issue. When I create a single table entry, the single line item is populated correctly. If I create x number more table entries, the Code will be based on the Department and last Category selected.

How do I get the Code single line item to not change for previous entered table rows?

Joshua, would it be possible for you to attach screen capture of what the issue is and maybe also post the code that you have so far ? That way everyone else should have a clear picture of what you wanted to achieve.

From the screenshot attached, if you select a category on the table form, the GL code will change for every for the current table entry and every previous entry. The Department field is on the main screen.

On the Department Field, I call a Service to Update the Expense Categories.

On the Temp Expense Category, I call a service to update the GL Code based on Department and Temp Expense Category.

On the Table Expense Category Field On Show event, I have the following javascript:

item.setOptions(app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempExpenseCategory.getOptions());

On the Table Expense Category Field OnItemChange event, I have the following javascript:

BO.F_GLCode.setValue('');
app.getForm('F_ExpenseForm').getBO().F_TempExpenseCategory.setValue(BOA.getValue());

On the Table OnShow event I have the following javascript:

if(BO.F_ExpenseCategory.getValue() !==''){
app.getForm('F_ExpenseForm').getBO().F_TempExpenseCategory.setValue(BO.F_ExpenseCategory.getValue()
);
}

//attach a listener to the temp dropdown and pass in my object
var srv = app.getForm('F_ExpenseForm').getServiceConfiguration('SC_GetGL_DeptExpCat');
srv.connectEvent("onCallFinished", function(success)
{
if(success) {
var j = BO.F_GLCode;
j.setValue(app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue());
app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue();


BO.F_GLCode.setValue(app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue());



}
});

If this cannot be resolved, I may switch to option 2. HCL Leap Manipulate Table

Any help would be greatly appreciated.

First of all, looking at the picture I am going to assume that when the + icon on Travel and Entertainment Expenditure is clicked, the Add Entry subform will popup. If you then fill this popup and click Add, those value will be added back to the table. Please correct me if that assumption is wrong.

Is there anything setup on the Table Display ? Since you put in a bunch of code that refer to Table I just wanted to make sure that you did not accidentally select the wrong element. So far it seemed that your code should only run on the Table entry sub-form.

Please also double check the service call that you setup to make sure that it write to the correct element.

You could also try to simplify the logic to test that it work before adding it up. For example first test without the service call (using hardcoded options) and see if the table population works properly.

You are correct about clicking + and the subform opening, fill the popup and clicking add to add back to the table.

The services are setup correctly and pointed to the correct fields.

I do have Table OnShow event with the following:

if(BO.F_ExpenseCategory.getValue() !==''){

app.getForm('F_ExpenseForm').getBO().F_TempExpenseCategory.setValue(BO.F_ExpenseCategory.getValue()

);

}

//attach a listener to the temp dropdown and pass in my object

var srv = app.getForm('F_ExpenseForm').getServiceConfiguration('SC_GetGL_DeptExpCat');

srv.connectEvent("onCallFinished", function(success)

{

if(success) {

var j = BO.F_GLCode;

j.setValue(app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue());

app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue();

BO.F_GLCode.setValue(app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue());

}

});

If I remove the above code, the form and subform populate accordingly except for the GL code on the Subform/Table. Adding the code above back to the Table OnShow event, the GL code will populate, but any table entries already created will update with the latest GL code. Correct example would be:

With Department = Assembly, then Expense Category = Company Car > GL Code = 55461, Expense Category = Meals > GL Code = 55210, Expense Category = Transportation > GL Code = 55200.

But what I am getting is as follows: Department = Assembly, then Expense Category = Company Car > GL Code = 55200, Expense Category = Meals > GL Code = 55200, Expense Category = Transportation > GL Code = 55200.

When are you calling the service? When the user selects an expense category does that call the service to retrieve the code? If you are calling the service in the onShow of the table (i.e. add/edit a row), then that is creating a listener every time and those listeners remain active and are re-run every time a category is selected. In this case, I suspect that you need to disconnect the listener after it runs. So the modified code looks something like this:

var srv = app.getForm('F_ExpenseForm').getServiceConfiguration('SC_GetGL_DeptExpCat');
var hdl = srv.connectEvent("onCallFinished", function(success) //modified line
{
if(success) {
var j = BO.F_GLCode;
j.setValue(app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue());
app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue();
BO.F_GLCode.setValue(app.getForm('F_ExpenseForm').getPage('P_ExpensePage').F_TempGLCode.getValue());
}

srv.disconnectEvent(hdl); //new line
});

Give this a try and let us know the result. If the issue is still occurring then I may ask you to send me your .volt file.

Disconnecting the listener corrected my issue.

I was calling the service on the onShow event of the table.

Thanks.