current.setAbortAction(true) causes the error message 'Invalid update'

Andrew Pishchul
Giga Expert

Guys,
I got stuck with current.setAbortAction(true) in a business rule... I have a simple business rule on an incident table:
When:

Before

Update:
yes

Condition:
current.category=='Software'&& !current.hasAttachments()

Script:
gs.addInfoMessage("No attached documents found! Operation cancelled.")
current.setAbortAction(true);


But this rule causes and error message 'Invalid update' when I try to save an incident without attachments and with Category='Software'. My custom info message will be displayed as well, but why 'Invalid update' is there???
16 REPLIES 16

What about doing an 'OnSubmit' Client Script, with an AJAX or function call to verify an attachment exists? If no Attachment display a message and abort Submit.


Yes, if we are talking about attachments then there is a very nice solution for that (onSubmit client script):



function onSubmit() {
var attachments = document.getElementById('header_attachment_list_label');
if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none' ) {
alert('You must attach at least 1 file.');
return false;
}
return true;
}


...but if we are talking about how to get rid of 'Invalid update' message caused by a business rule, there is no good solution for that. Just don't use abort function in a business rule.


HI Everyone,



Please let me know is there any way to suppress "Invalid Update" in business rule itself.



Could any one can help me with this.




Thanks,


Alekhya N


Jeet
Tera Expert

Hi Andrew,



I think for this table you have written few more business rules that might be before or after "insert/update". While inserting this new record one of your business rule is not letting them to insert/update a record and may be another business rules are executing. (This is the only reason you are getting "Invalid Insert/ Invalid Update" error message because you have used setAbortAction(true) somewhere)



So my best suggestion to you, You can give execution order for created business rule otherwise you can write one client script onSubmit() and return false if you don't want to insert new record on certain condition.



Note: Write a client script, Client script is not recommended for best practice as well.




Thanks,


Jeet


Kushagra Mehrot
Kilo Guru

a semicolon is what is missing !