The CreatorCon Call for Content is officially open! Get started here.

VIP Flag on sc_task

Arijit Saikia
Tera Contributor

I have a requirement to include a VIP flag for sc_task if the requested_for is a VIP user. This is required for both Platform and Service Operations Workspace.

 

I cannot use a OnChange client script(which is used for Incidents).

 

Dictionary Info: sc_task.request_item.requested_for

Table    sc_task

Field     request_item

Type      reference

Reference sc_req_item

5 REPLIES 5

ChiranjeeviR
Kilo Sage

Hi @Arijit Saikia,

 

You can use business rule instead

 

Step-by-step solution

1. Add a custom boolean field on sc_task

  • Field name: u_vip_flag (or your preferred name)

  • Type: Boolean

  • Label: VIP Flag

2. Create a Business Rule on sc_task

  • When: before insert, before update

  • Condition: if request_item is populated (exists)

  • Script logic:

    • Load the related sc_req_item record using request_item

    • Get the requested_for user on that sc_req_item

    • Check if that user is VIP (assuming a boolean field on sys_user like u_vip or a group membership check)

    • Set current.u_vip_flag to true/false accordingly

 

(function executeRule(current, previous /*null on insert*/) {
    if (!current.request_item) {
        current.u_vip_flag = false;
        return;
    }
    
    var reqItemGR = new GlideRecord('sc_req_item');
    if (reqItemGR.get(current.request_item)) {
        var userGR = new GlideRecord('sys_user');
        if (userGR.get(reqItemGR.requested_for)) {
            // Check VIP condition - example: custom boolean field 'u_vip' on sys_user
            if (userGR.u_vip) {
                current.u_vip_flag = true;
            } else {
                current.u_vip_flag = false;
            }
        } else {
            current.u_vip_flag = false;
        }
    } else {
        current.u_vip_flag = false;
    }
})(current, previous);

 

Thanks and Regards,

Chiranjeevi R

 

Please mark as Correct Answer/Helpful, if applicable.

Thanks & Regards,
Chiranjeevi
ServiceNow Developer | | ITSM | | ServiceNow Discovery | | Event Management | | Service Mapping | | CMDB

Please mark as Correct Answer/Helpful, if applicable.