on 05-12-2020 10:08 AM
Hi experts,
I have implemented some logic for one of the client in onSave validation to show some message if a condition met. The logic somehow works but it doesn't show the message:
the logic is as follow:
In the BO extension I have:
import AP.Common.GDT;
import AP.ExpenseReimbursementManagement.Global;
[Extension] businessobject AP.ExpenseReimbursementManagement.Global:ExpenseReport raises attachmentMessage, futurDateMessage {
message attachmentMessage text "No attachement found, Please attache documents to proceed";
message futurDateMessage text "You cannot select a future date";
node Mileage {
}
node Receipt {
node ReceiptBeneficiary {
}
}
}
In the validation I have:
import ABSL;
var flag = false;
var currentData = Context.GetCurrentSystemDate();
foreach(var r in this.Receipt)
{
if(r.Date.GreaterThan(currentData))
{
flag = true;
}
}
if(!this.AttachmentFolder.IsSet())
{
attachmentMessage.Create("E");
return false;
}
else if (flag)
{
futurDateMessage.Create("E");
}
else
{
return true;
}
I missed the key word "raise" before the message...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I think it was due to a return false missing after raising error message "futurDateMessage.Create("E");"
Can you please try to use following code:
import ABSL;
var flag = false;
var currentData = Context.GetCurrentSystemDate();
foreach(var r in this.Receipt)
{
if(r.Date.GreaterThan(currentData))
{
flag = true;
futurDateMessage.Create("E");
return false;
}
}
if(!this.AttachmentFolder.IsSet())
{
attachmentMessage.Create("E");
return false;
}
else
{
return true;
}
BR
Saurabh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Saurabh,
foreach(var r in this.Receipt){if(r.Date.GreaterThan(currentData)){
flag = true;
futurDateMessage.Create("E");return false;}}
this however will cause the message to repeat when we have more that one item level with a future data, I kept the flag that way to show that there are some items that need to be chacked.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.