How do I use a script action to show an error and abort action on another table?

Stacy1
Mega Guru

I have a business rule on the sys_journal_field table checking for bad characters and lengths when someone uses post in the comments field on the Case Table.

I have created an event but I don't really understand what I am supposed to past to the event and how I get it to display the error and abort the action on the case table thru the script action.

Can anyone explain how to do this?

Thanks,

Stacy

4 REPLIES 4

Allen Andreas
Administrator
Administrator

Hi,

In the business rule (or even onSubmit client script), you can check for bad characters, etc. in the submission that just took place.

Is there a reason you're doing it on the sys_journal_field table?

You evaluate for those bad characters and lengths and then in the script section of the business rule, if it's found to be something you don't want to let pass and want to abort, you'd add in the script: 

current.setAbortAction(true);

or if in onSubmit client script, just use: 

return false;

You can also pop-up an info message or error message to tell the user why, if you wish in business rule:

gs.addErrorMessage("Not allowed");

or if in client script, just use:

g_form.addInfoMessage("Not allowed");

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

I have a client script already on the Case Table.  This only works for the onChange and the onSubmit. The onSubmit only happens if they use 'save' or 'update'.  If they put in the comment's they get the onChange error, but that does not prevent them from using Post which does not count as a submit of the form.

The Post button on comments goes to the sys_journal_field. Therefore I have to write a script on the sys_journal_field to catch the error and then return the error to the case form.  

Thanks,

Stacy

Hi,

We were not aware you already had a client script or scripts on the case table, so thanks for providing that information 🙂

The onSubmit would only trigger if they posted those comments as part of a save/submit, but yes, you're correct, if they don't do it as a save/submit, then it doesn't trigger that. You could address this in an onChange. You could assist with clearing the bad characters for them and you could assist with truncating their post if past the length and furthermore alert them to the issue right then. It doesn't prevent them from submitting, but you've given a heads up and allows them to correct it before it's "gone" once they click post.

As far as aborting it, you can abort on either the table itself (case) or sys_journal_field. This can be done using the script I mentioned above. This can be obviously be written after you've done your evaluation of the text to determine if it should or should not be aborted. Overall point here is, you can abort within that same BR. However, as mentioned above, the comments are gone anyway. So it does prevent it from posting officially to the record, but they're gone. As far as alerting them to it, it doesn't appear you can when using the post button. In some testing I just did, the error message doesn't show up until there's the screen is refreshed using either table. So because the comments post button doesn't cause that refresh, they won't see it and you can't really push anything to it. I've tried through field messages and form messages and neither get through until you refresh.

So...it would appear that your last resort would be to try and address this through DOM manipulation and tapping in to the 'onClick' function of that button to try and address things, but that is not recommended at all.

Unless someone else comes up with some alternative, I think this is about all there is.

Please mark reply as Helpful/Correct, if applicable. Thanks!

 

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

I just wanted to check-in on this. If my reply above helped guide you correctly, if you don't mind, please mark it as Helpful & Correct.

Thank you!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!