Help

Re: Using a Button to create a URL

Solved
Jump to Solution
2115 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Huw_Jones
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi,

I’m pulling what little hair I have left out trying to search for an answer to my problem. Any advice would be very gratefully appreciated.

I am trying to create a button that will create a custom url based on the following:

https://random.company.co.uk/crsc/api/status/?dateOfBirth=<DD/MM/YYYY>&s
urname=&hasAgreedTermsAndConditions=true&organisationName=&employeeSu
rname=&employeeForename=

The elements will be referenced from our airtable.

Any clues as to where to start will be met with whoops of joy.

Thanks,
Huw

1 Solution

Accepted Solutions

I can see the problems , the below formula should work

"https://random.company.co.uk/api/status/"&{something}&"?dateOfBirth="&DATETIME_FORMAT({Date of Birth}, "DD/MM/YYYY")&"&surname="&{Surname}&"&hasAgreedTermsAndConditions=true&organisationName=Tidal+Supply&employeeSurname=employeeForename=Jones"

See Solution in Thread

12 Replies 12

Hi @Huw_Jones ,

Welcome to Airtable Community!

I see you already have your formula :slightly_smiling_face:

It should look something like this

"https://random.company.co.uk/crsc/api/status/?dateOfBirth="&{DOB}&"&s
urname="&{Surname}&"&hasAgreedTermsAndConditions=true&organisationName="&{Organization Name} &employeeSu
rname=&employeeForename=

Of course since I dont have the field names Im only able to assume.

The idea is you need to concatenate the data and where you need the ampersand you can do it like this &"&surname=

Thanks for your help Mohamed,

Unfortunately, the TermsAndConditions=true section in the formula leads to the following message: Formula functions must be immediately followed by “(”.

Do you know of a way to show airtable that this part of the url is not to be treated as a formula?

Sorry for being so think here - I have no knowledge of coding and this is really pushing the boundaries of my knowlegde.

Hi Huw,

The formula is just an example :slightly_smiling_face:

Basically you put anything you need between quotation marks "Text Here" so Airtable would understand that this is a fixed text and not a field.

If you want to share a screenshot or a view of the base so I can write the formula in the way you need it I ll be happy to do it

Welcome to the Airtable community!

Maybe this pattern will be easier for you to follow:

CONCATENATE(
  "https://random.company.co.uk/crsc/api/status/",
  "?dateOfBirth=" & ENCODE_URL_COMPONENT(DATESTR({dateOfBirth})),
  "&surname=" & {surname},
  "&hasAgreedTermsAndConditions=true",
  "&organisationName=" & {organizationName}, 
  "&employeeSurname=" & {employeeSurname}, 
  "&employeeForename=" & {employeeForename}
)

Depending on your field types, you may need a more complex formula.

CONCATENATE(
  "https://random.company.co.uk/crsc/api/status/",
  "?surname=" & ENCODE_URL_COMPONENT({surname} & ""),
  "&hasAgreedTermsAndConditions=" & {hasTermsAndConditions},
  "&organisationName=" & ENCODE_URL_COMPONENT({organizationName} & ""), 
  "&employeeSurname=" & ENCODE_URL_COMPONENT({employeeSurname} & ""), 
  "&employeeForename=" & ENCODE_URL_COMPONENT({employeeForename} & ""),
  IF(
    {dateOfBirth},
    "&dateOfBirth=" & ENCODE_URL_COMPONENT(DATESTR({dateOfBirth}))
  )
)

Thank you Mohamed once again. I’ve got this part working now. I am now having difficulty formatting the date of birth in the DD/MM/YYY format. Would you mind showing me where I’m going wrong here? I figured out it was something to do with the date string thanks to @kuovonne 's kind answers.

https://random,company.co.uk/api/status/“&{something}&”?dateOfBirth=”(DATETIME_FORMAT(‘&{Date of Birth}’',‘L’))&“&surname=”&{Surname}&“&hasAgreedTermsAndConditions=true&organisationName=&Tidal Supply&employeeSurname=&employeeForename=Jones”

Won’t this have the ability to resolve to null and thereby fail when concatenating a null value?

Nope. I have used this pattern several times. Is it not working for you?

Hi @Huw_Jones ,

This is actually easy, you can use this

DATETIME_FORMATE({Date of Birth},"DD/MM/YYY")

No, but I saw the pattern lacked an else argument and assumed that it would not magically concatenate an empty string. I guess it does have some magic. :winking_face:

Thanks again, I’ve ammended the formula but it’s still giving me error messages. Any pointers as to where I’m going wrong?

https://random.company.co.uk/api/status/“&{something}&”?dateOfBirth=”(DATETIME_FORMAT(&{Date of Birth}&, “DD/MM/YYYY”))&“&surname=”&{Surname}&“&hasAgreedTermsAndConditions=true&organisationName=&Tidal Supply&employeeSurname=&employeeForename=Jones”

I can see the problems , the below formula should work

"https://random.company.co.uk/api/status/"&{something}&"?dateOfBirth="&DATETIME_FORMAT({Date of Birth}, "DD/MM/YYYY")&"&surname="&{Surname}&"&hasAgreedTermsAndConditions=true&organisationName=Tidal+Supply&employeeSurname=employeeForename=Jones"

Amazing! Thank you so much Mohamed!
Huw