How can we get journal Field Value in client side?

m_servicenow
Kilo Contributor

Hi All,

Please can you suggest how can we get journalEntyValue from client side.

I am able to get it server side through getJournalEntry(-1) function. but this function is not working in client side. The code is below which is working fine in server side:

var notes = current.work_notes.getJournalEntry(-1);
var na = notes.split("\n\n");
for (var i = 0; i < na.length; i++)
gs.print(na);

_______________

Any help would be appreciated.

4 REPLIES 4

jcraneNYC
ServiceNow Employee
ServiceNow Employee

I'm not sure if you can actually do this Client-side, but you could write a script include, call it through GlideAjax, get the journal entry and return it to the client function.

Can I ask what you are trying to accomplish with this?


Hi Jon,


I am in the client portion of a UI Action doing validation on whether a journaled field has any prior entries before allowing the Action to occur and I have an ajax call to a script include but the returned result is always null even when there are previous entries.   Have any thought on what might be wrong?



This is the client-side scripting:


  var ajax = new GlideAjax('GetJournalEntry');


              ajax.addParam('sysparm_name','lastJrnlEntry');


              ajax.getXMLWait();


              var entryValue = ajax.getAnswer();


              alert ('entryValue ' + entryValue);


          if (entryValue==null) {


                alert('Please enter Initial Discussion Notes before Approving');


                      return false;


          }



This is the Script Include that I am trying to retrieve the last entry journaled:


var GetJournalEntry = Class.create();


GetJournalEntry.prototype = Object.extendsObject(AbstractAjaxProcessor, { lastJrnlEntry: function() { return current.u_initial_discussion_notes.getJournalEntry(1); } });



I can check the field u_initial_discussion_notes on the form, but that requires that there be something be in that field on the form when I hit the approve button...I just want to ensure that there was at least one discussion note entered at some point before allowing the Approve button to work.   Does this make sense?



Thanks,


Trena


TJW2
Mega Guru

You cannot use 'current', client side.


Rick Forristall
Tera Guru

Hi there Mukesh Kumar



Did you ever figure out how to get your journal field from a client script? I'm trying to do the same thing.



Thanks,



Rick Forristall


Goodwill of Central Arizona