Reset form controller in ui builder

angeloorteg
Tera Contributor

 

Hi everyone.

 

I have a modal with a form using a form controller .

 

After saving (create) the first time - it is linked to this record, no matter what I do.

 

The isNew flag of the form controller remains false from that moment on...

 

I tried resetting the sysId, reloading the form, refreshing it - it will stay in this state unless I refresh the page.

 

I want it to be a create modal only …

I appreciate any help, need to get this fixed since people might not notice that they are updating the previously created record 😕

 

If you need screenshots or any more information let me know - I am really lost rn

2 REPLIES 2

angeloorteg
Tera Contributor

--- delete

angeloorteg
Tera Contributor

UPDATE

 

I made it partially work. 


I have a client var newRecordId = -1  to tell the form I want to create a new record.

Once a record is created, I tried to setting it back to -1 but it didnt quite fire an event change.


So what I do now, on after create on [Form Completed] Event I set it to the newly created sysId, and then on [Modal close] Event I set it back to -1. 

This triggers an event change and isNew-Flag is back to true.

 

The problem now is, it works on first creation and seems to be okay ( but throws a canvas error in console ).
On the second creation it will open a blank page. Both are created. 
Why that? The first console error states thats it cant find a value for generating the route to navigate to. 
The second creation then, seems to be using a fallback route opening a blank page. 

So how to fix that?
I created a new UI Action, hoping that I can save and close the modal as intended :

current.insert();
action.setRedirectURL(current);
gs.include('ActionUtils');
var au = new ActionUtils();
au.postInsert(current);


Now - a new Problem - the errors in console are gone, and the blank page is a real record opening within the same tab. 
So basically it works fine now - but navigates me away from the parent form where I want to use the Create Button to open the modal n-times and create more records. 


Is there a way to prevent it from navigating away from that page - or maybe to at least open the record in a new tab? ( Probably hard, because the modal is part of the current page)

I just want to have a modal with a form and formcontroller to create new appointments,  never update them in the form and never be redirected anywhere, just close the modal after creation.

Help