How do I create an incident or request item - based on a record being added to a table?

catho
Tera Expert

Hi,

my first question - so please excuse me if I have missed anything obvious.

I would like to create a request item - with some pre-populated fields - based on when a record is added to an unrelated table.

So far I have looked at trying to do it by either events, or business rules - but not having much luck (I'm also very green with scripting).

Does anyone have some pointers of how you would implement this?

Thanks,

Cath

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

Hi Cath,



You can do through Business Rule, let me explain how through scripting since you are new in scripting. This might help you.



For Example: I am here trying to create an Incident when new Record gets added in Service Request (sc_request) table, checking condition that after new record is inserted and state of the newly inserted record in Open then create incident with some populated values.



find_real_file.png


find_real_file.png



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


  // Add your code here


  var gr = new GlideRecord('incident');


  gr.caller_id = gs.getUserID();


  gr.comments = 'New Incident on addition of new Record in Service Request Table';


  gr.short_description = 'New Incident on addition of new Record in Service Request Table';


  gr.category = "inquiry";


  gr.incident_state = IncidentState.NEW;


  gr.contact_type = "email";


  gr.insert();


})(current, previous);



Result:


find_real_file.png



Hope this will help you to understand how to achieve, just replace the table name on which when you insert new record incident should be created.


View solution in original post

21 REPLIES 21

It Should work, i have just test on creating new incident and it worked, i will update you soon after testing the same on ritm.


just tested on RITM and it worked,not sure what's wrong



find_real_file.png