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

How to get WorkFlow context in business rule

Radim4
Tera Contributor

Hello there, I'm trying to figure out, if there is some reliable way of finding the WF Context in BR which has no relation to running WF or RITM.

The scenario:

I have a cat item which takes an xls file, uploads this file into data source, triggers the import into target table. There is a Wait for event action inside WF, this event needs to be triggered from onComplete transform script. Now how do I find the reference to the correct WF Context when I don't know the RITM id inside this onComplete script. 

The reason is that I need to update some WF scratchpad values inside the onComplete script before the WF Wait for event action is triggered. 

Right now I'm storing the RITM ID inside out internal config field, which is not acceptable:

    getWfContext: function() {
		var contextGR = null;
        var wfContextGR = new GlideRecord("wf_context");
        if (wfContextGR.get("id", this.gvsIntmUtils.getConfiguration("qualys_result.load_xls.current_ritm_id"))) {
            contextGR = wfContextGR;
        } 
        return contextGR;
    }

Thank you for any help.

1 ACCEPTED SOLUTION

Hello,

If you are parsing that excel and running transform map through script after submission of catalog item you must be gliding sys_attachment table to get the attachment which is attached to that RITM that gets created after submission and copy that attachment  from RITM to data source which will run the transform map

So if this is the process that you are following , we can glide to sys attachment table again with and get the RITM sys_id which is stored in table_sys_id field and use it in wf_context table

 

Not sure if this works but give it a try 

Please mark my answer correct if it helps you

View solution in original post

9 REPLIES 9

@Radim 

Share us the update if the solution works.

I am skeptical since in the onComplete transform script you can query sys_attachment with the data source associated with the current import set.

But the issue is when multiple users submit the catalog item then the query might fail to find the correct table_sys_id.

Regards
Ankur

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

why not handle this in the onComplete transform script itself?

I believe it would be difficult to know the RITM number in onComplete

Regards
Ankur

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

Thank you, there are many other steps inside the WF which are dependent on those scratchpad values updated in the onComplete script. 

Hi,

I doubt you would know the RITM number in the onComplete script as there might be multiple users submitting the catalog item

If not then you can query RITM with your catalog item and pick the latest one.

Regards
Ankur

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

Radim4
Tera Contributor

Thank you for quick reply. The target table is custom table.