# Generate a random string

**URL:** <https://community.tulip.co/t/generate-a-random-string/9245>\
**Category:** Support, Troubleshooting, & Help\
**Tags:** automations\
**Created:** [September 7, 2023, 1:02pm UTC](https://community.tulip.co/t/generate-a-random-string/9245 "2023-09-07T13:02:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pete\_Hartnett](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/pete_hartnett/32/3678_2.png) [@Pete\_Hartnett](https://community.tulip.co/u/Pete_Hartnett)\
**Post date:** [September 7, 2023, 1:02pm UTC](https://community.tulip.co/t/generate-a-random-string/9245/1 "2023-09-07T13:02:55Z")

</div>

Hey All-

With the release of r261 (started rollout last night) we add support for running connector functions as an automations action. This addition reminded me of one of the [greatest connectors hacks of all time](https://community.tulip.co/t/custom-gage-widget-hack/3872). I was wondering if I could use this to around the lack of expression editor in automations.

The initial case I ran into where I wanted expressions was to generate random strings for table records -

Most (maybe all) Tulip instances have a “Connectors Demo” SQL connector that can be used, this already has authentication details, making it a good sandbox to run SQL queries.

1. Create a connector function
2. Add the query `select md5(NOW()::text) as random_string` to this function
3. Add a random\_string output  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/f/f88afad8020d4bbd05640dc73fe1995aadeb7ddc.png)

md5 hashes the current time into a string, this time includes seconds down to 10.000ths , meaning unique values is nearly guaranteed.  
_[ninja edit: `select CAST(FLOOR(RANDOM()*100000000000000) as text) as random_string;` is another query that will guarantee a unique string]_

From your automation:  
4. Add an action to your automation, calling this function, and store its output to a variable

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/f/f97b0afbe7f5ac85af99bded999a745482d2fb20.png)  
5. Use this variable wherever you need it! including as the id field on the table record creation action  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/a/a0c8afd57397fcc636ca41484f4b1528abda027d.png)

Obviously, multiple random strings can be created as needed, for separate tables.

* * *

There are a bunch of other ways I could thinking about using this functionality:

Concatenating strings:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/6/69a132c9d9a529e4661f374b6e06ca6370f1cc4b.png)

* * *

Multiplication, which could then be used downstream in your automation:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/0/0c4ee3b65c4dd8dac451580b686eac3ff7070004.png)  
…and probably much much more.

Hope this unblocks someone!  
Pete

---

<div class="post-metadata">

**Author:** ![jjj](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/jjj/32/4542_2.png) [@jjj](https://community.tulip.co/u/jjj)\
**Post date:** [September 7, 2023, 6:23pm UTC](https://community.tulip.co/t/generate-a-random-string/9245/2 "2023-09-07T18:23:27Z")

</div>

Pete, you’re a wizard 😃

![Done-it-again GIFs - Get the best GIF on GIPHY](https://us1.discourse-cdn.com/flex020/uploads/agilemfg/original/2X/0/083bc2a903da1b3221635bbaa96403bc8bed238b.gif)

---

<div class="post-metadata">

**Author:** ![freedman](https://sea2.discourse-cdn.com/flex020/user_avatar/community.tulip.co/freedman/32/107_2.png) [@freedman](https://community.tulip.co/u/freedman)\
**Post date:** [September 15, 2023, 1:50pm UTC](https://community.tulip.co/t/generate-a-random-string/9245/3 "2023-09-15T13:50:14Z")

</div>

Yes! @Pete_Hartnett thank you for connecting the dots here before the feature even released!
