onsubmit require attachement form widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 01:00 AM
Hi Guys
I am wondering if any of you guys have done this.
I am using the form widget and have buttons as below.
Submit Online Referral is a server side button from the backend
Cancel and save as draft is custom buttons
Cancels just leaves the form, and save as draft saves the form without needed to complete required fields.
I have a requirement to make attachment mandatory if users states yes to has attachments and only when they click on the submit referral.
In the back-end, i would have used business rules previous to do this, but not sure how i could do this on the portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 02:23 AM
Hi,
Please paste it in here as this is your submit action button
$scope.triggerUIAction = function(action) {
if ($scope.data.disableUIActions)
return;
if (g_form) {
$timeout(function() {
//paste it here
g_form.submit(action.action_name || action.sys_id);
}
)}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 07:59 AM
Thank you
Ive added the following but no joy
$scope.action.name = function(){
var attLength=$scope.get-attachment.length;
if(attLength==0){
g_form.addErrorMessage('Your are required to attach');
return false;
}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 08:10 AM
Hi Brendon,
I guess you are adding it in wrong place,
You need to add it to the function when you are going to save the request.
Also, its $scope.attachment.length and not $scope.get-attachment.length as per OOB.
Please try the below code and see the outcome.
You can also try to debug then if it is affecting something else.
$scope.triggerUIAction = function(action) {
var attLength= $scope.attachments.length;
if(attLength==0){
g_form.addErrorMessage("Please attach atleast one item");
return false;
}
if ($scope.data.disableUIActions)
return;
if (g_form) {
$timeout(function() {
g_form.submit(action.action_name || action.sys_id);
}
)}
}