Question about getRefRecord :)

joseeduardo
Giga Expert

Captura.PNG

Hello can someone explain me whats wrong here?? why it says it is a null field! It shouldnt! I mean I have lots of incidents with a caller Id!! thank you very much guys!

1 ACCEPTED SOLUTION

jajajaja LOL I just realized something! I got the null because of the "if", as we all of us know "if" will only search forward for the first record LOL here is my problem! Deepak Ingale and Michael Fry are both quite right!! I used the while loop and then I just found this first record a null one, so this was the cheater one that was showing up before!!



Captura.PNG



Now I want to highlight something! maybe it could even be worth of putting it on another discussion!! why are these null boys coming out?? if I just copied the script of servicenow wiki and in the scripting was a notNull! well check this out! there is some kinda of mistake in the wiki!!




Captura.PNG


well this is the mistake!, it is not: notNullQuery() instead should be: addNotNullQuery() , so if you use this last script it will work!




But guys actually there is something weird here! maybe some one with more experience could correct me if there is not such a weird thing! so far for me it is! look at this! if you use in this same code(well the only thing I actually changed was the loop I used a "while" one), if you instead use a simple addQuery() It returns only the NULL records! why?? you may ask to some else! cause I   dont know! the good point here is that in most of the cases it is supposed that a null record here is useless for us! so we can use addNotNullQuery() but any ways I just let you use this with precaution!


View solution in original post

8 REPLIES 8

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Jose,



Should that be


var caller = gr.caller_id.getRefRecord();


?



Best Regards



Tony


Hello thank   you for answering Tony! I tried the way you just said but this is what happens in this configuration check this out! :


Captura.PNG


this is what it returns :


Captura.PNG


what do you think tony?


User179407
Mega Guru

Refer section 3.30 , might be helpful



GlideElement - ServiceNow Wiki



Should be:


var caller = gr.caller_id.getRefRecord();



Suraj Chauhan


Thanks for answering! and I tried the example that is located there in the section 3.30 of that wiki link! wich is this:


Captura.PNG



But what happened is that it returns a null value!! what do you think!?