- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2025 08:39 PM
Hello community,
I am working on implementing a feature in the ServiceNow Agent mobile app using Mobile App Builder. My goal is to create a UI action in the 'Event Incident Records' section that allows the creation of a 'P1 Incident' by copying values from an existing record.
I have already started by creating a function called ‘Open P1 Incident’ with an Action item. The Action item includes sections such as script, input form screen, field values, and data parameters. Since no user input is needed, I have eliminated the input form screen section.
However, I am facing difficulties in grabbing values from the current record using the script. I've tried updating the script with inputs and outputs but am stuck on where to specify these input and output values.
Could anyone provide guidance or examples on how to achieve this? Any help would be greatly appreciated as I am new to mobile app development in this context.
Thank you in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2025 07:12 AM
Yaswanth, thank you for your time and help. It means a lot. I was able to get the logic and make it work. Here is the solution.
Documentation from the ServiceNow really helped me. This is the link how I was able to create action item with action step.
Instead of using 'script' in the Action item, I used 'Multistep' and created an Action Step with Script. Additionally, I created an Input form screen with variables 'sys_id' of type 'Database field,' adding the attribute of 'FieldName,' and attached the input form to the Action item.
The variable 'sys_id' from the Input form screen will be passed into the script (parm_variable.sys_id) on the Action Step.
Thank you for your continued assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2025 09:00 PM
To create a P1 incident from an existing record in the ServiceNow Agent app using Mobile App Builder, follow these steps:
1. Configure Data Parameters
In your "Open P1 Incident" Action item:
- Add a Data Parameter named "current_incident_sys_id"
- Set its value to reference the current record’s sys_id.
2. Update the Script
Use the "current_incident_sys_id" parameter to fetch the existing record and copy its values:
--Add this inside your execute function
// Get the sys_id of the current incident from the data parameter
var currentIncidentSysId = inputs.current_incident_sys_id;
// Fetch the current incident record
var currentIncident = new GlideRecord('incident');
if (currentIncident.get(currentIncidentSysId)) {
// Create a new P1 incident
var newIncident = new GlideRecord('incident');
newIncident.initialize();
// Copy fields from the current incident
newIncident.short_description = currentIncident.short_description;
newIncident.description = currentIncident.description;
newIncident.category = currentIncident.category;
newIncident.subcategory = currentIncident.subcategory;
newIncident.priority = 1; // Set to P1
} else {
//info message
}
Please mark this as helpful and correct if this resolves your issue.
Thanks,
Yaswanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2025 03:26 PM
Thank you Yaswanth for your prompt response to my query.
I have followed your suggestions and added a 'Data Parameter' to the Action item, updating the script accordingly. When testing the app, I encountered a 'Failed' message. I hope I've implemented the changes as you described but apologize if I missed something.
Please let me know if there are any additional steps I might need to take to ensure the script functions correctly? Your continued assistance is much appreciated.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2025 08:24 PM
Hi Sk,
Please use insert() action to insert the incident record.
Add the Missing insert()Call: after line 19
Please mark this as helpful/ solved if this answers your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2025 06:16 AM
Yaswanth,
I still see the 'Failed' message when testing in the app.
Please let me know if there are any additional steps I might need to take to ensure the script functions correctly? Your continued assistance is much appreciated.