Hi All,
I am trying to make a button for our Ordering Team to be able to Re-create a previous order.
Now the original order form contains a normal record and then a portal.
The portal contains the 'Part Numbers; and such - whereas the other section contains company name, order date and other generic fields.
Now I've set my script up so it goes from an 'Order History Layout' which is just a breakdown of the Portal section from above.
Script as below:
Set Error Capture [On]
Set Variable [$OrderId; Value:Order_Item::_ORDID]
Show Customer Dialog ["Is this the correct Order ID"; Order_Item::_ORDID]
Go to layout ["Order Details" (Orders)]
Perform Find [Restore]
Duplicate Record / Request.
So far the script does exactly what I need; except it does not pull through the portal records of the record we are duplicating.
Any advice or solutions would be great!
Thanks,
Hi Craig,
It's not duplicating the portal records because those are part of a different table.
Your best bet is to create a new window and search for the related records in that. Something like:
#New code goes after the find
If IsEmpty ( PortalRelationship::orderID )
Duplicate Record / Request
#nothing more to do since there are no related records
Else
Duplicate Record / Request
Set Variable [ $newOrderID ; Order_Item::_ORDID ]
New Window
Go To Layout [ layout based on portal records ]
Enter Find Mode
Set Field [ orderID ; $OrderId ]
Perform Find
If [ Get ( FoundCount ) ]
Loop
Exit Loop If [ Get ( FoundCount ) = 0 ]
Go to Record/Request [First]
Duplicate Record / Request
# The duplicated record is always added to the end of the found set, as long as the found set is not sorted
Omit Record
Go to Record / Request [ Last ]
Set Field [ orderID ; $newOrderID ]
Omit Record
End Loop
End If
Close Window
End If
Using a new window means that you won't have to worry about restoring the found set or the appropriate layout when you're done with the related records.
There's probably some more error checking that needs to happen, but this is the basics of it.