I have built a tool that uploads/overwrites hosted feature layers on enterprise portal on a weekly basis. The tool works fine, but the share with organization is not being recognized. The UploadServiceDefinition help states you must be signed into portal, so I included portal sign in in my script.
I set the in_organization parameter to "SHARE_ORGANIZATION" however, when my model runs it is not sharing with the organization.
This image shows my script successfully ran and I was signed into portal, and my sharing parameter was correctly set to SHARE_ORGANIZATION:
the actual script collects the parameter as input in a variable called share_organization (which can be set to SHARE_ORGANIZATION or NO_SHARE_ORGANIZATION per the ESRI documentation).
The upload command is here (uses the else clause in this particular case):
Parameters collected here:
I've been wracking my brain over this one...I have a similar script that publishes referenced registered data with similar settings and the share with organization part of the script (identical to this only on a federated server) works fine there.
Anybody have any idea why this is not working!?
Solved! Go to Solution.
Okay, So for those who want to know, I found a work-around here that allows me to share with the organization (without the portal sign-on).
In the script, after it created the sddraft, I simply opened it and changed the parameter to true using the following code (if share organization is equal to SHARE_ORGANIZATION execute the function):
```
import xml.dom.minidom as DOM
def changeShare(sddraftPath):
# Read the sddraft xml.
doc = DOM.parse(sddraftPath)
properties = doc.getElementsByTagName('PropertySetProperty')
for property in properties:
key = property.firstChild.firstChild.data
try:
if key == 'PackageUnderMyOrg':
property.firstChild.nextSibling.firstChild.data = 'true'
break
except:
continue
# Write to sddraft
f = open(sddraftPath, 'w')
doc.writexml(f)
f.close()
```
Hi Angela,
A quick suggestion: Maybe the parameter is a string with the value 'true' or 'false' and the method expects a boolean?
You could try GetParameter instead of GetParameterAsText or convert the input to a boolean?
Something like this has thrown me off before!
Regards
Carsten
Thanks Carsten, I thought of that, but I actually found a work around!
Okay, So for those who want to know, I found a work-around here that allows me to share with the organization (without the portal sign-on).
In the script, after it created the sddraft, I simply opened it and changed the parameter to true using the following code (if share organization is equal to SHARE_ORGANIZATION execute the function):
```
import xml.dom.minidom as DOM
def changeShare(sddraftPath):
# Read the sddraft xml.
doc = DOM.parse(sddraftPath)
properties = doc.getElementsByTagName('PropertySetProperty')
for property in properties:
key = property.firstChild.firstChild.data
try:
if key == 'PackageUnderMyOrg':
property.firstChild.nextSibling.firstChild.data = 'true'
break
except:
continue
# Write to sddraft
f = open(sddraftPath, 'w')
doc.writexml(f)
f.close()
```