Build dynamic hyperlinks

Surely this has to have been discussed somewhere… but I’m not finding it. Is there a format to dynamically build hyperlinks that I can use in email notifications? Example: Quote 12345 is due for follow-up.

I did look at the system generated ones but there’s a lot of info in that hyperlink that I don’t know what’s necessary? What also needs dynamically populated?

1 Like

Are you referring to the the links generated via the “Share” option in the overflow menu(s) of various forms?

1 Like

Yes

The built-in Share Tool simply calls the browser’s built-in Share API navigator.share(s) passing the current URL:

shareLink() {
    if (navigator.share) {
        const s = {
            title: document.title,
            text: document.title,
            url: location.href
        };
        navigator.share(s)
    } else
        window.open("mailto:?body=".concat(location.origin + encodeURIComponent(location.hash)))
}

So not helpful.

Not sure if there’s a utility that can build a valid deeplink. Whenever I’ve tried to simplify kinetic urls it’s seems very few params can be dumped. I’d say copy a valid Detail Form Url and then simply swap out the KeyFields Param/value is an easy approach.

&KeyFields.OrderNum=24484

Of course if they change the router somehow or the menuid changes it may break.

2 Likes

Yes - I did see what appeared to be a menu ID in there… but there’s also some kind of Guid as well. I’ll dig a little deeper and see if I can figure out how the menu search decides which menus to show… I know it has some logic built in. I’d hate for a menu change to now be a cause for broken links.

2 Likes

Keyfields input require a handling event on the app side, so what values you can pass in depend on the existence of those events on the form you are targeting.

Any time i’ve wanted to add a “Jump to page via URL” functionality to something, I use %valueIn% and set up an event to row-current-set and switch pages, or however the handling needs to be done.

For example, I did this in PO Approval, by setting up a data directive to build the URL and send an email, including the PO # and setting it up to jump to the detail page.

The channelid is a value for app commmunication between tabs, you want to set it to 0 for this porpoise.

4 Likes

Purpose GIF by chuber channel

7 Likes

Thank you. You guys rock!

Here is some example code from my DevTools dashboard where i am building URLs to load into App Studio with the appropriate app/layer (this is from a function):
These are relative URLs to the current page, which should preserve the base url https://{stuff}.epicorsaas.com/{environment}/apps/erp/home/)
You can use Session.AppServerURL to help with building the URL.

x = $"#/view/NONID12345/{app.Key1}/designer/pages?layerVersion=0&baseAppVersion=0&useBroadcast=1&company={Session.CompanyID}&site={Session.PlantID}&isNewApp=false";
y = $"#/view/NONID12345/{app.Key1}/designer/pages?layerVersion=0&baseAppVersion=0&useBroadcast=1&company={Session.CompanyID}&site={Session.PlantID}&isNewApp=false&layerNames=";

These feed into a dashboard:

6 Likes

Additionally, this code will allow you to assemble complete URLs (not relative) in a function (you can drop this code into devtools C# input to see output):

var r = result.Results.NewRow();
string menuid = "DEVTOOLS";
var vars = new Dictionary<string, string> { { "param1", "val1" }, { "param2", "val2" } };
string variables = string.Join("&", vars.Select(kvp => $"{kvp.Key}={kvp.Value}"));
r["Character01"] = $"{Session.AppServerURL}/apps/erp/home/#/view/{menuid}/?channelid=0&layerVersion=0&baseAppVersion=0&company={Session.CompanyID}&site={Session.PlantID}&{variables}";
result.Results.Add(r);

This will result in URL:
https://server.epicorsaas.com/environment/apps/erp/home/#/view/DEVTOOLS/?channelid=0&layerVersion=0&baseAppVersion=0&company=company&site=site&param1=val1&param2=val2

This method is used in a data directive when building a url for linking in emails and so on.

3 Likes

For the AppStudio event setup, for debugging purpose, you can see the value in inside dev tools console like this:

you can do something like:
After_FormOnLoad
Trigger: Type: Event, Hook: After, Target: Form_OnLoad
Condition: ‘context && context.initialValueIn && context.initialValueIn.ValueIn && context.initialValueIn.ValueIn.YourVariable’ !== ‘’ (only do something if you passed a valuein)
→ True: Component: dashboard-timer-set, interval:100, event:yourevent (i found it helpful to put a delay in for switching pages to allow data to load.)
yourevent
page-navigate-to ‘%session.context.initialValueIn.ValueIn.YourVariable%’

1 Like