If the Apex Add button doesn’t do the job, because of other data lookups needed, etc, I want to use the existing detail page as the Add page as well.
I understand that a page with the primary BO having read automatically will created a record in memory.
So on the launching page, I can have a button, but what’s the ‘right’ way to call another existing page? I shouldn’t have to create an instance first…but the standard:
this.router.navigateByUrl(‘/admin/meUsRoles/’ + meUsRole.id);
doesn’t work since I don’t have a new id value to pass along…?
If you want to have the user enter all the data and be able to cancel without creating, you can create a page where the business object you are editing is set to read on demand and save on demand. Then just add a cancel button that navigates them back to where they came from and a save button that does something like:
await this.myNewObject.save();
// this.myNewObject now has an id and you can navigate to wherever you want.
If you set the business object to save automatically, it will create the object as soon as the first information is entered.
If you really want to re-use your normal edit page, you could try something like setting the id to 0 or -1. In that case, you should probably use a separate property in the path
/myObj/:myObjId
vs
/myObj/:myObj.id
Your initialize method could then examine the value of this.myObjId and decide if the object needs to be read.