Function setJournalEntry is not allowed in scope

aklimenko
Mega Expert

Hi. We allow certain device management functions from within incident. Part of the logic is to add entries to incident's journal the tell a person of success or failure of a particular action. But it seems there is another restriction: Function setJournalEntry is not allowed in scope

Is there an alternative?

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

HI Alexey Klimenko



The setValue() method is not supported for Journal fields. Instead, assign values in script. Please take the look at the below example for reference.


function onAfter(current, previous) {


    //This function will be automatically called when this rule is processed.


var gr = new GlideRecord('incident');


gr.addQuery('sys_id','d71b3b41c0a8016700a8ef040791e72a');//Harcoded sysid just for testing


gr.query();


while(gr.next())


{


gr.comments = 'Pradeep Sharma added comments to this ticket';


gr.update();


}


}


Thank you! Worked


What about getJournalEntry? This is also apparently disallowed in scoped API. How can I read the current journal values? Thanks,



Noah