I've created an Add-In to ArcGIS Pro to facilitate importing and publishing a web map. I have a map package that I'm importing. I need to change the data source in the map to a hosted feature service in ArcGIS Online. In the Add-In code, I have this method:
private static void ResetFeatureServiceDataConnection(Layer dataConnectionLayer, string newConnectionString)
{
CIMStandardDataConnection dataConnection = dataConnectionLayer.GetDataConnection() as CIMStandardDataConnection;
dataConnection.WorkspaceConnectionString = newConnectionString;
dataConnectionLayer.SetDataConnection(dataConnection);
}
The parameters to this method are a map layer and the URL for the hosted feature service. This method changes the data source in the layer, but it doesn't change the ItemID.The ItemID is referencing the original data source (from the map package I imported). When I publish the map, the datasource is based on the ItemID, not the Url that I've set in the code.
I've tried changing the data source from the Layer Properties in ArcGIS Pro. When I click the Set Data Source button and select the layer in my hosted feature service, the URL changes, but not the ItemID.
Is there a way to change the Item ID to match the ItemID of the hosted feature service?