⚙ Operations Hub

ryanjoconnor
Participante

Formatting Domains using Ops Hub

resolver

I've upgraded to Ops Hub and want to understand the best way to clean up / format domains when they're submitted via form.

 

For context, we have several custom objects created via forms, and the domain seems to be the best feild to associate them all (pls correct if I'm mistaken here). That said, folks will submit domains that slightly differ than what HS has on file at the Company level, (ex: including or excluding http://) so I need to make everything uniform arross the board. 

 

What is the best way to do this using the Format function in Ops Hub? 

1 Soluciones aceptada
ChrisoKlepke
Solución
Asesor destacado | Partner nivel Elite
Asesor destacado | Partner nivel Elite

Formatting Domains using Ops Hub

resolver

@BérangèreL thank you for tagging me on this.

 

Hey @ryanjoconnor@JKenler  , 

 

happy to help you out here. This should be effortlessly possible with a short custom code workflow action. Since you mentioned Ops Hub you should be able to create one.

 

I've created a short Python script for you. Please let me know if you need help implementing that.

 

from urllib.parse import urlparse


def main(event):
    url = event.get("inputFields").get("url")

    parsed_url = urlparse(url)
    domain = parsed_url.netloc.split(".")[
        -2:
    ]  # Extract the last two parts of the domain

    return {
        "outputFields": {
            "domain": ".".join(domain),
        }
    }

 

No matter how the URL looks like, the method urlsparse provides the opportunity to just leave with the domain name and TLD (so. example.com)

 

Make sure you load the URL you want to adjust as an input field with the name url and provide an output field called domain. After that, you can use the Copy Property Value action to copy the output into another property. 

 

Hope that helps. If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it. 

 

Cheers, 

Chriso

Ver la solución en mensaje original publicado

4 Respuestas 4
JKenler
Participante

Formatting Domains using Ops Hub

resolver

@ryanjoconnor did you ever resolve this? 

BérangèreL
Administrador de la comunidad
Administrador de la comunidad

Formatting Domains using Ops Hub

resolver

Hi @JKenler, I hope that you are well!

First, I'd like to share these articles that might be of interest to you:

Format your data with workflows
Custom Formula Functions

I'd like to ask our top experts about some tips they may have: Hi @Teun@louischausse and @ChrisoKlepke can you share information to help @JKenler, please?

Also, if anybody else has anything to add and/or share, please feel free to join in the conversation 🙂

Thank you 🌟 and have a lovely day!

Best,
Bérangère


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Saviez vous que la Communauté est disponible en français?
Rejoignez les discussions francophones en changeant votre langue dans les paramètres! !
ChrisoKlepke
Solución
Asesor destacado | Partner nivel Elite
Asesor destacado | Partner nivel Elite

Formatting Domains using Ops Hub

resolver

@BérangèreL thank you for tagging me on this.

 

Hey @ryanjoconnor@JKenler  , 

 

happy to help you out here. This should be effortlessly possible with a short custom code workflow action. Since you mentioned Ops Hub you should be able to create one.

 

I've created a short Python script for you. Please let me know if you need help implementing that.

 

from urllib.parse import urlparse


def main(event):
    url = event.get("inputFields").get("url")

    parsed_url = urlparse(url)
    domain = parsed_url.netloc.split(".")[
        -2:
    ]  # Extract the last two parts of the domain

    return {
        "outputFields": {
            "domain": ".".join(domain),
        }
    }

 

No matter how the URL looks like, the method urlsparse provides the opportunity to just leave with the domain name and TLD (so. example.com)

 

Make sure you load the URL you want to adjust as an input field with the name url and provide an output field called domain. After that, you can use the Copy Property Value action to copy the output into another property. 

 

Hope that helps. If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it. 

 

Cheers, 

Chriso

TitiCuisset
Administrador de la comunidad
Administrador de la comunidad

Formatting Domains using Ops Hub

resolver

Hi @ryanjoconnor 

 

Thank you for reaching out.

 

I want to tag some of our experts here - @LMeert @Jonno_Price @crispyGTM do you have any thoughts for @ryanjoconnor on this?

 

Thank you!

Best

Tiphaine


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.