
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 02:37 PM
HI,
I am trying to have multiple records created on a different table that are related to the original record when it's submitted. I got this to mostly work,
but its not selecting the choice from the choice list as the value of the field. It will add a new choice and the rest of the logic on the form does not
work.
Here is the script I used on a UI action that allowed it to actually create the related records, but it doesn't use the choices from the choice list. It's
like it's adding a choice to the choice list to use.
// Create BRM/PM member
var member = new GlideRecord("u_ccb_members");
member.u_ccb = current.sys_id;
member.u_role = "BRM PM";
member.u_ccb_function = "BRM PM";
member.insert();
// Create Business/All Requirements approver member
member.initialize();
member.u_ccb = current.sys_id;
member.u_role = "Approver";
member.insert();
// Create SIT approver member
member.initialize();
member.u_ccb = current.sys_id;
member.u_role = "Approver";
member.u_approval_type = "SIT";
member.insert();
// Create CAT approver member
member.initialize();
member.u_ccb = current.sys_id;
member.u_role = "Approver";
member.u_approval_type = "CAT";
member.insert();
action.setredirecturl(current);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2017 06:47 AM
I was able to get this working by using the numerical value of the choice instead of the value or label.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 02:43 PM
Hello Amie,
One thought for you. In your choice list, for any given option, does the value in the Value field match the text you're assigning to the variable? Setting it to the value in the "Label" field could result in the problem you're showing us.
Also, does it match the value exactly? In other words does its upper case and lower case letters appear in the Value field in the same manner as the assignment statement? This is the cause that I've run into when doing this kind of thing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2017 06:22 AM
Yes, the value on the choice is exactly the same as what I am setting it to in the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 02:45 PM
When you said related records, you meant those other records created once primary record submitted is created? Why can't that to be done using a 'after' business rule on current record? Let current record create, then trigger a script that would create all subsequent related records?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2017 06:23 AM
Yes, that could be an option. I did try this but the additional records weren't created. Would I use the same script in the BR?