Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Javascript que muestra valores particulares de múltiples posibilidades

Tengo una lista de proyectos con diferentes estados (Rojo, Amarillo, Verde y Ninguno) Esos están asignados a un programa en particular. Necesito asignar a la variable el color más crítico asignado al programa. Si hay al menos un rojo, necesito mostrar rojo (sin importar si hay otros amarillos o verdes). Si el más crítico es amarillo, necesito mostrar amarillo, sin importar si hay verdes. Si solo hay verdes, necesito mostrar Verde. Si no hay ninguno asignado, necesito mostrar ninguno. El siguiente código está bien para 3 de ellos, no sé cómo agregarle ninguno exactamente. Todos los valores son cadenas.

Saludos Piotr

 function getProjectStatusProgram(program){ var status = ''; var grPrgTask = new GlideRecord('project'); grPrgTask.addQuery('u_program', program); grPrgTask.query(); while (grPrgTask.next()){ if (grPrgTask.overall_health == 'red'){ status = "red"; break; } else if (grPrgTask.overall_health == 'yellow'){ status = 'yellow'; } } if(status =='red' || status =='yellow') return status; else return 'green'; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Ejemplo teórico, ya que no tengo todo el código en cuestión.

 /*** Returns a string with following task status priority: 1: "red": if atleast one task has status "red" 2: "yellow": if atleast one task has status "yellow" 3: "none": if atleast one task has status "none" 4: "green": if no task has either status "red", "yellow" or "none" **/ function getProjectStatusProgram(program){ //REM: Set default status to "green" due to "If there are only greens I need to display Green" var status = 'green'; var grPrgTask = new GlideRecord('project'); grPrgTask.addQuery('u_program', program); grPrgTask.query(); while(grPrgTask.next()){ //REM: "If there is at least one red I need to display red( no matter if there are other yellows or greens)" if(grPrgTask.overall_health == 'red'){ status = "red"; break; }; //REM: "If the most critical one is yellow I need to display Yellow, not matter if there are greens." if(grPrgTask.overall_health == 'yellow'){ status = 'yellow' } //REM: If current status is still "green" and this tasks status is "none" -> "none" //REM: Since it is only "green" if all are "green" else if(status == 'green' && grPrgTask.overall_health == 'none'){ status = 'none' } }; //REM: Just return the status return status }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!