Auto populate date

AnanyaT
Tera Contributor

I have got a requirement to auto populate the Assigned field (Data and Time field) at the time assigned to in updated.

2 REPLIES 2

GlideFather
Tera Patron

Hi @AnanyaT it's pretty simple to achieve, however it requires to understand it better - is it a variable on the service portal, a field in backend or workspace form?

 

Please describe it or take a screenshot and it'll be easier to advice you.

 

  • for a backend field
    • Specify the table where the field is added
    • It can be for example a business rule - applied on that table
    • you set the conditions when you want to set that values and do something like the example below:

GlideFather_0-1754933957339.png

 

 

  • if it is a record producer it can be added to the script field:
var gdt = new GlideDateTime();
current.field_name = gdt; //rename the field accordingly

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Shashank_Jain
Kilo Sage

Hello @AnanyaT ,

 

As I understand it, you want a scenario where, if the 'Assigned To' field is updated on a table, a custom field should be populated with the updated date and time."

 

You can write business rule for this :

 

  • Table: The table you want this to run on (e.g., incident, task, etc.)

  • When to Run:

    • When: before

    • Update: checked

  • Advanced: checked (put your script here)

Script -
(function executeRule(current, previous /*null when async*/) {
 // Check if the assigned_to field was changed
    if (current.assigned_to.changes()) {
        current.u_custom_assignedtofield = new GlideDateTime();
    }
})(current, previous);

Mark this reply helpful if you find the solution so that it close the thread.
Thank you!
 
 

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain – Software Engineer | Turning issues into insights