@@ -911,11 +911,12 @@ internal void ConnectToCdsService(string cdsConnectionString)
911911 /// <param name="externalOrgWebProxyClient">User Provided Organization Web Proxy Client</param>
912912 /// <param name="isCloned">when true, skips init</param>
913913 /// <param name="orginalAuthType">Auth type of source connection</param>
914- internal CdsServiceClient ( OrganizationWebProxyClient externalOrgWebProxyClient , bool isCloned = true , AuthenticationType orginalAuthType = AuthenticationType . OAuth )
914+ /// <param name="sourceOrgVersion">source organization version</param>
915+ internal CdsServiceClient ( OrganizationWebProxyClient externalOrgWebProxyClient , bool isCloned = true , AuthenticationType orginalAuthType = AuthenticationType . OAuth , Version sourceOrgVersion = null )
915916 {
916917 CreateCdsServiceConnection ( null , orginalAuthType , string . Empty , string . Empty , string . Empty , null , string . Empty ,
917918 MakeSecureString ( string . Empty ) , string . Empty , string . Empty , string . Empty , false , false , null , string . Empty , null ,
918- PromptBehavior . Auto , externalOrgWebProxyClient , isCloned : isCloned ) ;
919+ PromptBehavior . Auto , externalOrgWebProxyClient , isCloned : isCloned , incomingOrgVersion : sourceOrgVersion ) ;
919920 }
920921
921922
@@ -945,8 +946,9 @@ internal CdsServiceClient(OrganizationWebProxyClient externalOrgWebProxyClient,
945946 /// <param name="certificateStoreName">StoreName to look in for certificate identified by certificateThumbPrint</param>
946947 /// <param name="certificateThumbPrint">ThumbPrint of the Certificate to load</param>
947948 /// <param name="instanceUrl">Actual URI of the Organization Instance</param>
948- /// <param name="isCloned">When True, Indicates that the contruction request is coming from a clone operation. </param>
949+ /// <param name="isCloned">When True, Indicates that the construction request is coming from a clone operation. </param>
949950 /// <param name="useDefaultCreds">(optional) If true attempts login using current user ( Online ) </param>
951+ /// <param name="incomingOrgVersion">Incoming Org Version, used as part of clone.</param>
950952 internal void CreateCdsServiceConnection (
951953 object externalOrgServiceProxy ,
952954 AuthenticationType requestedAuthType ,
@@ -971,7 +973,8 @@ internal void CreateCdsServiceConnection(
971973 X509Certificate2 certificate = null ,
972974 Uri instanceUrl = null ,
973975 bool isCloned = false ,
974- bool useDefaultCreds = false
976+ bool useDefaultCreds = false ,
977+ Version incomingOrgVersion = null
975978 )
976979 {
977980
@@ -1037,6 +1040,10 @@ internal void CreateCdsServiceConnection(
10371040 {
10381041 CdsConnectionSvc = new CdsConnectionService ( externalOrgWebProxyClient , logEntry ) ;
10391042 CdsConnectionSvc . IsAClone = isCloned ;
1043+ if ( isCloned && incomingOrgVersion != null )
1044+ {
1045+ CdsConnectionSvc . OrganizationVersion = incomingOrgVersion ;
1046+ }
10401047 }
10411048 else
10421049 {
@@ -1196,9 +1203,8 @@ public CdsServiceClient Clone(System.Reflection.Assembly strongTypeAsm)
11961203 if ( proxy != null )
11971204 {
11981205 proxy . HeaderToken = CdsConnectionSvc . CdsWebClient . HeaderToken ;
1199- var SvcClient = new CdsServiceClient ( proxy , true , CdsConnectionSvc . AuthenticationTypeInUse ) ;
1206+ var SvcClient = new CdsServiceClient ( proxy , true , CdsConnectionSvc . AuthenticationTypeInUse , CdsConnectionSvc . OrganizationVersion ) ;
12001207 SvcClient . CdsConnectionSvc . SetClonedProperties ( this ) ;
1201- SvcClient . _BatchManager = _BatchManager ;
12021208 SvcClient . CallerAADObjectId = CallerAADObjectId ;
12031209 SvcClient . CallerId = CallerId ;
12041210 SvcClient . MaxRetryCount = _maxRetryCount ;
@@ -4826,7 +4832,7 @@ internal bool AddRequestToBatch(Guid batchId, OrganizationRequest req, string ba
48264832 {
48274833 // if request should bypass plugin exec.
48284834 if ( bypassPluginExecution && ConnectedOrgVersion >= Utilities . CDSFeatureVersionMinimums . AllowBypassCustomPlugin )
4829- req . Parameters . Add ( Utilities . CDSRequestHeaders . BYPASSCUSTOMPLUGINEXECUTION , " true" ) ;
4835+ req . Parameters . Add ( Utilities . CDSRequestHeaders . BYPASSCUSTOMPLUGINEXECUTION , true ) ;
48304836
48314837 if ( IsBatchOperationsAvailable )
48324838 {
@@ -5478,7 +5484,7 @@ internal OrganizationResponse CdsCommand_Execute(OrganizationRequest req, string
54785484
54795485 // if request should bypass plugin exec.
54805486 if ( bypassPluginExecution && ConnectedOrgVersion >= Utilities . CDSFeatureVersionMinimums . AllowBypassCustomPlugin )
5481- req . Parameters . Add ( Utilities . CDSRequestHeaders . BYPASSCUSTOMPLUGINEXECUTION , " true" ) ;
5487+ req . Parameters . Add ( Utilities . CDSRequestHeaders . BYPASSCUSTOMPLUGINEXECUTION , true ) ;
54825488
54835489 logEntry . Log ( string . Format ( CultureInfo . InvariantCulture , "Execute Command - {0}{1}: RequestID={2} {3}" ,
54845490 req . RequestName ,
@@ -5691,8 +5697,8 @@ private void LogException(OrganizationRequest req, Exception ex, string errorStr
56915697 else if ( ex is HttpOperationException httpOperationException )
56925698 {
56935699 JObject contentBody = JObject . Parse ( httpOperationException . Response . Content ) ;
5694- var errorMessage = CdsTraceLogger . GetFirstLineFromString ( contentBody [ "error" ] [ "message" ] . ToString ( ) ) . Trim ( ) ;
5695- logEntry . Log ( string . Format ( CultureInfo . InvariantCulture , "************ {3} - {2} : {0} |=> {1}" , errorStringCheck , errorMessage , webUriMessageReq , ex . GetType ( ) . Name ) , TraceEventType . Error , ex ) ;
5700+ CdsClientOperationException ex01 = CdsClientOperationException . GenerateCdsClientOperationException ( httpOperationException ) ;
5701+ logEntry . Log ( string . Format ( CultureInfo . InvariantCulture , "************ {3} - {2} : {0} |=> {1}" , errorStringCheck , CdsTraceLogger . GetFirstLineFromString ( contentBody [ "error" ] [ "message" ] . ToString ( ) ) . Trim ( ) , webUriMessageReq , ex . GetType ( ) . Name ) , TraceEventType . Error , ex01 ) ;
56965702 }
56975703 else
56985704 {
0 commit comments