When I publish a Python script tool as a geoprocessing service directly (Share -> Publish a service), layer names that come in as Feature Layer parameters from a list of layers in the current map get changed to "ServiceName\LayerName" (ie, "EncroachmentPermitGenerator\mySDE.SDEuser.encroachment_permits_current"). When I publish the script using 'Save a service definition file' (with 'No available connection') and then the Upload Service Definition tool, the layer name comes through unchanged (ie, "mySDE.SDEuser.encroachment_permits_current").
For example, I had to change this line from 'if l.name = permit_layer' to 'if l.name in permit_layer' because the mxd's layer name didn't have the service name prepended to it. A simple change, to be sure.
Is this the expected behavior? When writing scripts for Geoprocessing Services, should I anticipate the service name being prepended to any layer name parameters?
(The save as a definition -> upload definition process was a workaround for our older 10.4 server that, for whatever reason, didn't recognize the data being registered in the data store. This might be related to BUG-000098784 and BUG-000100260 from the 10.5 and 10.6 release notes, but I'm not certain—I figured out the workaround and moved on.)