??? Struggling with inconsistent patch number formatting? Here's a magical solution to effortlessly control it without any hassle!

??? Struggling with inconsistent patch number formatting? Here's a magical solution to effortlessly control it without any hassle!



Do you often find yourself battling with inconsistent patch number formats? Fear not! We've got a magical solution for you. Say goodbye to those pesky formatting issues with our automated patch number formatting tool! No more worrying about spaces or alignments, just smooth and uniform patch numbers every time. Streamline your workflow and save time for what truly matters. Try it out today and experience the magic yourself! ???

#D365fo #InventBatch #Inventory #LinkedInMagic



[ExtensionOf(tableStr(InventBatch))]

final class InventBatch_Extension

{

public boolean validateField(FieldId _fieldIdToCheck)

{

// Call the base class' validateField method unconditionally

boolean ret = next validateField(_fieldIdToCheck);

// Check if the current record's DataAreaId is not CDA

if (!(this.dataAreaId == 'CDA' ))

{

return ret; // Skip validation for records with DataAreaId other than "CDA1" or "CDA2"

}

// Check if the field being validated is InventBatchId

if (_fieldIdToCheck == fieldNum(InventBatch, InventBatchId))

{

ret = this.validateBatchId(this.InventBatchId) && ret;

}

return ret;

}

private boolean validateBatchId(str _batchId)

{

info(strFmt("Validating batch ID: %1", _batchId));

// Check if the batch number contains only numeric characters

for (int i = 1; i <= strLen(_batchId); i++)

{

if (!this.isNumeric(subStr(_batchId, i, 1)))

{

error("Batch number can only contain numeric characters.");

return false;

}

}

// Batch number is valid

return true;

}

private boolean isNumeric(str _char)

{

// Allow numeric characters and leading zeros

return ((_char >= '0' && char <= '9') || (char == '0'));

}

}

//////////////////////////////////////////////////////////////////

public class BatchNumberValidator

{

public boolean validateBatchNumber(str batchNumber)

{

// Check if batch number contains only numeric characters

for (int i = 1; i <= strLen(batchNumber); i++)

{

if (!this.isNumeric(subStr(batchNumber, i, 1)))

{

// Non-numeric character found, return false

error("Batch number can only contain numeric characters.");

return false;

}

}

// Batch number is valid

return true;

}

private boolean isNumeric(str _char)

{

return (_char >= '0' && _char <= '9');

}

}

要查看或添加评论,请登录

Mohamed Zakarya的更多文章

社区洞察

其他会员也浏览了