Activity is outputting an object and I want to print this object inside another object

Hi Guys

I know this sounds confusing but an activity outputs an object and I want to pass the value of this object into another object for it to be outputted to the system.

In order for me to test that the output that the activity give is correct. I used object.tostring and value is correct. I then did object = object + “blah” + “blah”. But it did not output anything. I also tried adding object.tostring to it and it gives me the error object cannot use + operator. I also get the error object is not set to reference of an object.

Can someone please help?

@bobby

What kind of objects are you trying to add it ?

1 Like

It just says object. Nothing specific in uipath.

What is the variable type of this “object”?
Did the object.toString + "blah" +"blah" gave you errors?
It also looks like the object might not be initialized, before you are using it. Where exactly does it come from?

1 Like

image


It is an object of type object. No datatype like string or int etc.

@bobby
Try logging just department.ToString and see what that gives you. As @SSavickas mentioned if you’re getting an Object reference not set to an instance of an object. error it means that nothing was returned from the activity so your department object has no value at the point where you are trying to log it. In that case you’ll want to do a null check which you can do by using department is nothing inside an If statement.

1 Like

Hi Daniel. I tried that before. It is populating with a value. But passing it into another object. It seems to lose it’s content.

@bobby
Can you check the scope of your variable and also make sure that you haven’t accidentally duplicated it?

1 Like

Yeah @DanielMitchell. I check it. I wonder if it’s just a bug in the activities?

@bobby
What activity are you using?

1 Like

It’s a beta active directory activity

@bobby
When you’re trying department.ToString or "sometext" + department.ToString are you doing it from the variable panel like you are in this picture that you shared?

If so it will always fail with the “Object reference not set to an instance of an object.” because the bot initializes that variable when it starts, so department will never have any value there.

1 Like

Yes, I am doing through the variable panel. Ok that makes sense. Should I do it as an assign? But I tried doing in an assign String dep = department.tostring and then passed in dep into the newDescription and it still didnt work.

@bobby
Yes, you should be able use an Assign to do this. Create the variable, make sure it’s type is String and then try myVar = department.ToString + "some string" I would also recommend putting a Log Message after that to log the value of myVar and make sure it is what you’d expect.

1 Like

It worked. Brilliant, thanks man. :slight_smile: That’s annoying, it was so simple.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.