see if anything is in Additional Comments

Community Alums
Not applicable

In regards to Flow Designer Actions. I am trying to figure out how to create an action that will look through the sys_journal_field table (which I know how to access)  I just need to see if there has been an entry since the time the SCTASK was created. Again easy enough to do in javascript.  But I don't know how to translate the JS to an Action to hold basically a true/false value so I can use that action as a condition to put a flow into a wait condition if it's true.   I will also need to run this same thing again in a different part of the script to see if any new comments were added in the last 2 days I think I can just use something in the if statement to see if the comment was in the getdate() - 1 should work for the condition.  The output needs to be the same as a true/false in a variable I can use.

So here is the Javascript you will have to change the sys_id if you wanted to run it

My input is sysID which is the sys_id of the record and is in the addQuery line in the javascript below

var gdt = new GlideDatetime();
var gr = new GlideRecord('sys_journal_field');
  gr.addQuery('element_id', sysid);
  gr.query()
  while (gr.next()) {
    
    if (gr.sys_created_on < gdt) {
      outputs.tf = 'true';
    } else {
      outputs.tf = 'false';
    }

I had the above script in an action I was trying to build, however, I'm getting an error on the action.  the outputs.tf is the output string. I need to have either be true or false.

Could someone help me build the action?  Or point me into a really good tutorial or built-in Action that would show me how to do this I could follow?

1 ACCEPTED SOLUTION

You are missing a } to close the function

(function execute(inputs, outputs) {
// ... code ...
	var gdt = new GlideDateTime();
	var gr = new GlideRecord('sys_journal_field');
	gr.addQuery('element_id', inputs.sysID);
	gr.query()
	while (gr.next()) 
	{
		if (gr.sys_created_on < gdt) { 
			outputs.TF='true' ; 
		} 
		else 
		{ 
			outputs.TF='false' ; 
		} 
	}
})(inputs, outputs);
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

View solution in original post

6 REPLIES 6

Community Alums
Not applicable

Wow, can't believe I missed that.  Ok so how to I get the true false in the outputs so I can use that in the Flow design?  I thought I had outputs but those were variable outputs. So I guess my question is do I do a variable output then pass that to outputs in the action?

 

Community Alums
Not applicable

Oh I figured out how to get the outputs, no need to respond.  Thank you for looking at the code and pointing out the error.  It saved me a bunch of time banging my head against a wall 🙂