on ‎2021 Aug 11 10:14 AM
Hello everyone,
I got a problem with the setUserInput function. I want to change a table cell with a dropdown. For example, when I select a cell, a new popup will appear with a dropdown. When I select an entry in the dropdown menu it will update the cell. To be exact, there is a cell with an employee name and when I click on the cell, a popup will appear with a dropdown with different employee names. I can choose an employee name and it will change the cell with the selected name.
Now I got a problem with the setUserInput function which gives me an error everytime I call it:

Here is my script for the Popup button which will call the setUserInput function:
//Popup
if (buttonId === "button1"){
var selection = Table_2.getSelections()[0];
var planning = Table_2.getPlanning();
var dropDownKey = dd_Popup_Table_2_selection_employee.getSelectedKey();
planning.setUserInput(selection, dropDownKey);
planning.submitData();
Popup_Table_2_selection.close();
}else{
Popup_Table_2_selection.close();
}
I already checked the dropdown key. It returns a string with an employee name. When I parse a string directly as an argument in the function the error still appears:
planning.setUserInput(selection, "test");
My assumption is that the error is cause by a wrong selection.
Is there a solution for this problem? I would appreciate a feedback, thanks!
Best Regards,
Ben
Request clarification before answering.
Hi,
There are two way to get a solution.
1st and easy way is to use a data action and change the data in table and update the data in model.
2nd is by coding
please follow the below step.
if(buttonId ==="button1"){
var selection= Table_2.getSelections()[0];
var planning = Table_2.getPlanning();
var dropDownKey = dd_Popup_Table_2_selection_employee.getSelectedKey();
var result = Table_2.getdatasource.getresultset(selection);
//below code is use to save the save the value which existing value it has.
var val = result[0]["@measuredimension"].rawvalue;
//below code will remove the old record where value was assign
planning.setUserInput(selection, "");
planning.submitData();
// below code will change the employee # -> new employee code. and assign the existing value it was
having in it.
selection["Employee"] = dropDownKey;
planning.setUserInput(selection, val);
planning.submitData();Please try the above code.
Thanks,
Saurabh S.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It was possible to change the measure with this above-mentioned method.
- Can you please explain in detail
how can I change the name of an employee? Is it possible?
- selection["Employee"] = dropDownKey;
The above code will change the name of employee ( with will change from old name to new name )
Or should I look into data actions?
I would suggest if your looking to change in all the measure associate with that row then go with the data action only.
Thanks,
Saurabh S.
Hi,
this is my assumption when your changing the value of employee the salary value will also be there in table?
second assumption that current in table the employee is # and you want to change/assign it with the employee dropdown?
can you please confirm on above assumption!
Thanks,
Saurabh S.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Saurabh,
you are absolutely correct. I want to change or add an employee to a cell. Also when the cell is # I want to add an employee. Salary or costs should change with the employee.
I tried your suggestion with the updateMemeber API but I don't know how to parse a selection as an argument to the function yet.
Thanks and best regeards
Ben
Hi,
Can you please explain the below point in detail.
Salary or costs should change with the employee.
Thanks,
Saurabh S.
One more Q,
when you change the Employee from # to new for E1, do you want to keep same value (salary /cost same for new E1) or user will update a new value ? for each new employee added in table.
Thanks,
Saurabh S.
Dear Saurabh,
here is an example:
There are traveling expenses, but no employee assigned to it yet. Now I would like to assign E1 to the traveling expenses. So I click on the row with traveling expenses and change the employee cell from # to E1. This also should update the model.
I think first, it is enough when the user can update the value for salary/cost manually. For me the most important part is to update this particular table cell, so it also changed in the model.
If I use the updateMembers API, will it update all members? For example when I change E1 to E2, will it change all the E1 to E2 in the whole table or just this particular cell?
Thanks,
Ben
My understanding is that the setUserInput is used to update a measurement with a number not a string value corresponding to a dimension property (such as employee), thus it does not work with a "test" string.
You can, may be, alternative use filters to achieve what you are looking for.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.