Mandatory Attachment on Closed Complete Task

gnunez
Kilo Guru

Hello,

I currently have a business rule in place to make attachments mandatory before a  task is closed. The requirements have changed and we only want it to be mandatory when it is closed complete. If the task is being closed "incompletely" or "skipped", the attachment should not be mandatory.

I already changed one of my conditions, which I changed from State is one of Closed Complete, Closed Incomplete, Closed Skipped to State is not one of Closed Incomplete, Closed Skipped. After the change the attachment is still mandatory, which makes me think it has to do with the Close Task button.

Any assistance with this would be greatly appreciated!

This is what I currently have:

find_real_file.png

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Pranay Tiwari
Kilo Guru

Hi,

Change the condition,use this condition state is closed complete ,

and follow below code...Before (insert/update) BR

(function executeRule(current, previous /*null when async*/) {

 var gr= new GlideRecord("sys_attachment");
 gr.addQuery("table_sys_id",current.sys_id);
 gr.query();
	
 if (!gr.hasNext()) {
 gs.addErrorMessage("Attachment is required to submit this Request");
 current.setAbortAction(true);
 }
 
 
})(current, previous);

 

it will work perfectly..

 

Mark correct or helpful if it helps you.

 

Warm Regards,

Pranay Tiwari

| www.DxSherpa.com | pranay.tiwari@dxsherpa.com |

View solution in original post

16 REPLIES 16

jschlieszus
Kilo Guru

Just something that stood out to me, when you changed the state condition in the BR from IS ONE OF (closed complete/incomplete/skipped) IS NOT ONE OF (closed incomplete/skipped) you are actually picking up ALL of the other state values.  If it should only trigger on state is closed complete, then set state IS closed complete.

Pranay Tiwari
Kilo Guru

Hi,

Change the condition,use this condition state is closed complete ,

and follow below code...Before (insert/update) BR

(function executeRule(current, previous /*null when async*/) {

 var gr= new GlideRecord("sys_attachment");
 gr.addQuery("table_sys_id",current.sys_id);
 gr.query();
	
 if (!gr.hasNext()) {
 gs.addErrorMessage("Attachment is required to submit this Request");
 current.setAbortAction(true);
 }
 
 
})(current, previous);

 

it will work perfectly..

 

Mark correct or helpful if it helps you.

 

Warm Regards,

Pranay Tiwari

| www.DxSherpa.com | pranay.tiwari@dxsherpa.com |

Hi and thanks for the reply!

It did give the error message saying Attachment is required, but the task was still closed(see below):

find_real_file.png

Reload the form and the state will go back to it's previous value.  With set abort action it just stops the DB transaction.  If you like, you can set current.state = previous.state just prior to the abort.

Yes, thank you!