# Displaying a message on clicking a button

**URL:** https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705
**Category:** Developer
**Tags:** project
**Created:** [August 31, 2019, 7:52am UTC](https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705 "2019-08-31T07:52:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Thedevilcoder](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/t/ac91a4/32.png) [@Thedevilcoder](https://discuss.tryton.org/u/Thedevilcoder)
#### Post date: [August 31, 2019, 7:52am UTC](https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705/1 "2019-08-31T07:52:21Z")

</div>

I have created a button to generate a payslip of an employee.  
How do I prompt a message to the user to say that the “Payslip successfully generated” after clicking the button?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 1, 2019, 7:56am UTC](https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705/2 "2019-09-01T07:56:10Z")

</div>

You must use a wizard for that.  
But it is not the common practice in Tryton. The form on which the button is clicked usually shows that it has changed (like the status or a check box etc.).

---

<div class="post-metadata">

### Author: ![prashasti.sharma](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/58f4c7/32.png) [@prashasti.sharma](https://discuss.tryton.org/u/prashasti.sharma)
#### Post date: [May 27, 2020, 7:40am UTC](https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705/3 "2020-05-27T07:40:13Z")

</div>

How to activate a boolean field on clicking the button?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [May 27, 2020, 7:56am UTC](https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705/4 "2020-05-27T07:56:32Z")

</div>

The method of the button should write on this boolean.

---

<div class="post-metadata">

### Author: ![bala4901](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/b/fbc32d/32.png) [@bala4901](https://discuss.tryton.org/u/bala4901)
#### Post date: [May 27, 2020, 8:47am UTC](https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705/6 "2020-05-27T08:47:26Z")

</div>

You may use [Bus Publish - Notification](https://docs.tryton.org/projects/server/en/latest/ref/bus.html#trytond.bus.Bus.publish) for Show Notification to user

Example [Sending Notification](https://docs.tryton.org/projects/server/en/latest/topics/bus.html#sending-notifications)

---

<div class="post-metadata">

### Author: ![prashasti.sharma](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/58f4c7/32.png) [@prashasti.sharma](https://discuss.tryton.org/u/prashasti.sharma)
#### Post date: [May 28, 2020, 7:30am UTC](https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705/7 "2020-05-28T07:30:51Z")

</div>

```
@classmethod
@ModelView.button
@Workflow.transition('draft')
def mark_as_beneficiary(cls, records):
    for record in records:
        record.is_beneficiary = True
        if record.ifsc_code:
            regex = re.compile("^[A-Za-z]{4}[a-zA-Z0-9]{7}$")
            if (regex.match(record.ifsc_code)):
                record.ifsc_code = record.ifsc_code.upper()
            else:
                record.raise_user_error('Please fill valid IFSC code.')
        if record.account_no:
            if record.account_no.isnumeric() is False:
                record.raise_user_error(
                    'Account No should be Numeric. Please fill valid Account No.')

```

The above code is not working as well as not showing any error on clicking the button mark\_as\_beneficiary. On clicking the button mark\_as\_beneficiary it should automatically make the boolean field is\_beneficiary = True.  
Any help regarding the issue will be grateful.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [May 28, 2020, 7:34am UTC](https://discuss.tryton.org/t/displaying-a-message-on-clicking-a-button/1705/8 "2020-05-28T07:34:53Z")

</div>

You must call `ModelSQL.save` on the records to get the changes persisted.
