The CreatorCon Call for Content is officially open! Get started here.

Making attachment mandatory on RITM after closure of task

sanvi
Tera Expert

Hi All,

 

I have a requirement.

Attachment should be made mandatory on RITM after closure of a task which is driven by a workflow.

Tried adding in the workflow but its not working out. Have added below script in the if condition in the workflow.

 

Even though there is no attachment the workflow is end

answer = ifScript();

function ifScript(){

if(current.hasAttachments())

return 'yes';

else

return 'no';

}

 

Could someone help me how to achieve this?

9 REPLIES 9

dgarad
Giga Sage

Hi @sanvi 

can you try the below code?

function onSubmit() {
var grAtt = new GlideRecord("sys_attachment");
grAtt.addQuery("table_name", "sc_cart_item");
grAtt.addQuery("sys_created_by", g_user.userName);
grAtt.query();
if (!grAtt.next()) {
alert("You must attach a vendor quote to submit this request");
return false;
}
return true;
}

 

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

Mohan raj
Mega Sage

Hi @sanvi,

 

Try below script it may help you.

answer = ifScript();
function ifScript(){
	var att = new GlideRecord('sys_attachment');
    att.addQuery('table_sys_id', current.sys_id); // request item's sys_id
	att.query();
	if(att.next()){
		return true;
	}else{
		return false;
	}
}

 

If my response helps you to resolve the issue close the question by Accepting solution and hit thumb icon. From Correct answers others will get benefited in future.

Hi @Mohan raj ,

The script is working but, the workflow should not progress further until there is an attachment in the RITM.

Once there is an attachment i want to flow to proceed further.

 

Hi @sanvi,

 

try with wait for condition activity