incident comment API

Shabbir1
Tera Contributor

Hi Team,

We need to share incident comments via using API we have developed this API by using REST API explorer incident table API. So, we able to fetch the response but customer wants only latest(updated) comment. Could you please help on this, how to fetch only latest comment. 



Thanks & Regards,
Gori

6 REPLIES 6

Sunil31
Tera Expert

Hello @Shabbir1 ,

 

I believe this can be achieved by defining the rest api on sys_journal_field table. we can query it for our incident table and comments field.

 

 

BrahmjeetTanwar
Tera Guru

I don't think that sys_journal_table is available via rest api explorer, if it is available then we can use it and you can pass the sys id of the incident it will give you the comments or the second option is to create a scripted rest api which won't take much time and just return the latest comments, if you need help with the code I can help.


Let me know how 🙂

Thanks,
Brahm

Hi Brahm,

Could you please share the code?

Thanks,
Shabbir


ProdiptoL
Tera Expert

Hi @Shabbir1 , Try to use 'getJournalEntry(1)'

 

var inc_gr=new GlideRecord("incident");
if(inc_gr.get("number","INC0594858"))
{
    gs.info("Last Comment = "+inc_gr.comments.getJournalEntry(1));
}