When testing ServiceNow, you often need to adjust your approach, this is largely determined by the application you’re working on.
During my experience at SPOC, working with many different clients and a variety of applications, there was always a need to follow a certain workflow to reach a result that I needed to test.
To test the required acceptance criteria of a story, it might take a tester up to an hour to follow a whole workflow, until they arrive at the step that needs to be checked.
Testing in ServiceNow, an Example
A tester needs to get to a part of the process to test certain functionality against the acceptance criteria of a story, related to the ‘Status Field‘.
Frequently the tester might only see ‘read-only’ fields related to the status of an Incident, Problem, Change or any other ‘status field’ in custom applications.
The status is responsible for the workflow path that the process has to follow.
How to deal with this scenario? We can use ServiceNow Client Scripts to help.
Let’s suppose that we need to go from Assigned State to Invite Sent:
As is visible, the field is ‘read-only’, so the only way to change it is to follow these steps:
- First check the name of the field by clicking the right mouse into the field Label: (Sometimes this field might have a very easy name, or similar to the label, but in many other cases depending on the application field name might be different from the label.)
- Next step is to find out what is the value of the choice that you need to change. Every status field has one or many choices. Right click on the field status, and chose option show choice list.
- Search for the label you want in this case, ‘State’.The value of this field is 104, which means that putting the value in the code will produce the Invite sent state.
- Now you need to write the code below: g_form.setValue(‘state’,”104″);
- Click Run my Code
Automatically the value of the field will change to Invite Sent.
This method will be useful and can save time in many cases, especially when skipping some of the states of the workflow will not cause a problem; as they’ve already been tested.