diff --git a/GSCFieldApp/Services/DatabaseServices/DataIDCalculation.cs b/GSCFieldApp/Services/DatabaseServices/DataIDCalculation.cs index b81571c9..e5eef9fc 100644 --- a/GSCFieldApp/Services/DatabaseServices/DataIDCalculation.cs +++ b/GSCFieldApp/Services/DatabaseServices/DataIDCalculation.cs @@ -719,7 +719,18 @@ public string CalculateDocumentAlias(int parentID, string parentAlias, int start { string lastAlias = docParent.ToList()[0].ToString(); //Select first element since the list has been sorted in descending order string lastNumberString = lastAlias.Substring(lastAlias.Length - 3); //Document only has three digits id in the alias - int newNumber = Convert.ToInt16(lastNumberString) + startingDocNumber; + string validLastNumber = string.Empty; + foreach (char c in lastNumberString) + { + if (char.IsNumber(c)) + { + //Rebuild number + validLastNumber = validLastNumber + c; + } + + } + + int newNumber = Convert.ToInt16(validLastNumber) + startingDocNumber; bool breaker = true; while (breaker)