Dotwalking in GlideRecord

Mathew Hillyard
Mega Sage

Hi everyone,

I am attempting to create a notification to tell people when their knowledge article is about to expire.

I have registered the event, created the scheduled job and the notification fired by the event. Everything runs as expected, but I am running into problems trying to dotwalk to another table in order to supply the author's manager as parm2 to the event.

My scheduled job looks like this.

gr.author works fine and fires the event, which sends the notification to the kb article' author, but as author is a reference field I cannot work out how to dot walk to obtain the author's manager to insert into parm2 in the gs.eventQueue() function below. gr.author.manager, current.author.manager and any other variation seems to fail.

There are no log messages, parm2 is just empty in the event log.

Any ideas as to the correct syntax?

Here's the script:

function queryExpiringKBArticles() {

  var gr = new GlideRecord('kb_knowledge');

  gr.addEncodedQuery("workflow_state=published^valid_toONYesterday@javascript:gs.daysAgoStart(1)@javascript:gs.daysAgoEnd(-14)"); //this will give you all the articles will expire in 14 days

  gr.query();

  gs.log(gr.getRowCount() + ' rows retrieved');

  while (gr.next()) {

  gs.eventQueue( 'kb.expiring', gr, gr.author, gr.author.manager );

  }

}

Thanks

Mat

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

Hi Mathew,



As you are already passing the glideRecord object of the KB record, non need to pass additional parameters. Simply select knowledge as table in email notification and then select the recipients from fields.


find_real_file.png


View solution in original post

11 REPLIES 11

Arindam Ghosh
Mega Guru

use below code:



gr.author.manager.sys_id


Chandu Telu
Tera Guru
Tera Guru

Hi Mathew,




your code looks good to me,can you check the Event Param 2 contain recipient is checked or not


find_real_file.png


Harsh Vardhan
Giga Patron

Hi Mathew,



try with gr.author.manager.name



also you can check with script below. debug it through log. you can even run it in your background script.



  var gr = new GlideRecord('kb_knowledge');


  gr.addEncodedQuery("workflow_state=published^valid_toONYesterday@javascript:gs.daysAgoStart(1)@javascript:gs.daysAgoEnd(-14)");     //also validate with encodedquery if it's correct or not.


  gr.query();


  gs.print(gr.getRowCount() + ' rows retrieved');


  while (gr.next()) {


  gs.print( 'kb.expiring',+ gr.author+'     '+'   '+ gr.author.manager.name );


  }


Hi,



Unfortunately none of the suggestions worked - neither gr.author.manager.name nor gr.author.manager.sys_id.


I have indeed got parm2 contains recipient ticked on the notification - however looking at the event log the parameter isn't even being passed by the scheduled job.



Looking at the kb_knowledge table, author is a reference field from the sys_user table so I cannot see any reason why I shouldn't be able to dotwalk to fields in this table?



gs.print( 'kb.expiring',+ gr.author+'     '+'   '+ gr.author.manager.name );



Not sure this syntax is correct as nothing happens?



Mat