Hi Andre,
1. Yes when the dialog appears, notifications go to action center. I tried the code below as you suggested but still i got the same result, could it be that I need to change where i placed the code? I mean maybe i should put the validation on the dialog itself before it closes in this case?
[ExtensionOf(classStr(PurchFormLetter_PurchOrder))]
final class PurchFormLetter_PurchOrderX_Extension
{
private boolean must = false;
private List warnings= new List(Types::String);
public boolean validate(Object _calledFrom)
{
boolean ret;
ret = next validate(_calledFrom);
if(ret)
{
PurchLine purchLine;
while select purchLine where purchLine.PurchId == this.PurchTable().PurchId
{
TableX tableX;
select firstonly tableX where tableX.ItemId == purchLine.ItemId;
if(tableX)
{
this.validateFirstField(purchLine, tableX);
this.validateSecondField(purchLine, tableX);
}
}
if(warnings && warnings.elements())
{
ListEnumerator listEnumerator = warnings.getEnumerator();
if(listEnumerator)
{
while(listEnumerator.moveNext())
{
warning(listEnumerator.current());
}
}
}
if(must)
{
throw error("fix all errors");
}
}
return ret;
}
public void validateFirstField(PurchLine _purchLine, TableX _tableX)
{
if(_tableX.FirstField == XType::Must && _purchLine.FirstField== '')
{
error(strFmt("The FirstField for itemId: %1, is must be filled", _purchLine.ItemId));
must = true;
}
else if(_tableX.FirstField == XType::Optional && _purchLine.FirstField== '')
{
//warning(strFmt("The FirstField for itemId: %1, is preferred be filled", _purchLine.ItemId));
warnings.addEnd(strFmt("The FirstField for itemId: %1, is preferred be filled", _purchLine.ItemId));
}
}
public void validateSecondField(PurchLine _purchLine, TableX _tableX)
{
if(_tableX.SecondField == XType::Must && _purchLine.SecondField == '')
{
error(strFmt("The SecondField for itemId: %1, is must be filled", _purchLine.ItemId));
must = true;
}
else if(_tableX.SecondField == XType::Optional && _purchLine.SecondField == '')
{
//warning(strFmt("The SecondField for itemId: %1, is preferred be filled", _purchLine.ItemId));
warnings.addEnd(strFmt("The SecondField for itemId: %1, is preferred be filled", _purchLine.ItemId));
}
}
}
2. I've noticed that in PurchOrders, I can't choose which Lines to confirm even though there is PurchParmTable and PurchParmLine. So is it safe to always loop through PurchLine like what I'm doing now? or would there be a case where we can choose which purchLines to confirm from the UI?
3. You've noticed that i put a similar question to sales order (
https://community.dynamics.com/forums/thread/details/?threadid=c70b065b-022c-ee11-bdf4-000d3a55bb34). In sales orders i can choose which lines to confirm, so i now realized that putting this is wrong when doing validations
while select salesLine where salesLine.SalesId == this.salesTable().SalesId
{
}
and I will replace it with this, so that the validation works on the lines that were selected to be confirmed
SalesLine salesLine;
SalesParmLine salesParmLine;
SalesParmTable salesParmTableLocal;
select salesParmTableLocal where salesParmTableLocal.ParmId == this.salesParmUpdate().ParmId;
while select FirstField, SecondField, ItemId from salesLine where salesLine.SalesId == this.salesTable().SalesId
exists join salesParmLine where salesParmLine.SalesLineRecId == salesLine.RecId
&& salesParmLine.ParmId == salesParmTableLocal.ParmId
&& salesParmLine.TableRefId == salesParmTableLocal.TableRefId
{
}
I've noticed that SalesParmLine gets filled in both, when i click
confirm now(without dialog) and when i click
confirmation (where dialog appears)
So my question is, is it safe to always use SalesParmLine instead of looping SalesLine incase of clicking confirmation without dialog??