How can you access a field on a record producer from a client script within a multirow variable set?

Peter Namkoong
Tera Contributor

I am trying to figure out if it is possible to access or pass the value of a field on a Record Producer (RP) on the Service Portal to a MultiRow Variable Set (MRVS). I currently have a field on the RP that lets you specify a certain week and the MRVS lets you specify a record for a day of that chosen week. please see the images below:

Record Producer field for selecting a week

find_real_file.png

MRVS field for selecting a date from that week

find_real_file.png

currently, I am able to access the RP field by getting the HTML DOM element ID, but I am noticing some inconsistent behaviors when doing so. Is there any way I can access the field directly through some sort of dot-walking? I have tried using "producer.variables.week_ending" to access the field but that doesn't work within the MRVS client script.

 

I would appreciate your support!

1 ACCEPTED SOLUTION

Zach Biewend1
Giga Expert

I haven't found an elegant solution to this, but I did come up with a workaround. It takes a few steps but it worked very well for me in the past. 

Create a GlideAjax script include and client script on the RP. onChange of week_ending, write that value to a user preference (sys_user_preference) for the current user. Name it something unique... (<RP name>.week_ending).

In your MRVS, call a GlideAjax to fetch the value that's been written to that user preference. 

Then for good house keeping, onSubmit of the RP, clear that value from the user preference. 

 

Let me know if this works for you! 

View solution in original post

9 REPLIES 9

sachin_namjoshi
Kilo Patron
Kilo Patron

Use below blog to access MVRS field value

 

https://community.servicenow.com/community?id=community_blog&sys_id=865b5aeddbc023c0feb1a851ca9619f9

 

Regards,

Sachin

Hi Sachin,

thank's for your response. Unfortunately, that doesn't help me in this situation because I am trying to access the record producer's field from an MVRS client script.

 

Thanks again,

Peter

I will suggest you to go with GlideAjax approach.

MVRS variables values are are maintained in sc_multi_row_question_answer table.

You can query sc_multi_row_question_answer table from your script include and call this script include using GlideAjax from your client script.

 

Regards,

Sachin

Ankur Bawiskar
Tera Patron
Tera Patron

@Peter Namkoong 

It's not straight forward

refer below links for help

multi row variable set and functions from onLoad catalog client scripts

Help on Multi Row Variable Set

Regards
Ankur

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