Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
2491 Переглядів

Hi, I want to create a button on the Lead/Opportunity model that I will link to a server action (Nicholas Kosinski has a tutorial on this).


My requirement is that I want to make a POST request to a remote Angular server (I have a specific URL for that) when this button is clicked. Part of that URL will be some information of the opportunity record (e.g. name, address).


Can I do this using a few lines of python code inside a server action? Please share an example. Thank you!

Аватар
Відмінити
Найкраща відповідь

Hi Tushar, you can try this code:



lead_name = record.name or ''
customer_name = record.partner_id.name if record.partner_id else ''
email = record.email_from or ''
phone = record.phone or ''
payload = {
    'nombre': lead_name,
    'cliente': customer_name,
    'correo_electronico': email,
    'telefono': phone,
}
url = 'https://notify.run/testpost'
requests.post(url, json=payload)


I have not a v13 instance to test, but it's working on v17.

Best regards





Аватар
Відмінити
Найкраща відповідь

You can call any HTTP action (GET, POST, PUT ... ) within your Python code, as long as you define what launches this action, and send as parameters the information you want to send to another server.
This can also be done to retrieve information, like from APIs, web services, etc.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
трав. 22
3090
0
лют. 22
157
1
вер. 20
5202
2
жовт. 24
3765
0
вер. 24
645