@@ -106,18 +106,30 @@ public void SetValue(IContentBase content, string alias, string value)
106
106
if ( ! isInternal )
107
107
continue ;
108
108
109
- //Get the UDI value in the JSON
110
- var pickedUdi = GuidUdi . Parse ( relatedLink [ "link" ] . ToString ( ) ) ;
111
-
112
- //Lets use entitiy sevice to get the int ID for this item on the new environment
113
- //Get the Id corresponding to the Guid
114
- //it *should* succeed when deploying, due to dependencies management
115
- //nevertheless, assume it can fail, and then create an invalid localLink
116
- var idAttempt = _entityService . GetIdForKey ( pickedUdi . Guid , UmbracoObjectTypes . Document ) ;
117
-
118
- //Update the JSON back to the int ids on this env
119
- relatedLink [ "link" ] = idAttempt . Success ? idAttempt . Result : 0 ;
120
- relatedLink [ "internal" ] = idAttempt . Success ? idAttempt . Result : 0 ;
109
+ var relatedLinkValue = relatedLink [ "link" ] . ToString ( ) ;
110
+
111
+ //Check if related links is stored as an int
112
+ if ( int . TryParse ( relatedLinkValue , out var relatedLinkInt ) )
113
+ {
114
+ //Update the JSON back to the int ids on this env
115
+ relatedLink [ "link" ] = relatedLinkInt ;
116
+ relatedLink [ "internal" ] = relatedLinkInt ;
117
+ }
118
+ else
119
+ {
120
+ //Get the UDI value in the JSON
121
+ var pickedUdi = GuidUdi . Parse ( relatedLinkValue ) ;
122
+
123
+ //Lets use entitiy sevice to get the int ID for this item on the new environment
124
+ //Get the Id corresponding to the Guid
125
+ //it *should* succeed when deploying, due to dependencies management
126
+ //nevertheless, assume it can fail, and then create an invalid localLink
127
+ var idAttempt = _entityService . GetIdForKey ( pickedUdi . Guid , UmbracoObjectTypes . Document ) ;
128
+
129
+ //Update the JSON back to the int ids on this env
130
+ relatedLink [ "link" ] = idAttempt . Success ? idAttempt . Result : 0 ;
131
+ relatedLink [ "internal" ] = idAttempt . Success ? idAttempt . Result : 0 ;
132
+ }
121
133
}
122
134
123
135
//Save the updated JSON with replaced UDIs for int IDs
0 commit comments