Aug 22, 2022 07:22 AM
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
Solved! Go to Solution.
Aug 23, 2022 06:40 AM
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"
Aug 22, 2022 07:44 AM
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=
Aug 22, 2022 08:29 AM
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.
Aug 22, 2022 08:31 AM
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
Aug 22, 2022 10:53 AM
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}))
)
)
Aug 23, 2022 06:09 AM
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”
Aug 23, 2022 06:13 AM
Won’t this have the ability to resolve to null and thereby fail when concatenating a null value?
Aug 23, 2022 06:17 AM
Nope. I have used this pattern several times. Is it not working for you?
Aug 23, 2022 06:19 AM
Hi @Huw_Jones ,
This is actually easy, you can use this
DATETIME_FORMATE({Date of Birth},"DD/MM/YYY")
Aug 23, 2022 06:21 AM
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: