Ankur Bawiskar
Tera Patron

@Prati123 

wait for condition only works if workflow is waiting on current record.

your workflow wait script is checking sys_attachment but workflow is on other table (Demand)

you need to broadcast update to that workflow so that it check the wait for condition script again

use this in your business rule

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

    var attGR = new GlideRecord('sys_attachment');
    attGR.addEncodedQuery('table_sys_id=' + current.getUniqueValue());
    attGR.query();
    if (attGR.next()) {
        var gsa = new GlideSysAttachment();
        gsa.copy('sys_email', attGR.table_sys_id, 'dmn_demand', current.instance.sys_id);

        var record = new GlideRecord('dmn_demand');
        record.get(current.instance.sys_id);
        new Workflow().broadcastEventToCurrentsContexts(record, 'update', null);
    }

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post