I would use the document type in your setranges.
IF NOT sh.FIND('-') THEN
I've done somthing like this in the past for Credits. Where the user creates the header and we import the lines. I use the Sales Line as the dataitem since the header already exists.
On my function button I have this code:
Name DataType Subtype Length
GetItemFromFile->Dataport->Internet Returns Import //basically my dataport name
My dataport is like this, where I have created a function to get the info from the header like doc no & type called "SetGlobalParameters". then I can use those values to import lines into the header that I'm working on.:
ReturnLineNo := 0;
ReturnLineNo := ReturnLineNo + 10000;
"Sales Line"."Document Type" := "Sales Line"."Document Type"::"Credit Memo";
"Sales Line".VALIDATE("Document No.",vDocumentNo);
"Sales Line".VALIDATE("Line No.",ReturnLineNo);
"Sales Line".Type := "Sales Line".Type::Item;
"Sales Line"."Return Reason Code" := ReturnBoxCode;
SetGlobalParameters(DocSubType : Integer;DocType : Integer;DocNo : Code)
vOrderType := DocSubType;
vDocumentType := DocType;
vDocumentNo := DocNo
Works Great! If you think the trigger if firing more than once perhaps it's running for every document type option since you're not SETRANGE-ing "order" and you can always throw in a MESSAGE('Whatever'); in your code so you can see what & when it's firing.