Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2480 Lượt xem

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!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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





Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 22
3089
0
thg 2 22
157
1
thg 9 20
5202
2
thg 10 24
3739
0
thg 9 24
634