Dear gents,
I am trying to create a new validation on SalesAgreement Form, my requirement is when the user enters a price not valid in Trade Agreement Journal (PriceDiscTable) the form will return an error/Check failed.
i was able to create such validation on the table AgreementLineQuantityCommitment, since the field name is PricePerUnit on this table.
but im facing an issue, when the user insert an invalid line, he receives the error. but when he duplicates the Tab on browser or close the browser and open it again, the line is automatically saved on line despite that it shouldn't since the price is not valid.
then i tried the below code which is the validation on formDatasource and not directly on the table, and the record is still showing after closing/duplicating the form.
[FormDataSourceEventHandler(formDataSourceStr(SalesAgreement, ALine), FormDataSourceEventType::ValidatingWrite)]
public static void abTable_OnValidatingWrite(FormDataSource sender, FormDataSourceEventArgs e)
{
FormDataSource AgreementLineQuantityCommitmentDS =sender as FormDataSource;
AgreementLineQuantityCommitment AgreementLineQuantityCommitment = AgreementLineQuantityCommitmentDS.cursor();
AgreementHeader AgreementHeader,AgreementHeader1;
AgreementLine AgreementLine,AgreementLine1;
AgreementHeaderDefault AgreementHeaderDefault,AgreementHeaderDefault1;
PriceDiscAdmTrans PriceDiscAdmTrans ;
PriceDiscTable PriceDiscTable,PriceDiscTable1;
boolean docancel;
var args = e as FormDataSourceCancelEventArgs;
select AgreementLine1 where AgreementLineQuantityCommitment.RecId == AgreementLine1.RecId;
select AgreementHeader1 where AgreementHeader1.Recid == AgreementLine1.Agreement;
select AgreementHeaderDefault1 where AgreementHeaderDefault1.AgreementHeader ==AgreementHeader1.RecId;
if(AgreementHeader1.IS_Approved ==NoYes::No)
{
if(AgreementHeaderDefault1.IS_PriceGroup)
{
select PriceDiscTable
where AgreementLineQuantityCommitment.ItemId ==PriceDiscTable.ItemRelation
join AgreementLine where AgreementLineQuantityCommitment.RecId == AgreementLine.RecId
join AgreementHeader where AgreementHeader.Recid == AgreementLine.Agreement
&& AgreementHeader.DefaultAgreementLineEffectiveDate >=PriceDiscTable.FromDate
&& AgreementHeader.DefaultAgreementLineEffectiveDate <= PriceDiscTable.ToDate
join AgreementHeaderDefault where AgreementHeaderDefault.AgreementHeader ==AgreementHeader.RecId
&& AgreementHeaderDefault.IS_PriceGroup ==PriceDiscTable.AccountRelation ;
if(PriceDiscTable)
{
if(AgreementLineQuantityCommitment.PricePerUnit
your help is highly appreciated, as it's an urgent case.
Regards,