Hi All

basha shaik
Tera Contributor

I Have one question Related to User table.

 

Whenever add new user In User table automatic Raised Request .

 

Please suggest & Provided code

 

 

 

Thanks

3 REPLIES 3

Satishkumar B
Giga Sage
Giga Sage

@basha shaik Create a Business Rule will run after insert on the sys_user table. It will create a new record in the Request (sc_request) table and populate fields such as short_description and requested_for.

 

(function executeRule(current, previous /*null when async*/) {
    var requestGr = new GlideRecord('sc_request'); 
    requestGr.initialize();
    requestGr.short_description = 'New User Request for ' + current.name;
    requestGr.requested_for = current.sys_id;
    requestGr.insert();
    gs.addInfoMessage('Request created for new user: ' + current.name);
})(current, previous);

 

…………………………………………........................................................................................
Please Mark it helpful 👍and Accept Solution !! If this helps you to understand.

…………………………………………........................................................................................

 

 

Mark Manders
Mega Patron

Please describe what your use case is? What kind of request needs to be raised when? It sounds like a simple 'on insert' flow to create a record, but the way your question is formulated leaves for a lot of different explanations.


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

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Please suggest? Please share first a bit more yourself 🙂 This is not a code factory, dump your requirement, fix it for free.

 

Put some effort in yourself. That also learns you a lot more than just copy/pasting. And move on... code, why? For such a basic thing: Flow designer, few minutes work, done.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn