- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2021 04:07 AM
Hi All,
I've a record producer ("Request firewall Access") in scoped application "Firewall Audits" which will create a FTASK in a custom table (firewall_new_request). I've a MRVS in this record producer, on submitting a request from this record producer, all the rows which we're adding in MRVS will be available under parent table FTASK related list.
We've created another table (Rule resource data) to store all the MRVS values and we're setting the parent field of this child table from record producer script.
"""""" ruleresource.parent = current.sys_id.toString(); """""""
Query: I've a field called "Name" (String) in my record producer. After submitting the request from that record producer, I wanted to see the value which user entered in "Name" in child table (Rule Resource data) list view.
I wrote below before BR in child table by checking insert and update checkbox, but it is not working.
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sn_disco_firewall_new_firewall_request');
gr.addQuery('sys_id', current.parent);
gr.query();
if(gr.next()){
current.u_name = gr.u_name ;
current.update();
}
"u_name" is the backend field value for 'Name' in both parent and child table.
can anyone please some way to get the 'Name' value from parent table to child table 'name' field?
Note: Both tables extended from Task table.
Parent table field value:
Child Table field value is empty:
Please suggest a way to get the field value on child from parent.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2021 08:18 AM
Hi,
is that field in same scope as that of table?
try this
current.u_name = current.parent.variables.u_name;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2021 07:29 AM
Hi,
on parent you get name but not on child
did you print in that BR the value of parent ?
Is it u_parent?
print that field value
gs.info('parent'+ current.parent);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2021 07:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2021 07:52 AM
Hi Ankur,
I tried to print the value of current.parent.u_name_rp as well current.parent.variables.u_name_rp like below but I'm getting undefined as value.
(function executeRule(current, previous /*null when async*/) {
gs.info("New script");
gs.info("current parent=" +current.parent);
gs.info("current parent1=" +current.parent.u_name_rp);
gs.info("current parent2=" +current.parent.variables.u_name_rp);
current.u_name = current.parent.variables.u_name_rp;
gs.info("U name=" +current.u_name);
current.update();
})(current, previous);
LOGS:
IS there any other way to get the name field populated on child table from parent table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2021 07:56 AM
Hi,
what is the name of the record producer variable?
what is the column name of the name present on parent table?
please check that once
If you got sys_id in current.parent then you should be able to get the field values as well from that parent
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2021 08:09 AM
Hi Ankur,
Please find below for the front end and back end values of 'Name' in Record Producer, Parent table and child table.
Record producer variable is correctly mapped to Parent table field (u_name to u_name_rp). I'm getting the record producer value in FTASK as well.
Not getting the parent field value alone in child table field.
Tried even the below script in BR and it is the same, getting undefined value in u_name_rp if I print this:
var gr = new GlideRecord('sn_disco_firewall_new_firewall_request');
gr.addQuery('sys_id', current.parent);
gr.query();
if(gr.next()){
current.u_name = gr.u_name_rp ;
current.update();
}