Skip to Content
Menu
This question has been flagged
2 Replies
2008 Views

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!

Avatar
Discard
Best Answer

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





Avatar
Discard
Best Answer

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.

Avatar
Discard
Related Posts Replies Views Activity
1
May 22
2492
0
Feb 22
157
1
Sep 20
4645
2
Oct 24
1970
0
Sep 24
121