Transform Variable With Additional Text

Hi,

I am looking to create a link from a variable, but also add “/settings/?tab=admin_roles” after the provided URL.

Is there a transform expression I could use to add that text after a variable, which would be the beginning of the URL? From there, the output of the transform function would be used on the next web page as a link.

Thanks!

Hey Chris!

If you’re just trying to combine two potential strings into a new URL, you could use the CONCAT function.

For example, if I have a “beginning” input in a data flow that could take in any standard URL, you could use the CONCAT function to create and return a new URL with the new paths added on.

1 Like

Hi!

Fields that expect URLs in Airkit accept strings. So if you have a URL stored in a variable (let’s call it url_value for the sake of example), then the string "{{url_value}}/settings/?tab=admin_roles" would reference a perfectly valid link.

You can use similar principles to modify any portion of a URL. If there’s a topic you want to link to in Wikipedia, for instance, and the topic is stored in the variable topic, you can generate a link to that topic’s Wikipedia page with "https://en.wikipedia.org/wiki/{{topic}}", or, perhaps more completely, as

"https://en.wikipedia.org/wiki/{{
  SUBSTITUTE(topic, " ", "_")
}}"

Which uses the SUBSTITUTE function to replace any spaces with underscores, thus making even multi-word topics more URL-friendly.

Does that cover your use case?

Oh, I suppose instead of SUBSTITUTE, the function URL_ENCODE does a more complete job of escaping characters that have special meanings in URLs.

ie:

"https://en.wikipedia.org/wiki/{{
  URL_ENCODE(topic)
}}"

Great, that takes care of the combination.

How would I pass the output to the link on the next page?

Thanks!

That depends on how you’ve been handling data binding up until this point!

Sounds like you’re working with an Activity Variable, when you want to be working with an Activity Group Variable. Activity Group Variables are available throughout a Web Flow, not just a single Web Page. This doc on Variable Namespaces can help you get more of a big-picture understanding of how to conceptualize this.

Can you go into a little more detail of the variables you’re working with in this case?

1 Like

Thank you, that doc was helpful.

I have “pagelink” as object “any” at the end of my transform function.
For the hyperlink I am using activityGroup.pagelink, but for some reason, it’s not showing up?

image

Okay, I think I see what’s going on here!

Everything that goes into creating a Data Flow in the Connections Builder exists in its own little ecosystem. When you run a Data Flow using the Run Data Flow Action, you have to explicitly bind the output to something, otherwise you won’t be able to access it. (The “Return Value” you provided a screenshot of references the Data Operation output that will be returned by the Data Flow as a whole - you can’t access this as “pagelink” within your broader application.) In your case, you want to bind it to activityGroup.pagelink, and only then will that variable have a value that you can call upon.

Does that make sense?

1 Like

Great, just had to add the output binding on that data flow.

Thanks!

1 Like