Can't get dynamic inputs to save.
I have made a script that will get some values from a template via API and insert them into an activity. However, when I click save none of the dynamic input has been saved. however, if I run the script again and this time make a manual change to the fields (type an extra character, even just insert a space), it will save the fields that were manually altered. Any ideas?
Best Answer
-
Brett_Moffett Cireson PACE Super IT Monkey ✭✭✭✭✭
Hi @Eric_Evans
It looks to me, without testing the code in my lab, that you are setting the values on the HTML of the page rather than setting the pageForm.viewModel in the background that has the data that the save and apply button use to write to the database.
You can write directly to the viewModel by using a command llike:
var vm = pageForm.viewModel;
vm.set('title', 'New title');
1
Answers
A bit more context.... I have altered the Manual Activity html to include a dropdown for "Templates" (see Screenshot)
Once a template is selected, I have a listener on the drop down that will fire off a script (example below) that will grab the selected value and traverse the MA templates to find one that has the selected value's name. Once it finds the selected value, another API call is made to get the field values set in the template and adds them to the activity. However the problem comes when I try to save (see initial post)
Hi @Eric_Evans
It looks to me, without testing the code in my lab, that you are setting the values on the HTML of the page rather than setting the pageForm.viewModel in the background that has the data that the save and apply button use to write to the database.
You can write directly to the viewModel by using a command llike:
var vm = pageForm.viewModel;
vm.set('title', 'New title');
@Brett_Moffett I absolutely cannot thank you enough! I was able to get it to work, and plan to show it once I clean up my code.