location field in sc_task table

bondita1
Tera Contributor

Hello,

Can someone shed some light on how the Location field in the sc_task table gets populated? Where should I set the value for the Location field so that it populates correctly in the sc_task table?

Thanks

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @bondita1 

 

You need to create a new filed ( If not available OOTB) and reference to cmn_location table. and then you can use that in your work.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Pradeep Thipani
Mega Sage

Hello @bondita1 ,

 

Usually, the location field is referenced to the cmn_location table. Based on the records available on the location table you can select the location. Let me know if any further help is needed on this.

 

Please like and accept the solution if that helps.

 

Thanks & Regards,

Pradeep

"If this response was useful, please select 'Accept as Solution' and mark it as 'Helpful.' This helps me provide better answers and assists the community ".

Regards,
Pradeep

Hello,

Thats correct, The Location field in sc_task table refer to cmn_location table. I have populated Location column in sys_user table. But while creating a catalog item, Location field inserted as empty in sc_task table. So I just want to know, how to populate the value for this filed? Is this OOTB or do I need to write some script for this?

Thanks.

Hello @bondita1 ,

 

By OOB location field will not populate on the task created, to make it happen either you have to write a Business Rule or Catalog client script.

 

Here is the sample Business rule:

 

// Fetch location from the 'sys_user' table
var user = new GlideRecord('sys_user');
user.get(current.requested_for); // Assuming requested_for field holds the user
if (user.location) {
current.location = user.location; // Set location from the user profile
}

 

Please like and accept the solution if that helps.

 

Thanks & Regards,

Pradeep

"If this response was useful, please select 'Accept as Solution' and mark it as 'Helpful.' This helps me provide better answers and assists the community ".

Regards,
Pradeep