Hi,
In my Linq statement,
(From row In dtData
Let x= New Object(){row(“id”),row(“Id”),row(“firstName”),row(“middleName”),row(“lastName”),row(“dateOfBirth”),row(“phoneNumber”),(String.Concat(in_Id+““+ID,””,row(“id”),““,row(“Id”),””,row(“firstName”),“_”,row(“lastName”))).Substring(0,127)}
Select dtTempData.Rows.Add(x)).copytodatatable
assigned this into another datatable here throwing an issue like,“Index and length must refer to a location within the string. (Parameter ‘length’)”
I think this part is causing the exception. Perhaps your string does not contain that many characters?
We would recommend to ensure that never the AsEnumerable part is ommited
We could rewrite the LINQ to
(From row In dtData.AsEnumerable
Let sj = String.Format("{0}*{2}*{3}*{4}*{5}_{6}",in_ID,ID,row("id").toString.Trim,row("Id").toString.Trim,row("firstName").toString.Trim,row("lastName").toString.Trim)
Let sjs = String.Join("",sj.Take(127))
Let ra= New Object(){row("id"),row("Id"),row("firstName"),row("middleName"),row("lastName"),row("dateOfBirth"),row("phoneNumber"),sjs}
Select r = dtTempData.Rows.Add(ra)).copytodatatable
And also have additional options to increase te readability
Thanks for your reply I find the solution to set the condition like,
If(concatenatedString.Length > 126, concatenatedString.Substring(0, 126), concatenatedString)
The issue is from the string length.
let us demonstrate the approach, as it is working with any shorter length:
I tried with this approach also but it not working effectively Take function also throw an error.here over string not only mean to be under 127characters the scenario is above 127characters also that’s why set the if condition…
can you show what was modelled?
Same error was thrown for take function also.“Index and length must refer to a location within the string. (Parameter ‘length’)”
keep in mind the working demos from above. Feel free to RnD it also within the immediate panel
However, we do feel that we helped to advance the solution and that the topic can be closed
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.