- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-10-22 08:15 AM
I have a collection with 20 columns. I want to rename all of them with same names in Upper or Lower case and also want to trim the field names using a code stage.
can anyone have a solution?
------------------------------
vinod chinthakindi
------------------------------
Answered! Go to Answer.
Helpful Answers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-11-22 02:20 PM
I just figured out the code. Following code helps me to achieve my requirement. I just tweaked Rename Field Action code.
Collection_Out = Collection_In.Copy
For Each c As DataColumn in Collection_Out.Columns
c.ColumnName = Trim(c.ColumnName).ToUpper
Exit For
Next
------------------------------
vinod chinthakindi
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-10-22 09:07 AM
You could get a list of the current column names using the 'Get Collection Fields' action. You could then Loop the collection, formatting the values to meet your requirement. Then, call the 'Rename Collection Fields' action passing the data Collection and the Collection containing the formatted column names to the action.
------------------------------
Carl Carter
Senior Developer
Blue Prism
Europe/London
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
15-11-22 05:18 PM
Hi Vinod,
As Carl says, this is the easiest option, you can use the following functions in a calculation stage within a loop to do this such as
Trim(Lower([collection.Name]))
or
Trim(Upper([collection.Name]))
------------------------------
Ronan Considine
Senior Business Analyst
Blue Prism
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-11-22 10:03 AM
If possible could pls try it in your blue prism and share screenshots of process action steps . Want to look how its achieved.
Instead of Loops, Do we have any code stage for this?
------------------------------
vinod chinthakindi
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-11-22 02:20 PM
I just figured out the code. Following code helps me to achieve my requirement. I just tweaked Rename Field Action code.
Collection_Out = Collection_In.Copy
For Each c As DataColumn in Collection_Out.Columns
c.ColumnName = Trim(c.ColumnName).ToUpper
Exit For
Next
------------------------------
vinod chinthakindi
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-11-22 02:47 PM
When there is a solution which doesn't require custom code, then I would always offer this first unless there was a major performance gain from using a code stage. This is so more of the community can make use of the solution without needing to understand .NET code.
Well done in figuring out the custom code. I can see there is an issue with your code though. Your 'Exit For' command will exit your 'For Loop' after the first column name has been renamed. You should remove the 'Exit For' command unless it is your intention to only rename the first column.
------------------------------
Carl Carter
Senior Developer
Blue Prism
Europe/London
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-11-22 03:20 PM
I have updated my code and also included Flags for Trim and Uppercase using If else condition within for loop. Now its working well.
------------------------------
vinod chinthakindi
------------------------------
