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

  • 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
    Certified Lead Developer
    in reply to Peter Lewis

    Hi
    Thanks for your response.
    The main problem that I am currently facing is to get the URL for the site, with HTML also getting the current URL for site is something that I am not able to achieve.

  • 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.