Remove Fields coming in Description after Record producer submission

tyagi1703
Tera Contributor

Hi ,

I have 2 fields on the record producer , that are not visible on the form but visibility of the other fields are based on these field.

When user submits the case, this field comes up in the description of the case (description shows all the fields filled by user while submitting the case.)

I want to hide this field from the description but i cannot empty these field at any time.

Is there a way to hide/remove these fields from description.

2 REPLIES 2

Community Alums
Not applicable

@tyagi1703 ,

So if you are working HRSD scope, this is OOTB logic implemented there where all those variables who has some value are shown under description.

MIftikhar_0-1760626785205.png

https://www.servicenow.com/community/developer-forum/default-variable-not-populating-to-hr-case-desc... 

It’s not recommended to modify the OOTB script, as doing so would affect all HR services.
As an alternative, you can create a Before Business Rule specific to your HR service and, within it, use a regex-based replace function to remove the hidden variables from the description by setting them to an empty string.

(function executeRule(current, previous /*null when async*/ ) {
    if (!current.description)
        return;
    var lines = current.description.split('\n');
    var visibleLines = [];
    for (var i = 0; i < lines.length; i++) {
        var line = lines[i].trim();
        if (line && !line.startsWith('Hidden Variable')) {
            visibleLines.push(line);
        }
    }
    current.description = visibleLines.join('\n');
})(current, previous);

Assumption hidden variable names start with Hidden Variable (replace if you have a different pattern)

Description view before BR logic added:

MIftikhar_0-1760886850935.png

 

Description view after BR logic added:

MIftikhar_1-1760886894953.png

 

Ankur Bawiskar
Tera Patron
Tera Patron

@tyagi1703 

I agree with what @Community Alums mentioned.

you can use before insert BR

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader