Convert System.Object to String Variable

Hello, How to convert object variabe to string
My object variable cc is like this and when i convert that .toString then it changed like this.

1 Like

Hi @rajat_dhammi,

Probably you need the properties of this object as String.

So, access it first and then convert it to String.

Example: cc.Description.ToString

HI, @gustavo.cervelin,
How to get the properties
I am getting below error

1 Like

Sorry Rajat

Try cc.FieldUrlValue.Description.ToString

Hi, @gustavo.cervelin,
Getting this error

1 Like

Is this object a custom one?

Could you share your project?

Don’t need to be the whole project, just a simple sequence with this object variable declaration, the assign to cc variable and what you need to do before to be able to assign.

I am reading sharepoint list and reading it from there.
Like this

1 Like

and variable type is this

1 Like

Got it…

I need to check your project. A simple sequence containing this part you mentioned above is enough.

Be sure to delete sensitive data, if applicable.

Convert type of cc variable to string in variables tab, and then assign
cc= item(“ContentCale”).To string


It would be item(“ContentCalendarURL”).ToString

Looks like u just mentioned item(“ContentCalendarURL”)

Please add .To string and try

Giving wrong value if change cc to string
cc is object variable and cc1 is string, with string got completely wrong output

Hi, did you manage to resolve this? If not, please let me take a shot at it.
From what I’ve seen in this thread:

  • I think @gustavo.cervelin suggests the correct method (cc.Description.ToString should be correct, cc.FieldUrlValue.Description.ToString won’t work as that calls to a second FieldUrlValue object within the first one FieldUrlValue members (Microsoft.SharePoint.Client) | Microsoft Learn
  • I think @User12’s method won’t work here as you need only 1 property out of the object, not the whole object as a string (if I interpreted your question correctly)
  • I’m taking a couple of guesses here based on my understanding of the inner workings of VB/UiPath. If anyone can correct me or describe more accurately, please educate me!
  • If anything I wrote made sense or was useful, please let me know. It teaches me how to teach others :slight_smile:

Things you could try:

  1. In reply 1 below you are trying to assign the property.tostring to a message box. I’ve noticed that sometimes (there probably are people here who are smarter than me that can explain exactly why) UiPath doesn’t like when you convert (.ToString is a conversion to String type) and assign at the same time, and then use that value immediately (like you: you want to display it in a message box). You could try assigning cc.Description.ToString to a string variable, and then assign the string variable to the message box.
  2. You could try getting the value directly from the item (without assigning it to cc first). Try creating a string variable, and assigning item("ContentCalendarURL").Description.ToString.
  3. If this doesn’t work you could try assigning cc.Description (without the .ToString) to a generic type variable, and then assign that generic value to the message box. This might either work (as the generic var will be automatically converted to whatever you need it to be, I think this is called “implicit conversion”). It might also not work, but the error message might show you why ("Compiler error(s): Option Strict On disallows implicit conversions from ‘X’ to ‘String’). “X” would tell you which type of data comes from the cc.Description.

Reply 1:

I’ve noticed in this thread that you’re changing around multiple things while debugging. Best practice if you want to debug is to change only one thing at the time, and keep all others the same. This way you can analyze the results of your actions much better (I know this is hard, I always fall for the same trap because I’m just trying different things). Example:
In this reply you change both the assign activity that you want to do (Assign instead of Message Box activity) and the value that you want to assign to it. This makes it much harder to understand and compare the results you are getting.

1 Like

Did you resolve this issue? Been trying to archieve the same as you, but without succes.