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

Sohail Khilji
Kilo Patron

copy paste this code :

answer = ifScript();

function ifScript(){
    var grr= new GlideRecord('sys_attachment');
    grr.addQuery('table_sys_id', current.sys_id); // also try for file name if needed
	grr.query();
	if(grr.next()){
		return true;
	}else{
		return false;
	}
}

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji ,

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.

 

For this you you need to adjust the workflow to check if the current record is added with attachement in the 'wait for condition'. based on the condition it will move the flow forward...

 

also remember the flow will not move forward unless you nudge the ritm table as your checking for the condition on attachement table.


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

@Sohail Khilji 

 

Can we try this in client script??

 

Hi @sanvi,

 

Yes you can try in onSubmit client script 

function onSubmit() {
 
    if (g_form.getValue('your_variable') == "your_variable_value") { // This is the field value of the question you want to check
        try {

            var msg = 'This request requires an attachment. Please review the form and try again.';
          
  var attachments = document.getElementById('header_attachment_list_label');
  
            if (attachments.style.visibility == 'hidden' || attachments.style.display == 'none') {
                alert(msg);
                return false;
            }
        
        }

        //For Service Portal
        catch (e) {
            var count = getSCAttachmentCount();
            if (count <= 0) {
                alert(msg);

                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.