1. To apply restriction in a form which needs to pass before submit.
2. If the user cancels the submit process then perform post submit operation and validate again.
Verifying the restrictions is easy in the form, but to capture the control after a user clicks on Submit is tricky.
In my example, I am verifying the Phone Number on submit and hiding the Submit Button itself.
The scenario is that the form can only be submitted once.
However, if the user clicks on Submit Button and cancel the draft email for any reason then the whole process should be nullified and Submit Button should remain active.
This can be done by using the try catch block. And after capturing the specific exception of user cancelled operation, we can perform post submit operation.
Snippet:
try
{
var eid = "dummy@test.com";
var sub = "This is a dummy Subject Line";
var bdy = "Sample Body";
if(TextField1.rawValue == null || TextField1.rawValue == "" || TextField1.rawValue.length != 10)
{
app.alert("Please enter correct phone number");
}
if(TextField1.rawValue.length == 10)
{
this.presence = "hidden";
event.target.submitForm({cURL:"mailto:" + eid + "?subject=" + 'Anoop & Singh' + "&body=" + bdy ,cSubmitAs:"PDF",cCharset:"utf-8"});
}
}
catch(e)
{
if(e.toString() == "RaiseError: User canceled operation.")
{
this.presence = "visible";
}
}
No comments:
Post a Comment