Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

GlideRecord on Record Producer Script

Sam Ogden
Tera Guru

Hi All,

I'm trying to create a GlideRecord which looks for a unique value in a table to retrieve the Category, Subcategory and Assignment Group on our Incident form via the Service Portal.

I've created the below in the record producer script:

find_real_file.png

more_details_answer is a field that gets populated with an answers value via a client script.   This value then matches a value in the u_csm_question_answer_value field in the table u_assignment_group.   This table also holds the category(u_category), subcategory (u_subcategory) and assignment group (u_assignment_group) - all 3 of these are reference fields.

I want to grab the details from these 3 fields and then populate them on the Incident form.

I'm very new to scripting so any help with where I have gone wrong with the above code and also any tips on how I can debug things easier myself will be greatly appreciated.

Thanks

Sam

1 ACCEPTED SOLUTION

Mihir Mohanta
Kilo Sage

in line 52 instead of using if(com.next()){


use


if(ans2.next()){



Other part of script looks good.



Thanks,


Mihir


View solution in original post

7 REPLIES 7

Mihir Mohanta
Kilo Sage

in line 52 instead of using if(com.next()){


use


if(ans2.next()){



Other part of script looks good.



Thanks,


Mihir


Cheers for that, works a treat


I've got a second query off the back of the above code (corrected the error on line 52).



if there is no value in producer.more_details_answer, then it is looking in the table for no value in the u_csm_question_answer_value field.


How is the best way to change the code to not run if producer.more_details_answer has no value in it?



Thanks


Before the GlideRecord query(line 48) add an if statement like :


if(producer.more_details_answer !=''){



and close the if statement after line 61   using }