Fix Script Help - updating multiple HR Case Records

Rob Sestito
Mega Sage

Hello SN Comm!

I am working on script a Fix Script, in order to update many, many records for HR Cases.

Here is what I have as of right now:

var gr = new GlideRecord('sn_hr_core_case');
gr.addQuery('topic_category', 'system issue');
gr.addQuery('topic_detail', 'system issue');
gr.addQuery('hr_service', 'legacy_misc');
gr.addQuery('short_description', 'CONTAINS', 'Workday Password Reset');

gr.query();

while (gr.next()) {
	
	gs.info('fixLegacyMiscCases: I would fix ' + gr.getRowCount() + " records."); //Check script before running - does it return correct number of records?
	
	//gr.topic_category = 'Accounts / Access Control';
	//gr.topic_detail = 'Password Reset';
	//gr.hr_service = 'workday_password_reset';
	
	gr.autoSysFields(false);
	gr.setWorkflow(false);
	gr.update();
}

 However, when I run the script, I just get a message on how long it took to run, but no record count shows up.

And the time ran returns 00:00:04. So, I know it didn't do a thing.

Anyone able to help out what is wrong? I have tried a couple of ways with the format of the script. For example, in my addQueries - I had gr.addQuery("topic_category", 'system_issue'); - and so on for all of them. But the results have been the same no matter what.

Thanks in advance if anyone can help me!

-Rob

1 ACCEPTED SOLUTION

Rob Sestito
Mega Sage

I learned that the output I was getting (while large), was simply just telling me that the script was running. I attacked a small number of Cases within my fix script, and it did what I needed - updated those Cases as I needed them to be. Hit the right Cases and changed what I wanted corrected within my script.

Thanks everyone for the help here!

Closing post as the script is working correctly.

-Rob

View solution in original post

9 REPLIES 9

vkachineni
Kilo Sage
Kilo Sage
Please put gs.info line immediately after gr.query
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Added gs.info life right after the gr.query - same results.

Just showed the time it ran and that was it.

-Rob

michaelj_sherid
ServiceNow Employee
ServiceNow Employee

Hi Rob,

It most likely is being blocked by the Application Restricted Caller Access. For functionality like this you would have to have the fix script call to a script include in the script's scope. 

Just an idea of what this could be.

Regards,

Mike

Oh boy Michael - any idea how I would go about doing that?

I went to the list of Application Restricted Caller Access - filtered to show all HR:Core for the source scope. And we have 17 that are there.

If this is the case, how would I validate it to be the blocker?

Thanks,

-Rob