Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

I need to have the activity stream record to change color based on conditions

Jerome MAISETTI
Mega Guru

Hello 
I have users that got the vip_customer role. 
When user with this role adds a comment, I would like the border of the activity stream entry to be red. 
Is this feasible ? Does anyone know how to it ? 

I tried the following OnChange Client Script in Global but it doesn't work : 

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
    // Wait for the DOM to be fully loaded
    document.addEventListener('DOMContentLoaded', function() {
        // Get the current user's VIP flag value
        var isVIP = g_user.hasRole('vip_customer'); // Assuming 'vip' is the role name for VIP users

        // Get the activity record element
        var activityRecords = document.querySelectorAll('.activity-stream-item.comments'); // Assuming this selector targets external comment activities

        // Check if the user is VIP and the activity record exists
        if (isVIP && activityRecord) {
            // Change the background color of the activity record to red
            activityRecord.style.backgroundColor = 'red';
        }
    });
   //Type appropriate comment here, and begin script below
}

 

 

This is an example of what I want to achieve : 

JeromeMAISETTI_0-1708438182432.png

 

Thanks, 
Jérôme

2 REPLIES 2

Mark Manders
Giga Patron

In don't think you are going to achieve that and the question is also: why would you want that? Besides from seeing what the system can do, I see no real use case here. If a VIP comments to a ticket, make the number red, could be something I could understand (if it's not already done, because the VIP is the caller of the ticket). But making a rainbow of the ticket, doesn't really make sense to me. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Dr Atul G- LNG
Tera Patron

Hi @Jerome MAISETTI 

May I know the use case, and OOTB it is not available? It will increase your technical debt. 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************