Record Producer map to field or current.subcategory =producer.subcategory NOT Working

Stacy1
Mega Guru

I have a record producer on cases.

I have a field subcategory that looks at the sys_choice table and is displaying only the subcategories which belong to the category I am setting in my record producer.

I have tried to map the field and it doesn't work and I have removed that and done current.subcategory = producer.subcategory and that doesn't work either.

Any one have any ideas why?

Thanks,

Stacy

10 REPLIES 10

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Can you share what exactly is not working? I mean, you did try Record Producer script, what was the outcome of that? Nothing saved at all? Or an invalid value?

Did you debug producer.subcategory? Does this contain the value you would expect?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

So I have tried using a script.  My first log shows me the name of the subcategory.

My second log gives me a sysid and the value is the correct one.  However, the sysid it is giving me doesn't even exist in the sys_choice table.

This is my script:

gs.info("Stacys sub is " + producer.subcategory);
var sub = producer.subcategory;
var gr = new GlideRecord('sys_choice');
//gr.addQuery('label', 'CONTAINS', sub);
gr.addEncodedQuery('name=sn_customerservice_case^element=subcategory^dependent_value=3510');
gr.addQuery('value', 'CONTAINS', sub);
gr.query();
if (gr.next()){
gs.info('Stacys found gr' + gr.sys_id + gr.value);

current.subcategory= gr.value;
}

 

This is frustrating, it shouldn't be this hard to get subcategories for record producers.

 

thanks,

Stacy

sachin_namjoshi
Kilo Patron
Kilo Patron

you need to make sure that choice list values from your record producer variable matches with your target table subcategory choice list values.

 

find_real_file.png

 

Regards,

Sachin

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Stacy,

Are you also having similar dependency of sub-category on category on record producer as well

Do you have category and sub-category both as variables on record producer?

what value it sets when you set it via script

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader