This topic is locked

Pass Values to Details Table Before Display

7/11/2018 2:32:36 PM
ASPRunner.NET General questions
I
i.NoLim author

Hello,
I have 2 tables: 'Team' (Master) and 'Individual' (Details).
'Team' has, among other fields, "Team_ID," "Team_Email" and "Team_PhoneN."

'Individual' has, among other fields, "Team_ID," "Individual_ID," "Email" and "PhoneN."
When adding a new Individual, I would like for the fields in the 'Individual' table to auto populate with the values from the 'Team' table. However, the user should have the choice to change this value meaning this cannot be a "After record added" event.
I tried something like this in the "Before display" event but no luck.



XVar data = pageObject.getMasterRecord();
if (data != null)

{

//Get Team information for current Charge

string strTeamExists = "select * from dbo.Team where Team_ID='"+data["Team_ID"].ToString()+"'";

XVar TeamInfo = CommonFunctions.db_query(strTeamExists, null);

XVar data2 = CommonFunctions.db_fetch_array(TeamInfo);
if(data2)

{

xt.assign("PhoneN", data2["Team_PhoneN"]);

xt.assign("Email", data2["Team_Email"]);

}

else

{

//nothing

}

}


I'm fairly positive that the reason why this doesn't work is because the "Team_ID" for the Individual isn't generated until after its completely added.
I thought about doing a "JavaScript OnLoad" event but wasn't sure how to reference the values from the 'Team' table.

T
Tim 7/11/2018

Try using the "Process record values" event instead of "Before display". And you don't need the second record set.
XVar data = pageObject.getMasterRecord();
if (data != null)

{

values["Email"]=data["Team_Email"].ToString();

values["PhoneN"]=data["Team_PhoneN"].ToString();
}
Good luck!

Tim

T
Tim 7/11/2018

Oh wait... are you trying to add the "individual" (detail) record at the same time as you are creating the "team" (master) record? If so, my solution won't work. Can you have the user create the master record and then redirect them to the detail add page? (this is an option from the "settings" of the add page).
Tim

A
Arkie 7/11/2018

Depending on how you do your selections, this might help.

In my case, when adding a team member, first I select the team for that member to belong to. I set this field to use the lookup wizard and select the team from a dropdown. Then, using a feature of the lookup wizard, do an autofill on all the fields I want the team member to assume from team's values.

hth

~Joe

I
i.NoLim author 7/11/2018



Try using the "Process record values" event instead of "Before display". And you don't need the second record set.
XVar data = pageObject.getMasterRecord();
if (data != null)

{

values["Email"]=data["Team_Email"].ToString();

values["PhoneN"]=data["Team_PhoneN"].ToString();
}
Good luck!

Tim


That worked, thank you!
Actually, I would have liked to Inline Add as many Individuals as possible at the same time as creating the 'Team' but because of the math in other fields I'm not able to do it. Or am I?
This is an overview of what the project looks like:

Table | Fields

Team: TEAM_STATUS, TEAM_ID, TEAM_PHONEN, TEAM_EMAIL, TEAM_SIZE, TEAM_LIMIT, TOTAL, REMAINDER

Individual: TEAM_ID, INDIVIDUAL_ID, PHONEN, EMAIL, AMOUNT_USED, IND_REMAINDER, TEAM_LIMIT_COPY, TOTAL_COPY, REMAINDER_COPY

Charges: TEAM_ID, INDIVIDUAL_ID, CHARGE_ID, FEE
What's supposed to happen: User creates Team, enters Individual/s on said team, and finally adds Charges to each Individual.
The TEAM_LIMIT is defined depending on the number of Individuals in the Team, lets say $100.00 per Individual. 4 Individuals makes the TEAM_LIMIT = 400. Most of all the other fields are the same, they depend on entries in the Details tables.
The way I'm currently doing it is: After each entry I count how many Individuals are in the Team based on how many have the same "TEAM_ID" as the entry that was just made, and then I calculate all the other fields. This, obviously, prevents me from doing multiple Inline adds at the same time. Is there a way for me to make multiple entries, refresh the whole page, and finally calculate each field in both the Individual and Team tables?