Transform map query

_bhishek
Tera Guru

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

1 ACCEPTED SOLUTION

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.

View solution in original post

9 REPLIES 9

AJ-TechTrek
Giga Sage
Giga Sage

Hi @_bhishek ,

 

Refer the below document for IRE scripted API.

 

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

 

https://www.servicenow.com/community/developer-forum/ire-best-way-to-replace-transform-map-field-scr...

 

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

_bhishek
Tera Guru

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?

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

 

 

 

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 

I have added below condition .IT is working as expected.

gr.addQuery("sys_updated_on" ,"<", import_set.sys_created_on);