Working with Object Record and Object RecordList via Extension.

Working with Object Record and Object RecordList via Extension.

Action: System.ListAppend

Has two parameters:
  • Generic RecordList
  • Generic Record
I can see it does not seem possible to create generic recordlist/record in ServiceStudio. 

However you can create an object via extension, I created an extension action similar to outsystems system ListAppend action. See extension code/attachment below.

KVP_Set Action, takes in KeyValuePair recordlist as an Object, and assigns Key/Value strings to a KeyValuePair record then appends the KeyValuePair record to the KeyValuePair recordlist object. 

The problem is when you send the object from outsystems using the structure via the KeyValuePair extension - the recordlist is of different type to the extension (its using the same keyvaluepair structure but it is different?)

Exception error thrown: "Unable to cast object of type 'ssTest.RLKeyValuePairList' to type 'OutSystems.NssKeyValuePair.RLKeyValuePairRecordList'."

        public void MssKVP_Set(object ssKeyValuePairList, string ssKey, string ssValue)

            if (ssKeyValuePairList == null)
                Console.WriteLine("Record list must be previously instantiated.");

            RLKeyValuePairRecordList recordList = (RLKeyValuePairRecordList)ssKeyValuePairList; //<--- this should work, but it does not, an exception errors is thrown here!
            //RecordList recordList = (RecordList)ssKeyValuePairList; 
            RCKeyValuePairRecord keyValuePairRec = new RCKeyValuePairRecord(null);


            //Append the record to the recordlist
            keyValuePairRec.ssSTKeyValuePair.ssKey = ssKey;
            keyValuePairRec.ssSTKeyValuePair.ssValue = ssValue;
            keyValuePairRec.ssSTKeyValuePair.ssEnabled = true;


Anyone from outsystems have a copy of System.ListAppend code? or anyone know how to fix this issue? 
 All it should do is append keyvaluepair record to keyvaluepair object recordlist.
Hi Robert,

Unless I'm missing something, you are giving the extension a KeyValuePair List instead of a KeyValuePair Record List. I'm a bit hessitant to suggest this since you're an experienced user and this seems a bit of a novice mistake, but the error seems to indicate you perform a ToObject on a List:

Instead of a Record List:

Kilian, you are right that is what I did! .. I used the old record list in an extension before but not the new record list, what is the new record list? is it what I think it is? in c# it is a dictionary list of type key value pair?
Hi Robert,

It's not a new Record List, it's the new List, introduced with Platform 9. I'm not sure how to deal with it in extensions - iirc the SortRecordList extension has ways to deal with it, maybe you can check it out.
does anyone know what type is outsystems record "list" in c# , is it a dictionary list or something else?