A Multivalue key can be used to show your selected products. You'll need one field for showing all products and another for showing just the selected products.
When you click a button in the portal row, it can add the portal record's primary key to the list. Clicking it a second time can remove it and the button can look and act like a check box to show you which are selected.
If you selected records with serial numbers 1234, 654, 980 for your portal, the text field would show:
A relationship such as:
SampleTable::ProductListField = SelectedProducts::ProductID
will provide the needed portal.
A script to add/remove an item from this field:
If [ IsEmpty ( FilterValues ( Sample::ProductListField ; ProductPortal::ProductID ) ) // not in list]
Set Field [ Sample::ProductListField ; List ( Sample::ProductListField ; ProductPortal::ProductID ) ]
Set Field [ Sample::ProductListField ; Substitute ( ¶ & Sample::ProductListField & ¶ ; ¶ & ProductPortal::ProductID & ¶ ; ¶ ) ]
Set Field [ Sample::ProductListField ; Middle ( Sample::ProductListField ; 2 ; Length ( Sample::ProductListField ) - 2 ) ]
A calculation field with this calculation can be put in the portal where you select values:
not IsEmpty ( FilterValues ( AllProducts::ProductListField ; ProductID ) )
And if you format this field as a checkbox with 1 as it's sole custom value, you can resize the field to hide the one and set it up as the button to run the above script. Clicking the check box will check it and the product will be added to the Selected Product portal.
Cool, will this result in the entire porodcut list on the portal for each sample request record?
That's what i'm wanting. I want them to create the sample request and have the entire list of porducts to pick from.
They can check each item and then send the samples.
Then when a new sample request record is made, the portal of the products is specific to that sample request record and it will show no products checked yet..
You can have two portals: One that lists all products and one that only lists the selected products.
Here's a demo file where I made sure the script I posted worked correctly: http://www.4shared.com/file/47D2cLni/CheckboxWScrollBar.html
Is there any way to when i create a new record, the checkboxes in the all products portal are all empty?
For some reason on on my layout, the checkbox does the right things, but does not turn "x" checked when i click on it...
Why would this be happening?
Darn, didn't check this with a second record. The X operator is matching back to the original sample record and that's why the boxes are still showing as checked.
Make the List field a global field, but include scripts that copy the list from the gobal field to and from the list field local to your sample record.
On record load can perform a script to copy the local field's list to the global. The selection script can then be modified to update the global field every time the local field is updated. (or vice versa)
I've updated the original demo file with these changes and reuploaded it with the same down load link.
You're a genious! Works perfectly!
What would be my steps to add a qty box to the products?
When i do it, it keeps the same item qty in all the same request records.
I know i'll have to do something similar to the checkbox, i'm just now sure what.
In what table are you defining Qty?
What does this Qty represent here?
I may have painted us into a corner here. Instead of this "cute trick" we may have to toss it and instead use a Join table that matches products to samples just like a line item table matches products to an invoice.
Our products are sheets of paper.
So qty would refer to the number of sheets of paper we would send in the sample.
I hope we can make it work because what you have done for me so far works great!
Sorry, but now you have a second item of data for each selected product unique to the sample. Treat each sample to product as though each sampoe is an invoice with a line items table in a portal for your selected products. You can then define a Qty field in the SampleLineItems table for recording the quantity.
See Comment's Invoices Demo if you are unfamiliar with this approach. Just rename "invoices" as "samples" and the basic set up should work for you:
There are ways that you can still use a portal of products for selecting them if you really want.
This last demo shows 4 different approaches to selecting items for an invoice without having to scroll through a massive list of items in the product ID field. Two of them use a portal so this might give you some ideas.
I'm not able to get the sample line item portal to populate with all of the products.
Wouldn't adding the new line item table and relating it to the samples and products work? I thought so, but it's not working for me.
That's what I am describing:
Enable "Allow creation..." for SampleLineItems on the Sample to SampleLineItems relationship
Take a look at the EnhancedValueSelectionDemo file. It has scripts that create a new record in the LineItems table when the user clicks a row in the portal to products.