March 9, 200916 yr I have two tables - Charges and Order Charges. I do a find for all Charges matching the specified Industry and Product. This part is working perfectly, returning 3 records in the Charges found set for the data I'm testing with. What I can't figure out is how to add a new Order Charges record for each record in the Charges found set. Please see my script below. Thanks in advance for any suggestions on how I can add the new Order Charges records from the Charges found set. Commit Records/Requests [ No dialog ] Set Variable [ $OrderID; Value:"gOrderID" ] New Window [ ] Go to Layout [ “Masterfile - Charges” (Charge) ] Enter Find Mode [ ] Set Field [ Charge::IndustryProduct; Get (ScriptParameter) ] Perform Find [ ] # above works, below does not. Go to Record/Request/Page [ First ] Loop Set Variable [ $ChargeID; Value:Charge::ChargeID ] Set Variable [ $ChargeDescription; Value:OrderCharge::ChargeDescription ] Set Variable [ $Quantity; Value:OrderCharge::Quantity ] Set Variable [ $Rate; Value:OrderCharge::Rate ] Set Variable [ $UnitOfMeasure; Value:OrderCharge::UnitOfMeasure ] Set Variable [ $BillingFrequency; Value:OrderCharge::BillingFrequency ] Set Variable [ $BillingMode; Value:OrderCharge::BillingMode ] Go to Layout [ “OrderChargesTableView” (OrderCharge) ] New Record/Request Set Field [ OrderCharge::OrderID; $OrderID ] Set Field [ OrderCharge::ChargeID; $ChargeID ] Set Field [ OrderCharge::ChargeDescription; $ChargeDescription ] Set Field [ OrderCharge::Quantity; $Quantity ] Set Field [ OrderCharge::Rate; $Rate ] Set Field [ OrderCharge::UnitOfMeasure; $UnitOfMeasure ] Set Field [ OrderCharge::BillingFrequency; $BillingFrequency ] Set Field [ OrderCharge::BillingMode; $BillingMode ] Commit Records/Requests Go to Layout [ “Masterfile - Charges” (Charge) ] Go to Record/Request/Page [ Next; Exit after last ] End Loop
March 9, 200916 yr So what isn't working? At a guess you probably need to set the ChargeID to that of the new record, not the old one.
March 9, 200916 yr Author The script steps after the # comment step do not seem to execute. The OrderCharges for adding all belong to the same Order and that's why the OrderID doesn't change within the loop. The primary key for OrderCharges is OrderChargeID and it is generated automatically.
March 9, 200916 yr Is there a found set after the Perform Find? I cannot see anything in the code that looks broken.
March 10, 200916 yr Author Solved it. Where I had: Set Variable [ $OrderID; Value:"gOrderID" ] it was storing the literal gOrderID, when I really wanted to specify the global field there. Once I did that, it worked fine. (I did find a couple of other problems, but solved those as well.) I don't think I could have solved it without the feedback from this board telling me that I was on the right track. Many thanks to all. Hal
Create an account or sign in to comment