Trimble Connect User Forum

 View Only

 Principal does not contain a definition - .NET SDK

Jump to Best Answer
Kamil Pastuszko's profile image
Kamil Pastuszko posted 07-28-2021 04:15
Hello,

I am using .NET SDK to create a program that logs in Trimble, gets all projects, selects one project by name, then gets all todos. Finally it creates .csv file, where all the data that I want is stored.

Unfortunately I've ran into a problem regarding todo.Assignees, I would like to get an email of every person assigned to each todo, but instead I'm encountering this error message:Same thing happens with .FirstName and .LastName. I am able to get data like CreatedBy, CreatedOn, ModifiedBy, ModifiedOn, Type and Identifier, here's an example:
This is a screenshot of the array I've got a problem with:And this is how I select one project and todos in it:
Do you know how could I fix this issue, by any chance?

Regards,
Kamil
Kimmo Keränen's profile image
Kimmo Keränen Best Answer
Hi Kamil,

You have to check if the ToDo assignee is a Person or Group, both of which are derived from the base class Principal. If the concrete instance is Person, you need to cast the assignee to Person and then you have email, and the name properties available.
Kamil Pastuszko's profile image
Kamil Pastuszko
Thank you for your response, I found out that Assignee is a person, but I am not sure how to cast the assignee to Person, is there some kind of example for a beginner like me?
Kimmo Keränen's profile image
Kimmo Keränen
You can use "as" operator like in this article.
Kamil Pastuszko's profile image
Kamil Pastuszko

Thanks, I did it this way:
But now person.Email gets only first array from Assignees from each todo.

Is it possible to set it in a way that I can get all arrays (emails) from each todo?

Kimmo Keränen's profile image
Kimmo Keränen
Hi Kamil,

I suggest you ask these generic programming related questions from C# forums. Usually similar questions have already been asked and answered, like your latest question is answered here. So, you don't even have to ask, only find the question and answer by simple googling.
Kamil Pastuszko's profile image
Kamil Pastuszko

Thanks again for answering, I've managed to do it in another way using loops.

I've got another question which is related to Trimble Connect, so I'm gonna create a new thread because I've set this one as answered already.