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

Prasad Pagar
Mega Sage
Hi, The first thing came in my mind is action. What is the type of 'tf' variable? Thank you

Community Alums
Not applicable

The tf is a string .  and Yes, I want an action for this.

Community Alums
Not applicable

Here is the code i'm trying to get working.  the sysID is the inputs Label and name is sysid.

outputs is Label: TF name: tf  I get an error stating something is wrong with line 13 (last line of the code below).

(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);

find_real_file.png

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