How can I query the Activites for a sc_task

Community Alums
Not applicable

I'm needing to figure out how to query the Activities on a sc_task to see if the requestor has replied to an email..

Does anyone know a generic script to query the Activities.  I think it's the sys_history_set table but that does not seem to have a tie into something else

I have the information in the screen shot but don't know where / how to glideQuery this.

My request from the user is they need to see if the requestor on a SCTASK has responded via email. So I think the OID relates to something and the sys_history_set table the ID is the sys_id of the SCTASK.  So I'm confused on what to query.  Any help?

find_real_file.png

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,

Doing a query on history tables in not a recommended practice I would suggest and can impact your instance performance.

For your requirement, my suggestion here will be to update the ticket field say Work Notes or Additional comments when the user respond back via email.

Navigate to your Inbound action and update the script of Inbound Action as below for example:

current.work_notes = email.subject;
current.update();

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

4 REPLIES 4

DrewW
Mega Sage
Mega Sage

The activity formatter pulls data from a number of places to display it.  The history tables are not populated until you actually try and view the history.  So you cannot count on that data being there when you query it.

The best way to find out if a user has sent an email to the system is either to use an inbound action to make what ever the update/change is when the message is received or to query the sys_email table.

Without knowing more on the who/what/why there is not much else I can offer.

 

Jagmeet Singh
Tera Expert

Hi,

 

Please look into this link : https://community.servicenow.com/community?id=community_question&sys_id=fd9a832ddb5cdbc01dcaf3231f96190f

 

Hope this helps!

shloke04
Kilo Patron

Hi,

Doing a query on history tables in not a recommended practice I would suggest and can impact your instance performance.

For your requirement, my suggestion here will be to update the ticket field say Work Notes or Additional comments when the user respond back via email.

Navigate to your Inbound action and update the script of Inbound Action as below for example:

current.work_notes = email.subject;
current.update();

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Community Alums
Not applicable

So say I want to put this in the additional comments not the work notes.  I tried the following in the inbound email script in the script section

 

// want to put the subject in the additional comments and show it was updated by the sender.

current.comments = email.subject + ' ' + email.from
current.update();

 

but nothing happened.  how can I correct this

 

I need these sections of the email
This is the Activity Record
find_real_file.png

Want the areas in purple in Additional comments not necessarily Work notes because the user would only add additional comments so we need separation of what is put in work notes and additional comments.  So here is an example of what I would like to see in the additional comments.
find_real_file.png