- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-28-2024 09:56 AM
Hi all,
I am importing service account to cloud service account table .'Account id ' Field is coalesce field.When I am running import I want to update the 'Updated on' field with current run time for each service account for which account ID matches even if record is skipped or ignored (When no field value change) and operation status should be operational.
The records which are not updated with latest run .I want to update operational status as 'non-operational' for those service accounts.
Could you please help me how can i get this .
Thanks & regards,
Abhishek
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2024 10:22 AM
It may be running, but not updating. You should try the option provided by @Sumanth16 which is a better way of doing it by using onComplete transform script.
Also when you use onComplete, you may need to change query to not update in last 4 or 6 hours. Also add gs.info to know if it is able to find any account.
var gr = new GlideRecord('cmdb_ci_cloud_service_account');
gr.addEncodedQuery("sys_updated_onNOTONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()");
gr.query();
while (gr.next()) {
gr.info('++Service Account Non Operational++++'+gr.name);
gr.operational_status=2;
gr.update();
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-04-2024 11:18 PM
Hi @_bhishek ,
Refer the below document for IRE scripted API.
Please appreciate the efforts of community contributors by marking appropriate response as Mark my Answer Helpful or Accept Solution this may help other community users to follow correct solution in future.
Thanks
AJ
Linkedin Profile:- https://www.linkedin.com/in/ajay-kumar-66a91385/
ServiceNow Community Rising Star 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-05-2024 08:31 AM
Thanks for your response.Can we add condition like CMDB service account updated on before Import set created date in transform map on complete script .I think this would be more accurate .Can you please help me ,how can i write this condition?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-05-2024 08:45 AM
Hi @_bhishek ,
That would become more complex and impact the performance of your job. Check how long your job is taking to complete and add some extra time in the query. In my case , job is taking one hour , i added condition like not updated last two hours.
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-05-2024 09:28 AM
Hi Sumanth,
Thanks for your response.But for example, some one has updated any service account during that 2 hours period and that should be updated as non- operational but due to this query(Last 2 hours) it would not be updated.
So we want to update all the imported service accounts with operation status that i am updating with field mapping and remaining service accounts should be updated with non-operational state which are not included in import.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2024 09:19 AM
I have added below condition .IT is working as expected.
gr.addQuery("sys_updated_on" ,"<", import_set.sys_created_on);