ITSM Workflow Question

sanjaybagri
Tera Contributor

Hello Team,

 

I have a requirement : 

I am submitting the request and there we have certain approval after the creating the change request from the Run Script activity of the workflow in that workflow i want to wait till change request state should  move to implement state and once Change moves to implement then calling API for Integration.

 

Most of the thing are working as expected but only wait for condition is not working. i tried many approaches: 

1. When ever wait for condition is triggering then executing first time and returning the new value but i want implement state value. 

2. Wait for WF Event : this activity i used eventQueue & gs.eventQueueScheduled, Created event in event registry and triggering the event by Business Rule , Same event name passed in activity . before and after eventQueue info is generating but not moving in next activity.

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

gs.info("BR 1 ");
    if (current.state.changesTo(-1)) { // Replace 3 with your "Implemented" state value
        var journalGR = new GlideRecord('sys_journal_field');
        journalGR.addQuery('element_id', current.sys_id);
        journalGR.addQuery('element', 'work_notes');
        journalGR.orderByDesc('sys_created_on'); // Get latest note first
        journalGR.query();

        while (journalGR.next()) {
            var note = journalGR.value.toString();
            gs.info("Work Note: " + note);

            var match = note.match(/RITM Reference:\s*([a-f0-9]{32})/);
            gs.info("BR 2 "+match);
			if (match && match[1]) {
                var ritmGR = new GlideRecord('sc_req_item');
                if (ritmGR.get(match[1])) {
                    gs.info("Firing event on RITM: " + ritmGR.number);
                    gs.eventQueueScheduled('change.implemented', ritmGR, ritmGR.sys_id, ritmGR.number);
		   gs.info("Firing event on RITM after " + ritmGR.sys_id);
                    } else {
                    gs.error("RITM not found for sys_id: " + match[1]);
                }
                break; // Stop after first match
            }
        }
    }
})(current, previous);

 

 

I need help on Wait for condition step. 

Workflow is created in RITM Table and I want wait for change request. 

Please let me know if you need any additional information. 

 

Thanks a lot in advance and your support will be appreciate. 

 

Thanks

Sanjay Bagri

 

1 REPLY 1

Swapna Abburi
Mega Sage
Mega Sage

Hi @sanjaybagri 

When the BR is executed, can you see if event is created in Event log table? also, try replacing "gs.eventQueueScheduled" with "gs.eventQueue" method as you are not using any future date for event trigger.

 

SwapnaAbburi_0-1759259479644.png