It's the part "relate products to that order" that is very fuzzy here... but I'm going to leave that alone :) I assume you have a design that you are going with...
You only have a few options here: you either create the item first, or you capture it after creation and use it to relate your products.
Here are a few ideas:
Example:
Lets say that you have a aspx page called "wait.aspx" that has the javascript code to retrieve the ID of the last Order created by the user (perhaps using the SPSerivces SPGetLastItemId() utility). To get the NewForm to redirect there you would opened it as:
Hope this helps... Good Luck.
Paul.
Ps. Although I was going to leave it alone, I'll just mention it: it still feels like the relationship you are trying to build can be supported with the OOB capabilities of SharePoint and List...
You only have a few options here: you either create the item first, or you capture it after creation and use it to relate your products.
Here are a few ideas:
Create item first - use EDIT form for user input
If you can control where the User clicks, then you might be able to just create the order with minimal input (ex. just a Title) behind the scenes using SPServices and use ID of new item to open it in the EDIT Form... Once you are on the Edit form, you already have the ID and thus you can use it to do the relation you speak of.Example:
- User clicks on NEW ORDER
- Script, using SPServices creates a new order with minimal input (using UpdateListItems), which returns the new item created (including the ID).
-
Use the ID of the new item and open it on the EDIT form.
Get the New item ID after create
The trick with this one is to redirect the NEW form, after the user clicks "OK" to a landing page where you have custom code to retrieve the new ID. This can be achieved by using the &Source=http://... URL param when opening the NewForm.aspx.Lets say that you have a aspx page called "wait.aspx" that has the javascript code to retrieve the ID of the last Order created by the user (perhaps using the SPSerivces SPGetLastItemId() utility). To get the NewForm to redirect there you would opened it as:
/NewForm.aspx?Source=http://yoursiteUrlEscaped/wait.aspx
When the user Clicked OK on the new form, if all was successful, they will be redirected to the wait.aspx page where your code would then run, get the ID and make the relationship of the order to the Products. Hope this helps... Good Luck.
Paul.
Ps. Although I was going to leave it alone, I'll just mention it: it still feels like the relationship you are trying to build can be supported with the OOB capabilities of SharePoint and List...