Incident creation - GlideRecord('incident')

jose rivera1
Mega Contributor

Hello: I have the code below on a workflow. The code is working but I need to populate the following fields: "Requested For", "Category" and "Subcategory". Any suggestions on how to do this?

     inc = new GlideRecord('incident'),
     fs_desc = s_descritpion1.concat(" ", location);
     f_desc = Incident_description.concat(" : ", name);

    inc.initialize();
    inc.short_description = fs_desc;
    inc.description = f_desc;
    inc.assignment_group = 'ABCD';
    inc.insert();

find_real_file.png

Thanks,

1 ACCEPTED SOLUTION

Then something like:

inc.requested_for = gs.getUserID();

Do check what the correct field name is though. Because out-of-the-box there's no requested_for on Incident, there should be a caller_id field. But you can check that.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

View solution in original post

14 REPLIES 14

Mark Roethof
Tera Patron
Tera Patron

Hi there,

You can just add things like:

inc.category = 'your_category_value';
inc.subcategory = 'your_subcategory_value';

What's the issue you are running into?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Hello Mark! fs_desc and f_descare are variables for "description" and "short description" and these two are populating those fields correctly.

Regards,

I need to populate the following fields (see the screenshot in the original post): "Requested For", "Category" and "Subcategory". Any suggestions on how to do this?

You can do that with what I mentioned.

What's the issue you are running into?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn