Showing posts with label Validation. Show all posts
Showing posts with label Validation. Show all posts

Skip/Bypass validation in Data Entity Import – D365FO

 


Skip/Bypass validation in Data Entity Import – D365FO


I had a scenario where I need to create the Tax Exempt Number dynamically when importing Vendors' data.

For instance, if the given VatNum does not exist in the input data, the system should bypass the validation and create the vendor without any error. 


So, how do we incorporate this validation? Using the COC method of persistEntity.

public void persistEntity(DataEntityRuntimeContext _entityCtx)
{   
    
        next persistEntity(_entityCtx);
     this.skipDataSourceValidateField(fieldNum(VendVendorsV2,
     VatNum),true);
    
}

Support Faryal's Cusine


Product Receipt validation in Extension using COC D365FO



Product Receipt validation in Extension using COC D365FO



Using following code you can perform custom validation on product receipt using COC


[ExtensionOf(classstr(PurchPackingSlipJournalCreate))]
final class SLD_PurchPackingSlipJournalCreate_Extension
{

    protected boolean check()
    {
      
        PurchParameters     purchParam=PurchParameters::find();
        boolean flag=    next check();

            flag= flag && this.validatePackingSlip(flag);
      
        return flag;
    }

    public boolean validatePackingSlip(boolean flag)
    {
        if(flag && this.purchParmUpdate.DocumentStatus==DocumentStatus::PackingSlip)
        {
        
 

        }
        return flag;
    }

}

Support Faryal's Cusine


Transfer Order Shipment Validation D365FO


Transfer Order Shipment Validation in Extension COC


Yesterday, I received the requirement to put some custom validation during transfer order shipment.

As everyone knows that in D365FO over-layering is not allowed anymore. So I have performed this task in extension.

In extension, You have two options to perform this task.


1st-Way

Create the form extension and replace the shipment menu item with my custom menu item and after performing my successful custom validation call original menu items.

2nd-Way

Create extension class of  InventTransferUpdShip and override the check method using COC pattern and perform our custom validation.

I decided to go with COC and the following are the code snippet I have to write 



[ExtensionOf(classstr(InventTransferUpdShip))]
final class SLD_InventTransferUpdShip_Extension
{

    boolean validate()
    {
        
        boolean ok = next validate();

        
             ok=ok && this.validateTransferOrderShip(ok);
        
        return ok;
    }


  public boolean validateTransferOrderShip(boolean flag)

    {
        // write your validation here... 

     return flag;
  }

}

Support Faryal's Cusine


Product Receipt validation in Extension using COC D365FO

Product Receipt validation in Extension using COC D365FO



Yesterday, I received the requirement to put some custom validation while performing product receipts.

As everyone knows that in D365FO over-layering is not allowed anymore. So I have to perform this task in extension.

In extension, I have two ways to perform this task.

Create the form extension and replace the product receipt menu item with my custom menu item and after performing my successful custom validation call original menu items.

Create extension class of  PurchPackingSlipJournalCreate and override the check method using COC pattern and perform our custom validation.

So I go with COC and the following are the code snippet I have to write 



    [ExtensionOf(classstr(PurchPackingSlipJournalCreate))]

    final class SLD_PurchPackingSlipJournalCreate_Extension
    {
        protected boolean check()
        {
            boolean flag=    next check();
            flag= flag && validatePackingSlip(flag);

            return flag;
        }



        public boolean validatePackingSlip(boolean flag)
        {

            if(flag && this.purchParmUpdate.DocumentStatus==DocumentStatus::PackingSlip)
            {
                // write your validation here... you can access buffer of these table purchParmUpdate,purchParmTable
                flag= checkFailed(strFmt("Custom validation causes the product receipt generation failed, %1, %2",this.purchParmTable.ParmId, this.purchParmTable.DocumentDate));

            }
            return flag;
        }


    }





Support Faryal's Cusine


Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...