Populate case number on Incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 04:35 AM
Hello everyone,
There is a customer case record and using a UI action, we are creating an Incident.
Like, when we right click on the case form and select and click on Create incident, an incident is getting created.
So, once it is redirecting to incident, I see the case number in the Customer cases related tab.
There is also a Case field of reference type on the Incident, and there I want to populate with the respective case number while creating.
Can some one help me how can I do that?
below are the screenshots for your reference
Regards,
Sravanthi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 04:53 AM
is the Case field a custom one or OOB?
Also is that UI action an OOB or custom?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 06:12 AM
Hi Ankur,
The case field on the incident is not oob one
and secondly, the UI action when I checked it is showing like, created by admin.
The UI action name is Create Incident on the Case table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2024 11:15 PM
Hello @Sravanthi10 , you can retrieve the value of case from the current object in createIncidentFromCase() function at the time of creating an incident as below -
createIncidentFromCase(){
//code for creating incident
incidentGr.case = current.sys_id; // current.sys_id will give you the sys_id of case record
incident.insert();
}
If my answer solves your question, please mark it as Accepted ✔️ and Helpful 👍 based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 12:02 AM
Hi @Sravanthi10 ,
I tried your problem in my PDI it works for me please have a look below solution
I created UI Action and added below code
var gr = new GlideRecord('incident');
gr.initialize();
gr.sys_id = -1;
gr.u_case = current.sys_id;
gr.insert();
action.setRedirectURL('incident.do?sys_id='+gr.sys_id)
I also created I relationship for Related list and added below code
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('u_case', parent.sys_id);
})(current, parent);
Result
Related List
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak