The CreatorCon Call for Content is officially open! Get started here.

Mapping Two Different Variables to One Field, depending on value of another Field

jlynch23
Tera Expert

Hello all,

 

I'm working on a catalog item with a number of variables.  Two of the variables contain lists of team names (List A and List B), which are differentiated by type. Team Type is another variable, and based on what the requester selects (it is either Type A or Type B (team_type), and can never be both or non), the field shown will either be List A, or List B.  The requester then needs to select the appropriate team from the list that is shown.

 

The problem is, both List A and List B need to populate a single field on the resulting record (u_team_name).  I can't use the check box for this, since they are two separate variables (list_a_choice, list_b_choice). 

 

This is ultimately to drive assignment rules and processes behind the scenes, but have one single place for the teams handling these cases look for what team is relevant.  These teams have long and complicated names that have been tripping up these rules, and there are 23 choices - hence wanting to map them to the field.

 

Is there a way to script this on the Record Producer itself, or do I need to combine the fields and use a Client Script to g_form and add/remove the fields.  Would love to avoid having to go the g_form route.

 

Thanks!

Jessie

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi Jessie,

If I'm following correctly, it sounds like in the Script field of the RP you can have something like:

 

if (producer.team_type == 'A') {
    current.field_name = producer.list_a_choice;
} else {
    current.field_name = producer.list_b_choice;
}

Assuming field_name is a reference to the sys_user_group table, as are the 2 List variables so that the values/types agree.

 

 

View solution in original post

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

Hi Jessie,

If I'm following correctly, it sounds like in the Script field of the RP you can have something like:

 

if (producer.team_type == 'A') {
    current.field_name = producer.list_a_choice;
} else {
    current.field_name = producer.list_b_choice;
}

Assuming field_name is a reference to the sys_user_group table, as are the 2 List variables so that the values/types agree.

 

 

That is very similar to what I had been trying to write before - but I think I was over complicating it.  I'll give your example a try since it takes out some of the complications I had tossed into it.

if(current.u_team_type == 'A')
{
	var ATeam = producer.A_team_choice.getDisplayValue();
	current.u_team_name = ATeam;
}
else{
	var BTeam = producer.B_team_choice.getDisplayValue();
	current.u_team_name = BTeam;
}

 

Yeah - I was over complicating it with my original script - I did not need to do the getDisplayValue() portion, or creating and passing variables in the script.  I just needed to tell it that Team Name = Team A or Team B.

 

Thank you!

 

You are welcome!

 

 

Connect with me https://www.linkedin.com/in/brad-bowman-321b1567/