Try ERPNext Buy Support Partners Foundation

Use Button to Trigger Webhook

Hi there,

how would I trigger a Webhook using a Button in a DocType?

Thank you for the help!! Love the project!

Cheers
Jan

Hello @JanMrlth,

If you want to trigger a Webhook using a button in ERPNext, a webhook may be not the right thing to do, see the doc.

Maybe you could create a webhook to ERPNext itself? By using the Rest API.

What do you want to achieve?

Ok, let me explain what I want to do :slight_smile:

I am mechanical engineer and build machines. Attached to every part (item), there is a lot of technical documentation. I created a Doctype Download-Links and appended the item view with it. That way I can attach Links to manuals etc to the items.

I order to get a RFQ I need to send technical drawings to the manufacturer. Instead of attaching them to ERP-next and the email, I use n8n to create a shared folder in OneDrive and attach this Link to my Download-Links List.

Not every Part needs a folder. So I want a button in the ITEM, that is only there as long as no folder has been created. Clicking on the button would send the http-post to n8n. n8n the creates the folder, shares it, creates a short-link to the share-link, writes back this Link into the Parts description.

At the moment I have a webhook triggered ‘after_insert’, that sends the needed info to n8n.

I could add a Checkbox ‘Should Shared Folder be Created’ and add a Condition to the webhook. But maybe after two weeks I need that folder. The webhook does everything I need. I then want to trigger it once with ‘the press of a button’.

I hope that explanation is of any use…
Thank you!

You could add a checkbox “Create Folder” to Item, use “on_update” as a the Webhook “Doc Event” and use a condition like this:

doc.create_folder and not 'https://onedrive' in doc.description

This way you just have to check the checkbox and save the Item to trigger the Webhook.

1 Like