I have a need to validate the sales line data entered in the SalesTable form. So far I have entered the following code in the canClose() method
public boolean canClose()
//STEVOYDEV385 03/10/2018 PaulF -Begin
//If the current sales order status is not "Invoiced" then check if any of the new lines
//contain references to the Credit/Billings warehouse. If so, then ensure a reason
//code has been specified.
if (salesTable.SalesStatus == SalesStatus::Backorder ||
salesTable.SalesStatus == SalesStatus::Delivered)
while select thisSalesOrderLines
where thisSalesOrderLines.SalesId == salesTable.SalesId
&& salesLineInvDimensions.inventDimId == thisSalesOrderLines.InventDimId
salesLineModifiedDate = DateTimeUtil::date(thisSalesOrderLines.modifiedDateTime);
if (salesLineInvDimensions.InventLocationId == "Cred_Bill"
&& salesLineModifiedDate == systemDateGet()
warning("A credit reason code must be specified when sales lines reference the Credit/Billings warehouse");
//STEVOYDEV385 03/10/2018 PaulF -End
if (!salesLine.PBAItemLine::checkMandatory() )
ret = super();
// The user needs to be able to modify an exchange order associated to a return and
// go back to returns without completing the exchange order (this order). The returns
// logic will prevent the order from remaining open. A return must always be completed
// therefore, the exchange order will never be left open.
ret = ret && element.mcrCheckOpenOrder();
if (element.closedCancel() && ret)
ret = salesTableForm.canClose(salesTable);
Whilst this works perfectly if data is saved within the form, when the data is entered and the user immediately clicks "Close", the code doesn't identify the new data (Because it hasn't been saved at this point) and the check doesn't validate the data as I expect.
Putting my code block after the call to the super() method, simply results in the sales header information being lost all together.
Can anyone please advise where I should place my code to correctly validate the entered data, but also stop the form from closing if it doesn't satisfy the check?
Can I know which fields are you trying to validate in this scenario?
Try to put your whole code in the active method of your form.
You are trying to validate the sales status field of the sales table if so you try to add your code in the modified method of that field.
Please check and let me know any queries.
Hi John, Thanks for your message. I am trying to validate the warehouse recorded on the SalesLine. If a particular value has been entered then a reason code is required on the SalesTable. Do you have any suggestions?