Approval tab change request

servicenow14710
Tera Expert

I need color coding on approvals tab . how can this be achieved in right way. Thanks

 

img.png

 

2 REPLIES 2

Amit Gujarathi
Giga Sage
Giga Sage

 Hi @servicenow14710 ,
I trust you are doing great.

  1. Identify the field or condition: Determine the criteria or field value that will trigger the color coding. For example, you might want to color code approvals based on their status, priority, or any other relevant field.

  2. Define color codes: Decide on the color codes you want to use for different conditions. You can choose from predefined colors or define your own custom colors. For example, you can use green for approved, red for rejected, and yellow for pending approvals.

  3. Create a UI Policy or Client Script: Use a UI Policy or Client Script to dynamically update the color of the approvals based on the defined conditions. Here's an example of how you can achieve this using a Client Script:

 

function onLoad() {
  var approvalStatus = g_form.getValue('approval_status'); // Assuming 'approval_status' is the field containing the approval status
  
  // Apply color coding based on the approval status
  if (approvalStatus == 'approved') {
    g_form.setLabelOf('approval_status', '<span style="color: green;">Approved</span>');
  } else if (approvalStatus == 'rejected') {
    g_form.setLabelOf('approval_status', '<span style="color: red;">Rejected</span>');
  } else if (approvalStatus == 'pending') {
    g_form.setLabelOf('approval_status', '<span style="color: yellow;">Pending</span>');
  }
}

 

  1. Attach the script to the appropriate form: Once you have the script ready, you need to attach it to the relevant form. This will ensure that the color coding is applied whenever the approvals tab is loaded.

  2. Test and refine: Test the color coding on the approvals tab to ensure it's working as expected. Make any necessary adjustments to the script or conditions if needed.


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



@Amit Gujarathi : Hello amit, thanks for quick response

I tried using this for change request approvals where in i used this code on client script onload for sysapproval_approver table. But this isnt changeing colors. Can you please let me know if im missing anything here.Thanks.