Skip to content

Conversation

@alkaChaudhary73
Copy link
Contributor

/**

  • Purpose:
  • Updating a GlideDuration field programmatically can often be challenging in ServiceNow,
  • as it requires careful handling of duration conversions and field validation.
  • This utility simplifies that process by allowing users to set GlideDuration values
  • directly from a given duration in seconds — making it a handy and efficient tool
  • for automating time-based updates through Flow Designer.
  • Usage:
    • Provide the following inputs:
  •  1. inputSecond — Total duration in seconds (e.g., 86400 for 1 day).
    
  •  2. targetTable — The name of the target table where the record exists.
    
  •  3. recordSysID — The sys_id of the record to be updated.
    
  •  4. glideDurationBackendName — The backend name of the GlideDuration field to update.
    
  • Behavior:
    • Converts the provided seconds into milliseconds and creates a valid GlideDuration object.
    • Validates that the target field is a legitimate GlideDuration field before updating.
    • Updates the specified record with the computed duration value.
    • Handles invalid input or incorrect field types gracefully.
    • On successful update, sets the output variable executed to "true"; otherwise remains "false".
  • Example:
  • inputSecond = 94500 (1 day, 2 hours, 15 minutes)
  • targetTable = "incident"
  • recordSysID = "9c573169c611228700193229fff72400"
  • glideDurationBackendName = "u_duration"
  • → The script will automatically update the 'u_duration' field on the specified
  • Incident record with the equivalent GlideDuration value.
    

*/

@github-actions
Copy link

Valid PR for ActionPack

Thank you for your contribution. This PR complies with the CONTRIBUTING.md.
A maintainer will review this shortly. In the meantime, Happy Hacking!

@SapphicFire SapphicFire self-assigned this Oct 31, 2025
Copy link
Contributor

@SapphicFire SapphicFire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@SapphicFire SapphicFire merged commit 6ffe8d8 into ServiceNowDevProgram:main Oct 31, 2025
2 checks passed
@alkaChaudhary73 alkaChaudhary73 deleted the seconds-to-glideDuration branch October 31, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants