Redirecting to a destination stored in a variable

I have a form app that can be arrived at from various other apps (via links/ php buttons etc.)

So if you arrive at this app C from app A, clicking Exit should take you back to app A. If from app B, it should return to app B.

Does anyone have a tidy way of doing this?

First off, in Application => Navigation there is “Exit URL” but putting a variable here doesn’t work as it takes the value literally.

So in the calling apps I have a [comingfrom] global, which I’m trying to return to, set in App A and App B. Then in on AppInit of App C I have this

sc_url_exit("../[comingfrom]/[comingfrom].php");

However, the result of this is when it returns to the calling app (A or B) SC puts a new “Exit” button which was not in apps A or B before linking. So it ends up being quite confusing for users. Besides, I suppose its making the calling stack grow unnecessarily. I don’t want to resort to further hacks of checking if its a return and then hide the “Exit” on OnLoad event.

I’m hoping for a more elegant solution from anyone.

1 Like

I have solved this problem by removing default exit button in A and B and adding a custom exit button in the called app C than once pressed redirects to the calling app A or B

You can know the calling app by looking at php variable $_SERVER[‘HTTP_REFERER’]

The caveat of this approach is that if you have another app D calling C you need to modify the code in C to manage also this case.

Sounds great but if the referrer is generically in that PHP global, why is there a need to modify C at all?

C needs to know who the caller is in order to return to the caller when pressing exit