- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2019 10:21 AM
Greetings everyone,
I have the following problem.
I got one type of record that needs to be filled with specific attachments. So I made a section in the form with "File Attachment" fields because i need to keep track of which file was attached and which wasn't.
Something like this.
I managed to make a Business Rule that checks if there are attachments missing, if so, it shows a message at the top of the screen saying "The following files are missing: " and it shows which ones are missing.
The problem is, if I attach a file, update the record and then remove the file, the form won't recognize that a file is missing anymore.
I don't understand why it does that.
Can someone help me? Tell me if you need more info.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 06:32 AM
So... what I found out was that the File Attachment Field is a mess.
When the field is empty for the first time, it is ACTUALLY empty, so you can use the business rules condition like "IF FIELD IS EMPTY" and it'll work.
The problem is, when you upload a file and then delete it, the field doesn't become empty again. Instead it deletes the file from sys_attachment table (as expected) but the field itselft stays with the value of the sys_id of the last file (don't ask me why).
So I had to make a Insert/Update business rule with a script that searches for the sys_id of the file on the sys_attachment table, like this:
att.addQuery('sys_id',current.u_file_attachment_1);
att.query();
if(att.getRowCount()>0){
current.setValue('u_choice_1','true');
}else{
current.setValue('u_choice_1','false');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2019 10:43 AM
Hi Samuel,
I believe you are using the Business rule as only on insert not on update, and that is the only reason that when you create/insert the record the business rule is triggered and checks for the attachment but when it is updated the business rule is not triggered.
Please check the update check box as true in your business rule.
Please mark my answer as correct/helpful based on the impact.
Regards,
Alok

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2019 11:23 AM
you can give a try with before-insert- update Business Rule instead of display business rule,
Also,
you can refer to the below link:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 06:32 AM
So... what I found out was that the File Attachment Field is a mess.
When the field is empty for the first time, it is ACTUALLY empty, so you can use the business rules condition like "IF FIELD IS EMPTY" and it'll work.
The problem is, when you upload a file and then delete it, the field doesn't become empty again. Instead it deletes the file from sys_attachment table (as expected) but the field itselft stays with the value of the sys_id of the last file (don't ask me why).
So I had to make a Insert/Update business rule with a script that searches for the sys_id of the file on the sys_attachment table, like this:
att.addQuery('sys_id',current.u_file_attachment_1);
att.query();
if(att.getRowCount()>0){
current.setValue('u_choice_1','true');
}else{
current.setValue('u_choice_1','false');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 06:35 AM
Glad you got it resolved!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2021 04:34 AM
Hi
Hope you are doing good.
I have used this script for my requirement and it is working good for showing messages. But, when I delete the attachment from the field, and saving the form it is not showing the message even document field is empty. Could you please help me on this?
Thanks