locked
Disable "Create invoice" button RRS feed

  • Question

  • Hi,

    I have a problem with "Create Invoice" button. When I click it and my invoice created, it isn't disabled.So we can have so many related invoice and it is bad. I want to be disabled it, when first invoice was created and no one can click it again.

    I used javascript but it is disabled just during the creating invoice and after that it is enable.

    Please help me

    This is my code:

    function FrmOnSave(prmContext) {
        // Local variable to store value indicating how the save event was initiated by the user.
        var wod_SaveMode, wod_SaveEventVal;

        // Change the Save Event Value as per required Save Event
        wod_SaveEventVal = 19;

        if (prmContext != null && prmContext.getEventArgs() != null) {

            wod_SaveMode = prmContext.getEventArgs().getSaveMode();

            if (wod_SaveMode == wod_SaveEventVal) {
                var buttonID = "salesorder|NoRelationship|Form|Mscrm.Form.salesorder.MainTab.Actions-LargeMediumLarge-0";
                var btn = window.top.document.getElementById(buttonID);
                if (btn) {
                    btn.disabled = false;
                }
              

    Wednesday, February 26, 2014 12:27 PM

All replies

  • Hi Aghaghy,

    If I understood you correctly, you want only one Invoice to be associated with a Contact/Account. In that case, the logic would be something like "find if there are any invoices existing against the Contact/Account and if you find any disable the Create Invoice button" and this needs to be wired up to "FormOnLoad" of Contact/Account.


    Wednesday, February 26, 2014 12:33 PM
  • Agree with Dynamotion. That would be a way to hide the button when an invoice already exists. However, this might slow the form load. Consider using a pre-create plugin on invoice to check this condition and abort with an error message.

    If my response helps you in finding your answer then please click 'Mark as Answer' and 'Vote as Helpful'

    Wednesday, February 26, 2014 1:10 PM