Dear Appsheet community,
Sometimes you want to shorten URLs, which is soooooo useful if you are generating QR Codes and want them to contain a lot of data. Useful, because when the QR Code contain a long url, it becomes more difficult to scan them, or maybe the output encounter encoding issues and is not displayed correctly.
I searched a lot but couldn't find any topic in the community about this issue, so I created one for reference. There's three way to do this, first is to use webhooks return values, second is using spreedsheet formulas and third way is to use an AppScript function.
In this post we will see how to achieve the first and 2nd method.
Method 1 (da best) - Using webhooks return values :
- You will need a tinyurl api token, it's free under 600 urls created. Get it on the tinyurl website in your account settings.
- Create a column that will contain the tiny url.
- Create a new automation.
Step one : Call a webhook. Set preset to custom. URL value should be : https://api.tinyurl.com/create?api_token= YOURAPITOKEN
Body should be, for example :
{
"url": "https://form.jotform.com/250250250?controlor=<<[Controlor]>>&site=<<[Site]>>",
"domain": "tinyurl.com",
"alias":"",
"tags":""
}
if you want to edit the url value with column values, just like in templates, put your column names between <<[column]>>, and all the url between "url".
Toggle on Return Value. Set the name to : data.tiny_url and type to Text.
Step two : Add a new event "run a data action" on the column you created, where the new value is : [Step one name].[data.tiny_url]
the automationevent1
event2
That's it.
I'm using this to pre-populate fields of a Jotform. I create a jotform URL containing AppSheet specific values, and even letting jotform users access appsheet files that are specific to one-form only by inserting the file URL directly in the URL. Obviously we can't scan a QR Code with so much data, which is why I looked for a workaround.
Method 2 (don't do it) - Using spreedsheet formulas (will increase the syncing time by a lot) :
What you will do is :
in english it should be : IMPORTDATA(CONCATENATE("http://tinyurl.com/api-create.php?url=" & indirect(ADRESS(ROW(),*column number of the URL column*;1,TRUE))))
in my case, example : IMPORTDATA(CONCATENER("http://tinyurl.com/api-create.php?url=" & indirect(ADRESSE(LIGNE();10;1;VRAI)))) (10 is the column number of my URL column in my spreadsheet, corresponding to letter J)
That's it !
Nice. Presumably should also be possible wholly within AppSheet via Use return values from webhooks - AppSheet Help.
It's my first time using this function, can you help me configure it ? I gave it a few try but I didn't managed to use the response in a column
I have not yet used this recently introduced feature. Try posting a new topic in the Q&A forum with your specific question. Maybe other community contributors have tried it out.
As @dbaum said, it works using webhooks return values and it's way more efficient than using spreedsheet formulas.
Thanks to nico for this https://www.googlecloudcommunity.com/gc/AppSheet-Q-A/Failed-Webhook-type-translation-Conversion-erro...
I'll update this post
Very well explained, and it works as expected. Just one question, how many API tokens can be used for each app. I mean if I have one app with different tables. When you create the automation rules, can you use the same API token without causing any conflict? Can the same token generated from tiny url be used in other apps?, or should I use one token per automation rule. Sorry if it sound a bit silly, I do not know too much about this topics.
Hi areyes,
You can use your API token in multiple apps. You just need to be sure to keep it private if you are a paid user.
Perfect. Thank you.