- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2025 11:52 AM
Hi I need to mapping the date and hour from catalog to ritm, like this:
variable from catalog
u_fecha = "13-03-2025"
u_horario = "11:30"
field RITM:
u_std_fecha_programada_inicio = 2025-03-13 11:30:00
u_std_fecha_programada_fin = 2025-03-13 12:30:00
SCRIPT:
var fecha = current.variables.u_fecha; // Formato esperado: YYYY-MM-DD
var hora = current.variables.u_horario; // Formato esperado: HH:mm (24h)
// Validar que los valores existen
if (fecha && hora) {
// Crear fecha de inicio combinando fecha y hora
var fechaInicio = new GlideDateTime(fecha + " " + hora);
// Clonar fechaInicio y sumarle 60 minutos (3600 segundos)
var fechaFin = new GlideDateTime(fechaInicio);
fechaFin.addSeconds(3600);
// Asignar valores sin usar update() para evitar loops
current.setValue("u_std_fecha_programada_inicio", fechaInicio);
current.setValue("u_std_fecha_programada_fin", fechaFin);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2025 08:15 PM
It's work on mine. Are these two variables in the correct format as the comment next to them?
var fecha = current.variables.u_fecha; // Formato esperado: YYYY-MM-DD
var hora = current.variables.u_horario; // Formato esperado: HH:mm (24h)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2025 08:27 PM
Hi, scl_amorale
Your script is missing seconds when add time to the variable.
Update the line 6 to this below code.
var fechaInicio = new GlideDateTime(fecha + " " + hora + ":00");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2025 06:28 AM
Hi , is not working, for example I selected in my catalog "Horario: 11:30", but in RITM appear 8:30 and 9:30. Should be appear 11:30 and 12:30
(Horario is a text variable)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2025 08:15 PM
It's work on mine. Are these two variables in the correct format as the comment next to them?
var fecha = current.variables.u_fecha; // Formato esperado: YYYY-MM-DD
var hora = current.variables.u_horario; // Formato esperado: HH:mm (24h)