Skip to content

Commit 9973350

Browse files
authored
Codesnippet - check inactive user from List and apply field style (#1701)
* Apply Field Style on List type field based on condition If one of the reviewers is inactive, highlight the corresponding column in list view. * Apply Field Style on Reviewers if anyone is inactive * Check inactive user in the List type field and apply Style * Apply Field Style on Reviewers if anyone is inactive
1 parent ac2d8b0 commit 9973350

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
There is a list type field named 'Reviewers' on Policy records.
2+
On the list view of Policies, we want to highlight with field styles, where any of the user listed under Reviewers is inactive.
3+
In the screenshot attached below, Daniel Zill is inactive user, and if he is present in Reviewers, the respective column value is applied with defined field styles.
4+
<img width="809" height="370" alt="image" src="https://github.com/user-attachments/assets/b483207e-f3ba-4db7-a717-d392694eaf50" />
5+
<img width="433" height="107" alt="image" src="https://github.com/user-attachments/assets/5129038f-d210-40f4-bcd8-1727d791edca" />
6+
7+
The condition to check if any inactive user is present in Reviewers must be written on 'Value' (actual Server script) and the styles to applied must be mentioned on 'Style'.
8+
Refer below screenshot:
9+
<img width="911" height="239" alt="image" src="https://github.com/user-attachments/assets/477e52cb-bdad-439d-a1cc-5b6be0415c20" />
10+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//The below code followed by "javascript:", inside 'Value' field for the List type Reviewers field's Style record will do the condition check.
2+
var answer = false;
3+
var arr=[];
4+
arr = current.reviewers.split(',');
5+
for(i=0; i<arr.length; i++){
6+
var gr = new GlideRecord('sys_user');
7+
gr.addQuery('sys_id',arr[i]);
8+
gr.query();
9+
if(gr.next()){
10+
if(gr.active == false){
11+
answer = true;
12+
}
13+
}
14+
}
15+
answer;
16+
17+
//The Style field then must be populated with the style we want to apply. I have applied "background-color: blue;" "text-decoration:line-through;"
18+
background-color: blue;
19+
text-decoration:line-through;

0 commit comments

Comments
 (0)