In regards to the calculation between two record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I need a calculation between two records in my app engine. I am currently working in dev environment - sandbox and needed to get a column which gives the difference between two fields.
as a example:
column 1: due date - 08/31/2025
column 2: lead time - 30
output : start date: 08/31/2025 -30 = 07/31/2025
and i want to use this a trigger daily on flows. How i can get this difference in my instance. I tried using formula but not working. my instance is currently not allowing me to script anything. can anybody let me know the logic can be used?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
It didn't work for me yet. not sure if i need to have a advance writing access to get this done. currently i am using service now dev sandbox environment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You can use GlideDateTime to achieve your requirement.
For example, consider below record from Hardware table. For demonstration purpose, take 'purchase date' as the 'start date' in your logic and assume you have a field 'lead time'. You can calculate 'due date' using below script,
var gr = new GlideRecord('alm_hardware');
gr.addQuery('sys_id','=','0ea9604d3790200044e0bfc8bcbe5d35');
gr.query();
while (gr.next())
{
var start_date=gr.purchase_date;
gs.print("Start Date is : " + start_date);
var due_date=new GlideDateTime(gr.purchase_date.getGlideObject());
var lead_time=30;
due_date.addDaysLocalTime(lead_time);
gs.print("Due Date is : " + due_date);
}
If this helped to answer your query, please accept the solution and close the thread.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I was trying here @Bhuvan @GlideFather