29
Views
9
Comments
Solved
Struggling with basic concepts with regards to variables, lists and for each loops
Application Type
Reactive

I'm attempting to modify the stock Appointment template to allow you to select multiple doctors/faculty at one time.  The stock template allows for only choice.  Then, the user needs to be able to submit the 1 or more selected doctors to write them to a db table.  Again, it works for the 1 doctor but not multiple.  I'd like to include the OML....but will that expose any of the real faculty/doctor data I may be using for test purposes?


--Rick


Solution
  • make a server action that takes in a list
  • inside that server action forEach over the list and do your database actions
  • those names don't really seem helpfull, i would try to make sure the selected list also contains the id's
  • it is possible to share an oml without sharing the data, unless you also have used excels to bootstrap data, or have in some way hardcoded data, we will not see any of your data
  • Nontheless, you would still reveal all of your business logic and design, that might not be a good idea
  • A typical thing to do is to make a separate demo oml, with little or no dependencies
    • easer on the other forum members, as they don't have to search for the screen / action 
    • safer for your business, not revealing anything you don't want to
    • could even help you solve the problem, as you could have a eureka moment while making it

Dorine

Hi ,Richard Dwyer

Take a reference from this post ...

https://www.outsystems.com/forums/discussion/86750/one-to-many-forms/#Post366593

Hope it help you .

Kind regards ,

Kundan Chauhan

Thanks but I don't know if that thread addresses my concerns.  How do I find someone who can either do a screenshare or look at my files to tell me what I need to do to get the this solution working as it should?

To clarify, I'm trying to push multiple selections to the database.  The first screenshot below shows that I've selected 2 names from a list on the left and clicked the "Add" button push them to a list on the right.




The function I call to move them with the "Add" button looks like this...note in debugger I can see the names I have selected:


Finally, I want to call a server script to push the names to the table which the script below attempts to do.  I know there are at least two issues with what I have below.  First, if I pick 3 names it will iterate and push the first name only 3 times to the table so it's not actually passing the other names in the variable.  Next, call a server side script 3 times is not optimal as I should pass all three names to it once and have the server side script upload the list all at once.


How do I push the 3 names shown in the debug code above to the table?


Screen Shot 2023-08-31 at 8.42.43 AM.png
Solution
  • make a server action that takes in a list
  • inside that server action forEach over the list and do your database actions
  • those names don't really seem helpfull, i would try to make sure the selected list also contains the id's
  • it is possible to share an oml without sharing the data, unless you also have used excels to bootstrap data, or have in some way hardcoded data, we will not see any of your data
  • Nontheless, you would still reveal all of your business logic and design, that might not be a good idea
  • A typical thing to do is to make a separate demo oml, with little or no dependencies
    • easer on the other forum members, as they don't have to search for the screen / action 
    • safer for your business, not revealing anything you don't want to
    • could even help you solve the problem, as you could have a eureka moment while making it

Dorine

Thanks for the reply.

So my "ConfirmOnClick" would change to call a server action called "PostFacultyIDsToDB"....or something like that...

That newly created server action gets an input parameter of labeled "ListIn" added to it.

When I go back to my "ConfirmOnClick" flow I can see the call to new server action wants a value in the "ListIn" drop down:


I assume I'm passing into that the variable I set earlier called "NewSelectedFacultyVariable", correct?  When I do, I get a mismatch...and indication it's looking for a variable that is set to text:



Why would it reject my variable setup to handle the list of names?


Also, thank you for clarifying on the OML.   Good to know.

your variables have to match in type, to be able to pass them.  So your ListIn should be of the same datatype as your local list where you are accumulating the selected faculties. 

Just calling it ListIn doesn't make it a list yet.

Can you show both ?

I see.  I think that portion is now sorted as both types match and there error is gone:


Now I need to pass my For Each loop that list:


Then for my server action I need to call the default CRUD scripts that were created...but I cannot see them from this module....and dependencies have been updated.  The right side is the server script I assume I should call to push changes to the DB.  Left side is where I need to call it.

Why can consumer module call a script on the producer module?








As you said in your title, these are all very basic questions, and the learning modules explain all this in a much better way than I could. 

I would look at something like the learning path for reactive developer

Thanks so far.  I have what I'm hoping is my last question.  Currently I have my solution now updating the table in the producer module utilizing a procedure that stores the selected values in the variable.  Then further on, I write these values to the DB successfully.  The last piece for me is to be able to call this ListItemOnClick script each time the user presses a button to select this individual and have the new individual appended to the variable as opposed to overwriting previously selected values.   I want to write "Peter", "Paul" and "Mary" to my variable and then pass that to the producer module where I will loop the 3 records, writing them to the table.

What am I missing here? 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.