To create a log entry for a customized search source in the sp_log table

Raji10
Tera Contributor

Hi All,

I have created an external search source,but, since it's a customized search and facet, the system does not log search entries in the sp_log table. We shall use GlideSPScriptable function to capture the search text and create such log entries.

Can anyone please help. It is part of the Simulator that I'm practicing from the NowLearning platform. Please refer to 'Service Portal (London)' Simulator for the exercise.

Thanks & Regards,

Rajalakshmi.

1 ACCEPTED SOLUTION

above method can be used only inside widget client script.

may be you can do normal glide record insertion into sp_log table. with required values.

you can get the search term from "query" in data fetch script section of your search source.

View solution in original post

3 REPLIES 3

SatheeshKumar
Kilo Sage

you can use the below:

$sp.logStat(String type, String table, String id, opt String comments);

logStat(String type, String table, String id, opt String comments😞 voidCreate a new entry in the sp_log table with a table name, a record sys_id from that name, and some type and optional comments. Handy for doing things like logging searches or visits to pages, etc.

Hi @SatheeshKumar ,

Can you please help me where I have to place the code. I am using an external search source which is scripted.

Thank you.

above method can be used only inside widget client script.

may be you can do normal glide record insertion into sp_log table. with required values.

you can get the search term from "query" in data fetch script section of your search source.