- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 11:08 AM
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?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 12:02 PM
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);
Vinod Kumar Kachineni
Community Rising Star 2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 11:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 11:13 AM
The tf is a string . and Yes, I want an action for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 11:22 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2022 12:02 PM
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);
Vinod Kumar Kachineni
Community Rising Star 2022