UI Builder - Component to create a new record within modal?

MrRodgers
Tera Contributor

Hi all,

 

I am trying to display a new record in a modal on UI Builder. I want the user to fill in this form. However, I can not identify which component I should select in order to show a new record for a fixed table? I'd appreciate any help. Thanks. 

 

UI Builder - Components.png

Screenshot of some of the UI Builder components.

4 REPLIES 4

AnirudhKumar
Mega Sage
Mega Sage

I just got this done. Here are steps with explanation:

 

Ingredients needed:

- A custom Modal (This would contain your new record form and a 'Submit' button)

- A Form component (We'll use this render your new record form with fields)

- A 'Submit' Button (The Form component doesn't come OOB with Save/Submit button , so we create ours)

- A 'New Record' Button (I added this to my page for demo. Clicking it would call the custom modal)

 

Steps:

 

1. Add a new Modal of Custom type

 

modal - snip 3.PNG

 

2. Inside the body of the Modal, add a Form component and a button component

Note: The Form component needs to use the Record form preset 

modal - snip 2.PNG 

 

3. Create a new Client State called newRecordSysId , with Type as Number and Initial Value as -1

 

modal - snip 4.PNG

4. Update the Data Resource Form Controller with a static table and SysId:

Note: A little patience is required at this step, the values might refuse to be updated, you gotta wait for the form to 'settle' and the pencil (Static input) icon to appear

 

Modal - snip 5.PNG

 

5. Next we add 2 events to the 'Submit' button on the Modal:

- Click on the Button -> Go to Events tab -> Click Add Event Handler -> Type 'Save' -> Pick [Form action] Save 

- Click on the Button -> Go to Events tab -> Click Add Event Handler -> Type 'Modal' -> Pick 'Open or close modal dialog' -> Select your modal from the dropdown, and keep the 'Open modal Dialog' toggle as false (This will ensure the popup is closed when you click the 'Submit' button)

 

modal - snip 6.PNG

 

6. Finally we tie the modal to the 'New Record' button:

 

Click on your 'New Record' button -> Go to Events tab -> Click Add Event Handler -> Select 'Open or close modal dialog

Modal snip - 1.PNG

 

Give it a try and let me know. It felt great making this work 🙂

Thank you very much for your help. This was great and I appreciate you taking the time. I am so close to getting this working now. The only part I'm stuck with is triggering it. I only want to show the modal on load of the page if the user has a specific role and they do not have a profile record in another table. However, I can't figure out how to limit the trigger to when these conditions are met. Trying to figure out how I can run a script to trigger it. Do you happen to have any ideas?

pankajComrade
Tera Contributor

Hi @AnirudhKumar I have implemented the mentioned steps and able to save record but when I try to open new record second time , then custom modal popup contains the recently save /created record. And Please give some reference about validation if i have  same required fields on form how can we prevent to save / close the modal.

Thanks

Facing the same issue, got any solution for this ? First time it opens up a new form but second time instead of opening a new form it opens us the existing record.