Getting 'Specified cast is not valid' when trying to add to record list

Hi there.

I'm designing code to insert a variable number of values into an entity for graph on a mobile app. However, in my c# code, I'm flipping through and array of decimals, which I want to add to this record list. When I use 'NameOfList'.Add("Data to add") it says 'Specified cast is invalid'. Any help on why this is happening, or alternatives for append to a record list, would be super helpful.Thank you.

Hi ProfLiam,

Are you sure that the data types of the list and the data are the same? This error could occur if say you were trying to add a double to a list of ints.

Regards

Hi Stefan,

Thank you for the swift reply. Yes, I have ensured that the datatypes are both Decimal, and just checked again. I have tested it with other datatypes too, however I get the same error. Perhaps the manner in which I add it is incorrect? I could not find much documentation on this, so I'm quite unsure about the way I'm going about it. Any help is much appreciated. Thanks!

Regards



Hi, 

Then I am unsure, Im not currently able to test this myself but it could have to do with it being a record list. Perhaps you could create a record to add and not just add the decimal data itself to the list. 

Regards

If you're trying to add to a RecordList variable, could you use the Append method instead?


This post has a more complex code sample that may help you find the issue.

Rejection.ssSTNMMResponse_RejectionMeterReading_Content_Item.ssRejectionList.Append(SimpleRejection);


In any case, I believe you will also need to encapsulate each Decimal value in a Record. As far as I know, Integration Studio doesn't support "lists of values" the way more recent versions of Service Studio do.

Stefan van Deventer wrote:

Hi, 

Then I am unsure, Im not currently able to test this myself but it could have to do with it being a record list. Perhaps you could create a record to add and not just add the decimal data itself to the list. 

Regards

Hi Stefan,

Thank you for the reply. I understand, I'll have to dig deeper into how to modify such a list.

Regards


Gonçalo Soares wrote:

If you're trying to add to a RecordList variable, could you use the Append method instead?


This post has a more complex code sample that may help you find the issue.

Rejection.ssSTNMMResponse_RejectionMeterReading_Content_Item.ssRejectionList.Append(SimpleRejection);


In any case, I believe you will also need to encapsulate each Decimal value in a Record. As far as I know, Integration Studio doesn't support "lists of values" the way more recent versions of Service Studio do.

Hi Gonçalo,

Thank you for the reply. That could work, so I will try that out using .Append() instead. Thank you for the post, I'll read through that and see if I can gain a deeper understanding of record lists. Ah, I see, so this is perhaps the incorrect way to do it altogether? If it isn't supported as a list of values I might need to find an alternative, if there is one. It's odd that Integration Studio isn't as up to date as service studio.

Regards