Help with Flow designer code (autoassign "assigned to" field)

cicgordy
Tera Guru

Hi all,

 

I have a few subflows and I need to add a code in flow designer, within the "assigned to" field code snippet when creating a "catalog task action" (image below)

cicgordy_0-1677593757465.png

I need to auto-assign the same person that user would assign this particular task to, to subsequent tasks that creates after in other subflows(so perhaps by using short description name of other tasks).

So I guess I will need to add a code into subsequent tasks "assigned to fields" where I will need to copy same person assigned for previous task. 

Anyone can help in writing this code? 

 

Many thanks

1 ACCEPTED SOLUTION

Hi,

Yea, so have you went to your list view of RITMs and found the RITM you're testing with and double checked that it actually has an SCTASK associated to it with the short description as you're showing?

 

Just to add more to all this, I have now gone to the level of effort to build a flow and subflow in my own instance to this does work...

 

 

var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", fd_data.subflow_inputs.ritm.sys_id);
gr.addQuery("short_description", "Provide requested service");
gr.query();
if (gr.next()) {
  return gr.getValue("assigned_to");
}

 

So in my example script, my input was the RITM trigger record in the parent flow. Keep in mind that you need to test the subflow separately from testing the main flow. Otherwise, do a full execution of the flow in a real test (not a flow designer test) OR...ensure your subflow is Published, not just saved, and then run test from parent flow.

 

I'm starting to run out of options to assist further without asking that you start all over again with providing precisely what you have today with full screenshots and everything...which I hope we don't need to do. I know what I've provided is working.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

16 REPLIES 16

Thanks @Allen Andreas.

 

I tried both the above but still not working. 

Hi,

At this point, I'm wondering if the query is even returning any result, because the return is only set to return the string value if there's a query result found. If you go into background script within your instance, and use the script you have, you only gave it here in a screenshot, so I can't copy and paste it, but instead of the return line you use:

gs.info(gr.getValue('assigned_to'));

When you run that with your script, do you see a sys_id showing in the result?

Ensure you have the sys_id of the RITM in your background script test as well.

If you don't see a result, then it's an issue with the RITM you're using as far as the sys_id or the name of the SCTASK isn't being found (it may be case sensitive). So you'd want to double check in list view of RITMs...find that one, open it, find related sc task list at bottom and double check the short description, etc.

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

cicgordy_0-1677694201408.png

no results at all

 

Hi,

Yea, so have you went to your list view of RITMs and found the RITM you're testing with and double checked that it actually has an SCTASK associated to it with the short description as you're showing?

 

Just to add more to all this, I have now gone to the level of effort to build a flow and subflow in my own instance to this does work...

 

 

var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", fd_data.subflow_inputs.ritm.sys_id);
gr.addQuery("short_description", "Provide requested service");
gr.query();
if (gr.next()) {
  return gr.getValue("assigned_to");
}

 

So in my example script, my input was the RITM trigger record in the parent flow. Keep in mind that you need to test the subflow separately from testing the main flow. Otherwise, do a full execution of the flow in a real test (not a flow designer test) OR...ensure your subflow is Published, not just saved, and then run test from parent flow.

 

I'm starting to run out of options to assist further without asking that you start all over again with providing precisely what you have today with full screenshots and everything...which I hope we don't need to do. I know what I've provided is working.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi @Allen Andreas ,

That worked fine, you're amazing!! Thank you so much for your precious help 🙂