August 1, 201213 yr Hello, Here is what I wish to achieve (I am in the event management industry): I have a final Estimate and from the information in its related EstimateLines table I wish to pull out a value of a certain field to use to populate fields in a PlanningDocument table. Working with Loop, and moving to next record, I have it working somewhat, but I can't seem to find a way to assign a different variable for each Loop/EstimateLine. I understand how to Loop with a counter; but what I can't seem to figure out is to script a different variable for each Loop? In other words can I do something like this: $Item + 1 Or is this the wrong approach? Might an export/import work better? I hope I have been somewhat clear..... Thank you in advance for any help
August 1, 201213 yr How about: $item & ¶ & 1 That makes a list of the values in one variable, then you can use GetValue to pull them out. Alternatively you can use variable repetitions, where the repetition is the $counter.
August 1, 201213 yr Author Thank you David for your quick response! I'm still quite new to scripting; but, I think I can do this. I'll play around with this, but I might show up here again! Thanks again
August 1, 201213 yr Author Ok....I'm stuck already... I have a couple of questions. In the Set Variable dialog box, I would put "$Item" in the "Name" box? And in the "Reptition" box I would put "$Item & ¶ & 1"? However, I can't seem to see if this working properly because I want to then put the whole list of items (not just one), into another field. But I can't seem to figure out how to (with GetValue or even simply Set Field) to dump the whole lot into another field. I'll try and explain a little clearer (I hope...) what I'm trying to achieve: What I'm looking to do is aggregate all the values of a certain field from a found set. I scripted a find for the EstimateLines related to a certain Estimate and a certain category of items. Let's say "non-alcoholic beverages" found in Estimate #23. I want the values of ALL the items of ALL the EstimateLines of the found set (for example: "Orange Juice", "Cola", "Bottled Water") I want to then put this aggregated list (if possible with a carriage return in between) in a field in a PlanningDocument table so that the wait staff can see what non-alcoholic beverages have to be prepared. In other words, I want it to display: Orange Juice Cola Bottled Water I will then do the same for other categories (such as "alcoholic beverages" and then "food"...) Thank you, for any extra help you can give.
August 1, 201213 yr You've got three boxes in a Set Variable[] script step. Name, Value, and Repetition. Let's ignore the Repetition (just leave it at 1). The name of the variable is $item. As you loop through each record set the variable value to $item & ¶ & EstimateLines::Item (or whatever your field is named). At the end of your loop you will have a variable with a list of all the items. You can Set Field[] with $item or make it a global variable to show using Insert Merge Variable.
August 1, 201213 yr Author Thank you, thank you, thank you. It all makes sense now. A small note. I'm getting a carriage return at the beginning of the field in which I'm Setting. Not a big deal, but I can't understand why that might happening.
August 1, 201213 yr The first time it loops $item is empty. Try this instead: $item & If ( not isEmpty ( $item ) ; "¶" ) & EstimateLines::Item )
August 1, 201213 yr The first time it loops $item is empty. Try this instead: $item & If ( not isEmpty ( $item ) ; "¶" ) & EstimateLines::Item ) You don't have to declare a variable before you use it. So it's easier to write Set Variable [ $item ; List ( $item ; EstimateLines::Item ) ] within the loop, which prevents a leading CR. EDIT: Here's a simple example. SimpleLoop.fp7.zip
August 1, 201213 yr Author Worked like a charm. It all makes so much sense when it is shown to you. I hope some day I can think more clearly through these things. Thanks again
August 1, 201213 yr I have a final Estimate and from the information in its related EstimateLines table I wish to pull out a value of a certain field Instead of looping, you could be on a layout of Estimates and set the variable to = List ( EstimateLines::CertainField )
August 23, 201213 yr Author hmmm...reviving this post because I've ran into an odd problem. I've adapted the script that David Jondreau suggested to transfer lines from our Run Sheet to a Planning Doc field. It worked beautifully until one day, it refused to carry over any Lines that had a date before the Event Date. There is nothing in my script that would instruct to do something... I've watched the script in action as much as I can, and I can't see where it might be going wrong. The data viewer also shows the info not being attached to the variable.... I find it really odd. I was wondering if someone might be able to point me in some direction.... Thanks
August 23, 201213 yr Author Sorry, figured it out.....sort of It had to do with my sort when in my Run Sheet Lines layout.... Got rid of all the sorting options - it is carrying all the info now....but gotta find a way to make it sort... If I can't figure it out -- I will be back here! Thanks
Create an account or sign in to comment