- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I Want to populate my mrvs data from record producer to a table under a related list of a custom table form view.
I have created a custom table for the other fields to store the record producer data once submitted. And I have created child table with year, month, no_of_seats_require as same as MRVS fields, and parent field which is reference to custom table.
In the producer side I have used this code to initialize the record on the table mentioned:
this is not working and rows are not inserted in related list of custom table. How I can achieve this. Please provide the resolution.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
record producer is on which target table? Parent table?
If yes then why to write current.insert() when record will already be created when you submit record producer?
what debugging did you do in your script?
1) table name and parent field is correct?
2) fields you are trying to set are correct? is the field type matching against variable type?
3) variable names from MRVS are correct?
4) add gs.info() and see
If you are trying to set reference field from choice variable then it won't work
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
try this
(function executeProducerScript(current, producer) {
// Insert parent record first
current.insert();
// Get MRVS JSON (internal name = monthly_seat_demand)
var raw = producer.monthly_seat_demand.getValue();
if (!raw) return;
var rows = JSON.parse(raw); // Array of objects
for (var i = 0; i < rows.length; i++) {
var r = rows[i];
var gr = new GlideRecord('x_ggisu_seat_deman_seat_demand_mrvs');
gr.initialize();
gr.parent = current.sys_id; // reference field to parent
gr.year = r.u_year || ''; // use internal column names from MRVS
gr.month = r.u_month || '';
gr.no_of_seats_require = parseInt(r.u_no_of_seats_require, 10) || 0;
gr.insert();
}
})(current, producer);
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Not working. Not able to see the row data in related list of custom table. And duplicate records were creating. Check the screenshots of issues. u_month, u_year,..... these are child table variables - x_ggisu_seat_deman_seat_demand_mrvs.
Producer script:
internal column names from MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @JyothiD
Can you please try the below
(function executeProducerScript(current, producer) {
// Do NOT insert again, RP engine will handle it
var raw = producer.monthly_seat_demand.getValue();
if (!raw) return;
var rows = JSON.parse(raw); // Array of objects
gs.info('MRVS JSON: ' + raw); // Debug
for (var i = 0; i < rows.length; i++) {
var r = rows[i];
gs.info('Row ' + i + ': ' + JSON.stringify(r)); // Debug
var gr = new GlideRecord('x_ggisu_seat_deman_seat_demand_mrvs');
gr.initialize();
gr.seat_request = current.sys_id; // Reference to parent
gr.u_year = r.year || ''; // Map MRVS variable → child field
gr.u_month = r.month || '';
gr.u_no_of_seats_require = parseInt(r.no_of_seats_require, 10) || 0;
gr.insert();
}
})(current, producer);
Run again and check your logs → you’ll see the JSON output, so you’ll know the exact MRVS keys.
and provide the log
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Now only one record created. But, still rows are not attached to the record. log is showing.