How to Get SC Task Closed Date in Flow Designer Script Step
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 08:14 AM
Hi Community,
I'm working with Flow Designer and I have a flow triggered by an SC Task. I want to retrieve the closed_at date of that SC Task and use it in a Flow variable called revokeAccess.
// i am using this in my background script to get the closed date help me to get in my flow script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 08:26 AM
Hi @LokeshwarRV
you should do it via GlideRecord instead of GlideDateTime
No AI was used in the writing of this post. Pure #GlideFather only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 08:33 AM
if the flow trigger is on sc_task you can directly access the closed_at field.
Why to use Flow variable?
IF you still require then
you can use "Set Flow Variables" flow logic and use script to set the value
something like this in the f(x) inline script
return fd_data.trigger.current.closed_at.toString();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @LokeshwarRV !!
Since your flow is already triggered by an SC Task, you don’t need to query the sc_task table again with a GlideRecord. The triggering record is already available in Flow Designer.
Best practice (no script required)
Create your flow variable revokeAccess (type: Date/Time).
When setting the value, simply use the data pill:
Trigger → SC Task → Closed atThis directly gives you the closed_at value of the SC Task.
If you need to use a Script step
If you want to process the value in a Run Script action, reference the trigger record instead of using a new GlideRecord:
(function execute(inputs, outputs) {
if (inputs.task.closed_at) {
var closedAt = new GlideDateTime(inputs.task.closed_at);
outputs.revokeAccess = closedAt.getValue();
}
})(inputs, outputs);Configuration:
Input:
task → Data pill → Trigger → SC TaskOutput:
revokeAccess → Date/Time (or String)
Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.
Regards,
Vaishnavi
Associate Technical Consultant
