Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

How to Allow or Not Allow Edit on Purchase Order?

Posted on by 102

I added a comboBox type field called "Status" with the values ​​Open and Blocked on the PurchTable form and I want to write a method that does not allow editing any information from Purchases Order if the Blocked value is selected.

  • Gokhan Cakir Profile Picture
    Gokhan Cakir 140 on at
    RE: How to Allow or Not Allow Edit on Purchase Order?

    Thank you Martin,

    I learned something nice from you.

    Best Regards!

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,588 Super User on at
    RE: How to Allow or Not Allow Edit on Purchase Order?

    The problem with previous answers is that they don't take existing logic into account.

    For example, if you followed Gökhan suggestion, you would make the order editable if your status is Open, even if the order is in workflow or already invoiced (and the system is configured not to allow changes to invoiced orders). That would be a bug.

    An appropriate place for your logic may be PurchTable.checkUpdate(). And make sure you don't set the value to true if the standard logic returns false. For example:

    boolean checkUpdate(
    	boolean  _useWarning,
    	boolean _interCompanyCheck,
    	boolean _treatInvoicedOrderUpdateWarningAsError)
    {
    	boolean allowEdit = next checkUpdate(_useWarning, _interCompanyCheck, _treatInvoicedOrderUpdateWarningAsError);
    	
    	if (this.MyStatus == MyOrderStatus::Blocked)
    	{
    		allowEdit = false;
    	}
    	
    	return allowEdit;
    }
          

    Gökhan, please always use Insert > Code (in the rich-formatting view) to paste source code. It'll prevent the extra spaces between lines (when you post each line as a separate paragraph), it adds kine numbering and so on.

  • Gokhan Cakir Profile Picture
    Gokhan Cakir 140 on at
    RE: How to Allow or Not Allow Edit on Purchase Order?

    Hi Pavel,

    You have to override called "active" method in PurchTable.

    For example;

    public int active()
    {
        int ret;
        ret = super();
        //Just you can edit PurchTable if Your Costom Field is Open
        purchTable_ds.allowEdit(PurchTable.YourCustomField == Open);
        return ret;
    }

  • Suggested answer
    Komi Siabi Profile Picture
    Komi Siabi 12,403 Super User on at
    RE: How to Allow or Not Allow Edit on Purchase Order?

    On the active method of the PurchTable datasource, you can set a condition.

    if(condition)
    {
        purchTable_ds.allowEdit(false);
        purchLine_ds.allowEdit(false);
    }

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans