Friday 11 August 2023

Table Methods in D365FnO

 

 

Table Method

 

static void ImpFunctions(Args _args)
{

    info(int2str(tableNum(AttEmployeeTable)));

    info(int2str(fieldNum(AttEmployeeTable, Name)));

}

 

public void initValue()
{
    super();
    this.Email = "saurav@yahoo.com";

}

 

public boolean validateField(FieldId _fieldIdToCheck)
{

    boolean ret;

    ret = super(_fieldIdToCheck);

 

    if (_fieldIdToCheck == fieldNum(AttEmployeeTable, PhoneMobile))

    {

        if (strLen(this.PhoneMobile) > 13)

            ret = ret && checkFailed("Invalid phone number");

    }

    return ret;

}


public void modifiedField(FieldId _fieldId)
{

    super(_fieldId);

    if (_fieldId == fieldNum(AttEmployeeTable, Gender))
    {

        if (this.Gender == Gender::Male)
        {
            this.CreditLimit = 600.00;

        }
        else if (this.Gender == Gender::Female)
        {
            this.CreditLimit = 500.00;

        }
        else
        {
            this.CreditLimit = 200.00;
        }

    }

}

 

public boolean validateDelete()
{

    boolean ret;

    ret = super();

    if (this.Gender == Gender::Female)
    {

        ret = ret && checkFailed("Female customers cannot be deleted");

    }
    return ret;

}

 

public boolean validateWrite()

{

    boolean ret;

    ret = super();

    if (this.Gender == Gender::Female && this.Email == '')

    {

        ret = ret && checkFailed("Email is mandatory for Female customers");

    }

    return ret;

}

No comments:

Post a Comment

Data Entities in D365 FnO

  Data management - Data entities ·        Data entity is a conceptual abstraction and encapsulation of one of more underlying tables. ...