How to get data from a UI Page embedded in a Record Producer

Luc
Tera Contributor

I have a record producer that creates a data_source record, but I also want to create a problem ticket under certain circumstances. I accomplished this in the Record Producer's script section. Simplified code:

if(producer.u_type == 'Create Problem'){
var prob = new GlideRecord('problem');
prob.initialize();
prob.short_description = "Data Source Request";
prob.due_date = producer.u_due_date;
var probId = prob.insert();
}

 

However, I needed the user to be able to select data from a dynamic slush bucket, so I embedded a ui page onto the record producer. It has the following fields (simplified):


<input type="text"  id="test_field" onchange='populateSlushbucket()' />

<g:ui_slushbucket id='slush' >
</g:ui_slushbucket>

 

So my question is this: Back in the record producer script, how do I access the values from the UI Page fields? I can get the producer fields easily enough with "producer.u_field_name," but I don't get anything using "producer.u_ui_page."

I need to include the values from both the text and slush fields on the problem ticket.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi,

you cannot access the UI page value inside record producer script directly.

One thing you can use is this approach

1) create a variable on record producer which is string type such as users

2) in the UI page client script code you can then set the value of that variable using g_form.setValue('users', values)

3) Now you have the sys_ids in that variable you can use that in record producer script

current.<fieldName> = producer.users;

Regards
Ankur

 

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron

Hi,

you cannot access the UI page value inside record producer script directly.

One thing you can use is this approach

1) create a variable on record producer which is string type such as users

2) in the UI page client script code you can then set the value of that variable using g_form.setValue('users', values)

3) Now you have the sys_ids in that variable you can use that in record producer script

current.<fieldName> = producer.users;

Regards
Ankur

 

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

Brilliant! Thank you Ankur!

You are welcome

Regards
Ankur

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