Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to insert fields using ACLs, Business Rules,

karola616
Giga Contributor

How to insert fields using ACLs, Business Rules,

3 REPLIES 3

SAI VENKATESH
Kilo Patron
Kilo Patron

Hi @karola616 

 

In general we will not be using ACl's but we can use business rules.

 

Example: you can any business rule(before, after,async)  when insert.

 

(function executeRule(current, previous /*null when async*/) {

    var inc = new GlideRecord('incident');
    inc.initialize();
    inc.short_description = 'testing communty';
    inc.description = ''test';
    inc.insert();

})(current, previous);


Thanks and regards

Sai Venkatesh

Ravi Gaurav
Giga Sage
Giga Sage

Hi @karola616 

 

 

1. Inserting Fields Using ACLs

Access Control Lists (ACLs) in ServiceNow don’t “insert” fields — they control access to them.
But if you want to control who can insert values into specific fields (i.e., who can create or update a record), you do it with table-level and field-level ACLs.

For example:

Type Operation Applies to Example
record create incident Controls if a user can create a record in the incident table
record write incident.short_description Controls if a user can set or change the short_description field
record read incident.caller_id Controls if a user can view caller information

Key Point:
If a user doesn’t have create permission on a field or table, they won’t be able to insert that field’s value when creating a record.

So, while ACLs don’t insert fields, they decide who can insert or modify them.

 

2. Inserting Fields Using Business Rules

If you mean automatically populating field values during record creation, that’s where Business Rules come in.

A Before Insert Business Rule is ideal. Example:

 

 
(function executeRule(current, previous /*null when async*/) { // Automatically set field values before record creation if (current.short_description.nil()) current.short_description = "Auto-created incident"; // Set a default priority current.priority = 3; // Set caller based on logic var user = gs.getUserID(); current.caller_id = user; })(current, previous);

 

This runs before the record is inserted, ensuring the field values are added automatically even if the user didn’t set them.

 

3. Typical Use Case Example

Let’s say you want to auto-populate a custom field u_ticket_source when an incident is created via email.

You’d write:

 

 
(function executeRule(current, previous) { if (current.sys_import_set.nil() && current.sys_email.nil()) { current.u_ticket_source = "Manual"; } else { current.u_ticket_source = "Email"; } })(current, previous);

 

This ensures that when the record is inserted, the field u_ticket_source is automatically filled without user input.


Summary

Goal Use This Purpose
Control who can insert or update fields ACL Restrict or permit access
Automatically populate or modify fields during insert Before Insert Business Rule Add or adjust values programmatically
--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Ankur Bawiskar
Tera Patron
Tera Patron

@karola616 

sorry your requirement is not clear.

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