Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
2493 Представления

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
3766
0
сент. 24
647