- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â07-06-2022 11:06 PM
Hi, I have two custom table, table1 and table2 . Table 2 is child of table1.
I have a ui action "Fill Form" on table 1 on clicking of which i want a new record to be inserted in table 2 .
But it is also creating a new record in table 1 which i don't want
How can i achieve this any help would be appreciated
Thank you.
Code which i am using on ui action:
var gr=new GlideRecord("table2");
{
gr.initialize();
gr.fields=current.fields;
gr.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â07-06-2022 11:28 PM
Hi Prakash
Try this code
var ans=new GlideRecord('u_filled'); //table 2
ans.initialize();
ans.u_owner = current.u_owner;
ans.u_list_field = current.u_list_field;
ans.u_choice_1 = current.u_choice_1;
ans.u_choice_2 = current.u_choice_2;
ans.u_choice_3 = current.u_choice_3;
ans.u_question_1 = current.u_question_1;
ans.u_question_2 = current.u_question_2;
ans.u_question_3 = current.u_question_3;
ans.u_question_4 = current.u_question_4;
ans.insert();
action.setRedirectURL(ans);
You will see child records on parent list too but when you open the record it will be in table2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â07-06-2022 11:10 PM
Hi prakash
try this
var gr=new GlideRecord("table2");
gr.initialize();
gr.field1=current.field1; //map all your fields .
gr.field2 = current.field2;
gr.insert();
action.setRedirectURL(gr); //use this line for redirection to table2 record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â07-06-2022 11:21 PM
Hi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â07-06-2022 11:28 PM
Hi Prakash
Try this code
var ans=new GlideRecord('u_filled'); //table 2
ans.initialize();
ans.u_owner = current.u_owner;
ans.u_list_field = current.u_list_field;
ans.u_choice_1 = current.u_choice_1;
ans.u_choice_2 = current.u_choice_2;
ans.u_choice_3 = current.u_choice_3;
ans.u_question_1 = current.u_question_1;
ans.u_question_2 = current.u_question_2;
ans.u_question_3 = current.u_question_3;
ans.u_question_4 = current.u_question_4;
ans.insert();
action.setRedirectURL(ans);
You will see child records on parent list too but when you open the record it will be in table2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â07-06-2022 11:11 PM
Hi,
your script seems incomplete
Regards
Ankur