- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 03:01 AM
I have a system property and the type is Integer, and the value is 300. After the trigger condition wait 300 seconds of time then execute the remaining flow. But waiting time need to be dependent on the system property value. Can you please help me on this.
If use script action to wait the time please let me know what is the input and output I have to take and what are types needs to take.
Hi Sir @Ankur Bawiskar, As suggested previously I have changed the System property value to 1970-01-01 0:00:00. but my requirement is taking only in the system property type is integer and Value is 604800. It is possible to do this way sir?, if possible please help me on this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 03:59 AM
If you just create a new flow variable 'waitUntil' of type 'date/time' in your flow. You can set your flow variable with this script:
var wait = gs.getProperty('removed_group');
var now = new GlideDateTime();
now.addSeconds(wait);
var waitUntil = now.getValue();
return waitUntil;
It returns the date/time of now + 300 seconds. You can use that in your 'Wait a duration of time' action:
By waiting 0 seconds after that time has passed, you are in fact setting it to the date/time you set your variable to.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 03:16 AM
You could create a flow variable and script it's value. Get the current date/time and add the value from the system property (you may need to do some calculation as you probably need to get it to be set in milliseconds).
Then you can use the 'Wait for a duration of time' action with a relative duration to wait 0 seconds after the variable.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 03:22 AM - edited ‎12-10-2024 03:26 AM
Hi @Mark Manders , can you please help me on the script, I have tried this. I have tried with taking output variable type is string, duration, Integer. But I am unable to select output variable value in the Wait for duration by selecting duration type is 'Relative or Percentage'.
(function execute(inputs, outputs) {
outputs = outputs || {};
// Fetch system property value in seconds
var inputSeconds = gs.getProperty('removed_group');
var outputDuration = "";
var durationISO = "PT"; // ISO 8601 format for duration
gs.info("Retrieved inputSeconds: " + inputSeconds);
if (inputSeconds && !isNaN(parseInt(inputSeconds, 10))) {
inputSeconds = parseInt(inputSeconds, 10);
gs.info("Parsed inputSeconds as integer: " + inputSeconds);
// Calculate minutes and seconds
var minutes = Math.floor(inputSeconds / 60);
var seconds = inputSeconds % 60;
var hours = Math.floor(minutes / 60); // Calculate hours
minutes = minutes % 60; // Adjust minutes after extracting hours
gs.info("Calculated hours: " + hours + ", minutes: " + minutes + ", seconds: " + seconds);
// Construct the output duration (human-readable format)
if (hours > 0) {
outputDuration += hours + " hour" + (hours > 1 ? "s" : "");
durationISO += hours + "H";
}
if (minutes > 0) {
outputDuration += (hours > 0 ? " " : "") + minutes + " minute" + (minutes > 1 ? "s" : "");
durationISO += minutes + "M";
}
if (seconds > 0) {
outputDuration += (hours > 0 || minutes > 0 ? " " : "") + seconds + " second" + (seconds > 1 ? "s" : "");
durationISO += seconds + "S";
}
gs.info("Constructed outputDuration: " + outputDuration);
gs.info("Constructed ISO duration: " + durationISO);
// Assign ISO duration to outputs.timer
outputs.timer = outputDuration;
outputs.durationISO = durationISO;
gs.info("Assigned outputDuration to outputs.timer: " + outputs.timer);
gs.info("Assigned ISO duration to outputs.durationISO: " + outputs.durationISO);
} else {
gs.info("Invalid inputSeconds value. Setting default 'Invalid input value'.");
outputs.timer = "Invalid input value";
outputs.durationISO = "PT0S"; // Default to zero seconds in ISO format
}
// Final output assignment log
gs.info("Final outputs.timer value: " + outputs.timer);
gs.info("Final outputs.durationISO value: " + outputs.durationISO);
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 03:59 AM
If you just create a new flow variable 'waitUntil' of type 'date/time' in your flow. You can set your flow variable with this script:
var wait = gs.getProperty('removed_group');
var now = new GlideDateTime();
now.addSeconds(wait);
var waitUntil = now.getValue();
return waitUntil;
It returns the date/time of now + 300 seconds. You can use that in your 'Wait a duration of time' action:
By waiting 0 seconds after that time has passed, you are in fact setting it to the date/time you set your variable to.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2024 04:55 AM
Create a Flow Variable
Use Set Flow Variables action
Script in the getProperty method.