menu

How to create a pretty link from a link field ( JSON_EXTRACT, JSON_UNQUOTE, TRIM, TRAILING )

The Link field stores any link in JSON format. In this example, we will create a calculation field with a formula that extracts a pretty URL from the links in the link field.

Possible Inputs Expected Output
https://google.com
http://google.com
http://google.com/
https://google.com/

google.com

Formula:

TRIM(TRAILING '/' FROM REPLACE(REPLACE(JSON_UNQUOTE(JSON_EXTRACT(@{this:link},'$.url')), 'https://', ''),'http://', ''))

Explanation:

  • The JSON_EXTRACT() function extracts the URL from the JSON output. 
  • The JSON_UNQUOTE() function removes the quotation marks from the above extrcated URL.
  • The REPLACE() function replaces the "https://" or "http://" prefix with an empty string. This is because we only want the pretty URL, which is the domain name without the prefix.
  • TRIM(TRAILING '/' FROM  URL) removes any "/" from the end of the URL if present.

 


InfoLobby © 2024 Globi Web Solutions