Hello,
I would have a entity Company and another entity Contacts. They have a one-to-many relationship. Currently, if I would like to add multiple contacts for a company, I would have to submit the form multiple times. I am wondering, is there a way for me to add multiple contacts in a single screen without having to submit the form multiple times. Thank you!
Hi @Low Nico,
Sharing the oml in which there is a screen CompanyDetail which can create company with multiple contacts. What we are doing here is storing the list of contacts in the local list and looping over the list at final save action for same companyId. Another screen Companies to show list of companies with their contacts.Also check the Demo here.RegardsKrishnanand Pathak
Thank you for this sample oml. It was really helpful. When trying out the demo, after adding the different contacts, when I go back to view the details, the contacts names arent shown. Is there a way save it? Also the oml seems to be private and I cant seem to access it after publishing it, any suggestion on that too? Thank you so much for your help!
Hi @Low Nico, The reason you can't find the OML might be because it is in Independent Modules. As you do not have an application associated with the OML, look for it in the Independent Modules or try the Search Modules button on the left side of the Applications Page in Service Studio.
Check the module inside the Independent modules with module name Com as shown below:After adding all the contacts & company name then press the Save button it redirect you to the companies screen. There you would see the added company and their contacts.
As I can see there are two companies. I think second one is yours.
That is right, I added the second company. What I am asking is, when I click Project ABC to view the details, I get:
Would it be possible to view the different contacts in this screen too? Thank you!
Would it be possible for you to update your oml so that this is possible? I tried your earlier suggestion but couldnt achieve it. Thank you so much for your help on this !
Sure, Sharing the updated oml.Demo is also updated.
Thank you so much for taking the time to help me with this. I really appreciate it!
Hi @Low Nico, I am adding an OML; please see if it helps. What I have done is create a screen where I have a local variable of list of contact types and a local variable of contact types. On the screen, I have a table that shows data of local list and a button to add data to the list, and one more button to save the data of the list to the database with a for each loop.You should follow best practice this is just to give you an idea.ThanksGitansh Anand
Thank you for your sample oml! I have a idea on how to approach this now. When testing the sample oml, I noticed that the name of the contact isnt saved in the database. It creates new entries but the contact name isnt saved. Any reason for that? Thank you so much!
Hi @Low Nico, I accidentally assigned the wrong value in the create action. I am adding the updated OML; please look at it.ThanksGitansh Anand
Thank you for your help on this. I have a better idea on how to do this now!