URL field, Link Name, Default Value
Hello,
I think it would be great if the Link Name option of the URL field could have a default value field in field properties. It would make it easier and faster to define a simple unique word or expression as a link for each record containing a URL field without the need of entering the same word for each record we submit..
Anyway, while waiting for Zoho to add this feature to Creator, here is a working solution I found based on the following source :
The idea is to deconstruct the link and to reconstruct it with the desired Link Name, like "Go", "Visit", "Learn More" or "Buy"...etc, via Deluge.
These lines of code must be added on "ON ADD > ON SUCCESS" or " ON EDIT > ON SUCCESS".
- //This variable (Link) will have the value entered in the URL field but formatted as an HTML link by Z-Creator.
- Link = input.URL_field;
- //These 2 lines of code will allow 1st: to keep only everything that is after "href=" in the formatted link. That's why it's called Suffix, then 2nd: to keep only everything that is before " target", the Prefix. So we end up with the web address only. Deconstruction completed.
- Link = Link.getSuffix("href=");
- Link = Link.getPrefix((" target"));
- //These 2 following variables are the means by which we will reconstruct the link. We are putting back what we previously removed. But instead of just only adding the target, we will also add our desired Link Name. Here we chose "Visit".
- Link_start = "<a href=";
- Link_end = " target='_blank'>Visit</a>";
- //The link is reconstructed via a simple sum.
- input.URL_field = Link_start + Link + Link_end;
Now every time you will enter a web address in the URL field of your form, the field will display "Visit" linking to the web address you entered.
URL_field is just the variable name of the URL field. Just have a look on the field properties to see what you wrote...
Hope it will help someone.
Cheers.
PS: Please, also note that the Link Name option does not need to be checked for this code to work.