Add two fields date and time and then auto populate this two data into another field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 05:03 AM
I have two fields 1. error -- type is date and time
2. SUN Mints---type is date and time
I want to add two fields and then data is auto- populated into 3 field
3. End date----type is date and time
I wrote a script but it is not working could you please help on this
Thaks for the support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 05:10 AM
Hi @vinod6
Could you please share your script?
It'll be helpful for others to debug.
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 05:14 AM
Hello @vinod6
Please share script.
Kindly mark my answer as helpful and accept solution if it helped you in anyway,
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2025 05:31 AM
HI @vinod6
I'm unsure about our script.
But i just tried in my PDI by using the below script and it worked.
Note: I've considered SLA definition table as a sample table to test your scenario. Please replace the table and field names as required.
var gt = new GlideRecord("contract_sla"); // replace with your table
gt.get('00e277560f6233004fbc309c4e767e1e'); // sys id of the record, replace with your record syid/logic
var str = gt.getDisplayValue('duration').toString(); // Duration field from SLA definition table
gs.print(str);
var days = str.split(" ")[0]; // Hours
var hr = str.split(" ")[2]; //Days
var min = str.split(" ")[4];//Mins
var hr_secs = parseInt(hr)*3600 + parseInt(min)*60; // converting hours and minutes to seconds
var up = gt.getDisplayValue('sys_updated_on'); // Picking the date field to add the duration
var dt = new GlideDateTime(up);
dt.addDays(parseInt(days));
dt.addSeconds(parseInt(hr_secs));
gs.print(dt.getValue());
Result:
Sample record:
Script output:
Hope this helps.
Regards,
Siva