Standard Change Request Validation through Automated Testing Framework

Feddy
Kilo Sage

Hi Everyone,

We have a requirement where we need to test a  Standard change request validation through ServiceNow ATF.
We have followed the below link:
1. https://greg-grabowski.com/test-standard-change-automated-test-framework/

2.https://greg-grabowski.com/test-standard-change-automated-test-framework-part-2/.


The issues which we are facing is that the default value of the change request type is set to standard(by following the above link), so we couldn't able to perform other tests where we need to test other change types.
is there any workaround to test standard change request.

Thanks.

1 ACCEPTED SOLUTION

Ankush Agrawal
ServiceNow Employee
ServiceNow Employee

Hi Fedrick

You can use the query in the below format:

var standardTemplate = new GlideRecord('std_change_record_producer');
standardTemplate.addQuery('active', true);
//You can also add a query to get the required template
standardTemplate.query();
standardTemplate.next();
var gr = new GlideRecord('change_request');
gr.applyTemplate(String(standardTemplate.template.name)); //This step applies the queried template
gr.setValue('type', 'standard');
gr.setValue('short_description', 'This is my short descr');
var sysID = gr.insert();

--

Cheers

Ankush

View solution in original post

6 REPLIES 6

Ankush Agrawal
ServiceNow Employee
ServiceNow Employee

Hi

Can you please tell what other tests are not working fine? On other changes, you can select the type to 'Normal' or 'Emergency.

Another workaround to test standard change is just create it from 'Run Server Side Script' method. 

--

Best Regards

Ankush

Hi 


yes , I can able to create test steps for "Normal change" by using 'open a new form' on "Change Request" Table.
but I have followed the above mentioned link for "Standard Change" where the type is defaulted to "standard",In result test steps for the "Normal change" is getting failed.
Can you tell me how to create a standard change from "Run Server Side Script".We have tried similar to this but we couldnt able to fetch details like Short description,Description,Assignment group and other values from standard change template.

Thanks & Regards

Fedrick

Ankush Agrawal
ServiceNow Employee
ServiceNow Employee

Hi Fedrick

You can use the query in the below format:

var standardTemplate = new GlideRecord('std_change_record_producer');
standardTemplate.addQuery('active', true);
//You can also add a query to get the required template
standardTemplate.query();
standardTemplate.next();
var gr = new GlideRecord('change_request');
gr.applyTemplate(String(standardTemplate.template.name)); //This step applies the queried template
gr.setValue('type', 'standard');
gr.setValue('short_description', 'This is my short descr');
var sysID = gr.insert();

--

Cheers

Ankush

Thanks Ankush Agrawal:)