Redirect to different Sites/Tempo in Appian

Certified Lead Developer

Hi All,

We have a UI where we call a safe link to open an External UI in the same tab. This safe link can be triggered from multiple places in Appian (Sites or Tempo). A single user can have access to multiple sites or tempo from where they can trigger the safe link. Now on the External UI, we have to call a link (link will be sent to External UI using API) to navigate back to Appian from the original location, but the problem is we do not have the browser URL from where the user clicked the safe link from. So is there a way we can find out from which site/tempo was the safe link triggered?

Eg -
User is on Site A -> Triggers a process -> UI has safe link -> User clicks on Safe link -> Navigated to External Site
User is on Site B -> Triggers a process -> UI has safe link -> User clicks on Safe link -> Navigated to External Site

Now how do we know that the user was on Site A or Site B as in Sites we cannot add any parameters while calling any process

Note -> Same process is used in Site A and Site B

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    There would be no way to do this unless you could use slightly different links to the external site, and based on that, add logic to the external site to determine which Appian site link to show the user.  Otherwise, you should probably just decide that the users should expect to always be navigated back to Site A (for example) regardless of where they were when they went to the external link.

  • There actually is a potential solution that involves using a Web API to save the user's current location and redirect you to the correct place. However it is fairly complex - I'd only recommend using this if you're willing to devote the time to writing custom HTML to correctly insert data and redirect the user.

    You can see an example of how this works in the Dynamic Site Management application on the app market.

  • 0
    Appian Employee
    in reply to ekanshj

    What point are you trying to get the URL? Can you describe more what you have tried and what isn't working?

  • 0
    Certified Lead Developer
    in reply to Peter Lewis

    HI 
    I am not an expert in HTML but tried to do some things, the API is unable to read 'window.location.href' and insert the site URL from where this API is being called.
    Replacing the HTML function with a hard coded value works fine as expected, but with the function I am unable to get the URL for the page from where the API is triggered (UI).  

    a!localVariables(
      local!hostURL: rule!APN_getSiteUrl(),
      a!httpResponse(
        statusCode: 200,
        headers: {
          a!httpHeader(
            name: "Content-Type",
            value: "text/html"
          ), 
          a!httpHeader(
            name: "X-Frame-Options",
            value: null
          )
        },
        body: "
    <html>
    <body>
    <script>
    
    fetch(
    `" & local!hostURL & "webapi/653cWA?site="&"`&window.location.href,
    {
    method: `POST`,
    credentials: `include`,
    headers: { 'Content-Type': 'application/json' }
    }
    ).then(response => {
    window.location = `" & local!hostURL & "sites/xxxxxxxxx"&"`
    }).catch(function (err) {
    console.error(err);
    });
    </script>
    </body>
    </html>"
      )
    )

  • 0
    Appian Employee
    in reply to ekanshj

    I'm sorry, I'm don't know much about HTML either. Is it possible that hard-coding could be a viable solution? If you have different interfaces on each site, you could hard-code the current URL on each of those sites for when you launch the link.

  • 0
    Certified Lead Developer
    in reply to Peter Lewis

    Hardcoding will not work in my case as the UI is same.
    But anyways thanks for all your help, will keep looking and see I can find something.

  • 0
    Certified Lead Developer
    in reply to ekanshj
    Hardcoding will not work in my case as the UI is same.

    Can you expand on this?  You could make each different site show a different version of the external URL even if you otherwise use the same interface for both.  I don't exactly see how you stop at it "will not work".

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt


    The problem is I am building this external link inside a UI which is part of a action link in record dashboard, so basically the summary page of the record has multiple action links and one of the action is calling this UI which has an external link and this record is being called in multiple places, so there is no way for me in the current scenario where I can pass the site sub/url from site/tempo to my UI to identify the starting point of the same. Also the users have access to multiple sites, so they can navigate from the menu bar to different site (without any action so cannot tract where the user is actually).

    Also the application size is huge to consider changing all the sites and the places used by the objects.
    I have not given up yet to find a solution, but the approach of hardcoding is something I cannot use because of multiple reasons.

  • I believe part of the issue is that the interface is sometimes called from an Action in Sites, which does not accept input parameters - is that correct?

    Otherwise you may have to create wrapper process models for each site action, that would know the URL based on which process model was called - those wrapper processes can call your main process asynchronously with an input for URL.

    For the Tempo calls, you can add a parameter for the URL to the link interface, but the call to the interface (URL param) would have to be hard coded differently based on where it is exposed.

    +1 for it would be a great help to be able to obtain the full URL from any interface.  Have a few use cases for that myself.

  • 0
    Certified Lead Developer
    in reply to ekanshj
    I am building this external link inside a UI which is part of a action link in record dashboard, so basically the summary page of the record has multiple action links and one of the action is calling this UI which has an external link and this record is being called in multiple places

    so add a parameter to your interfaces and processes called "siteContext".  Have unique interfaces for SiteA and SiteB, where each of them calls the same sub-interface, each passing in its own site unique identifier for "siteContext".  Pass this value around and use it to determine the external URL you show.

  • 0
    Certified Lead Developer
    in reply to Chris
    +1 for it would be a great help to be able to obtain the full URL from any interface.  Have a few use cases for that myself.

    I'd pay cash-money for a new function like a!getCurrentSite() - it seems unreasonable that there's no way of doing this without ridonkulous workarounds.

  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    Correct can be done but the problem as I said is modifying huge amount of objects that have been created over a period of 4-5 years.
    Multiple factors come in picture when we are working on an existing applications and the timelines are tight.
    I was mainly looking for a direct approach for now rather than modifying all my site applications with a static UI for each site.

    Anyways thanks for all your help, will let know how it all comes out. Firstly will try to see if I can make WebApi work.

Reply
  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    Correct can be done but the problem as I said is modifying huge amount of objects that have been created over a period of 4-5 years.
    Multiple factors come in picture when we are working on an existing applications and the timelines are tight.
    I was mainly looking for a direct approach for now rather than modifying all my site applications with a static UI for each site.

    Anyways thanks for all your help, will let know how it all comes out. Firstly will try to see if I can make WebApi work.

Children
  • 0
    Certified Lead Developer
    in reply to ekanshj

    I understand about needing to modify a huge number of objects.  But I want to clarify with respect to "static UI for each site" -- this is rather easy to sidestep by establishing a structure where (only) the top-level interface for a particular site page is unique, and inside that all it does is call the shared interface in question, in doing so passing in a parameter identifying the site; this can of course then be used for other interfaces and/or on-page start process links, etc. 

    You also wouldn't need to modify *all* such places at once, but rather cherrypick the few most important (the ones directly up-line from the external URL you want to generate) and go from there.  In case any of that makes this approach more feasible for you.  If it's a big established system you're trying to modify I know that's quite a bit more of a lift than if it's a newer system under development of course.