How to run "Populate primary resource attributes" from background script

DhathriC
Giga Contributor

I have to create a Action in flow designer, where I will be passing user sys_id. I want to trigger "Populate primary resource attributes".

12 REPLIES 12

Ankur Bawiskar
Tera Patron

@DhathriC 

there is an OOTB scheduled job for this "Populate primary attributes for all resources"

Check code of that and use in your flow action

OR

Invoke the scheduled job using script in custom flow action

 var gr = new GlideRecord("sysauto_script");
 gr.addQuery("name", "Populate primary attributes for all resources");
 gr.query();
 if (gr.next()) {
     gs.executeNow(gr);
 }

AnkurBawiskar_0-1768316356279.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  This scheduled job is for Bulk, Can we execute only for 1 user, by passing sys_id of the user

@DhathriC 

then please explore within that scheduled job which function is called and then use that script in your flow action and modify such that it takes 1 user

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@DhathriC 

there are different script includes involved

ResourceProfileSyncServiceSNC

AnkurBawiskar_0-1768359884252.png

 

PlanningAttributesSNC

AnkurBawiskar_2-1768359934521.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@DhathriC 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader