How to disable toolbar button and load another item on item maintenance form

SOLVED

I have a customization project to create a customized item copy function on Inventory Item Maintenance form. A custom command button is added to the form. When user clicks the button, it fires stored procedure I created to copy the current item with a new ItemID.

The form has a built-in copy command button on toolbar, is it possible to disable this built-in command button on toolbar

After the copying is done, how to reload the form with new item id

Thanks

  • +1
    verified answer

    Before answering the question, I'm curious what the current copy Item command did not do for you?

  • 0 in reply to dbcoles

    Thank you for the reply. I am a developer at my firm and don't know why built-in copy command does not meet the business need. The built-in function certainly does not copy our custom tables related to item master. It may also copy something our client really don't want to copy over.  

  • 0 in reply to yzou

    I'd suggest finding out what additional things need to be done, adding code to the Copy command screen and/or the Form Save Customizer event (if you have Customizer). In Customizer, the command to disable the button is:

     Form.Controls("tbrMain").ButtonEnabled("K11") = FALSE

    outside customizer, just tbrMain.ButtonEnabled......

  • 0 in reply to dbcoles

    Customizer is used for this project. After copying is done, I would like to load the form with newly copied item. In sales order form, I can use DrillAround to load a sales order by passing SOKey. Do you know a way to load item by passing either companyid + itemid or itemkey in customizer?

    We did consider your suggestion to modify the existing copy function. But it did not work out.

    Thanks again!

    Youdao

  • 0 in reply to dbcoles
    SUGGESTED

    I tested your code and it worked. 

    Form.Controls("tbrMain").ButtonEnabled("K11") = FALSE

    By the way, I figured out how to load a item with a new item

    'issue cancel command
    oForm.HAndleToolbarClick CStr("K7")

    'populate lookup control with new itemid
    Form.Controls("lkuMain").Text = stringNewItemID

    'Issue a refresh command to load the new itemID
    oForm.HAndleToolbarClick CStr("K25")

    Thank you for your help. I marked the question answered.