I am building a workflow, which calls a SQL stored procedure. Part of the data that is returned is a Guid for a record in a different entity "new_dbfmlivedata", but I am getting stuck with assigning the 'guid' to updaterecord id . This is my third attempt but I still get the error Unable to cast object of type 'system.guid' to type Microsoft.xrm.sdk.a;iasedvalue
My code
Dim DBLMLiveDataid AsGuid
Dim DBFMLiveDataList AsNewQueryByAttribute("new_dbfmlivedata")
DBFMLiveDataList.ColumnSet = NewColumnSet("new_dbfmlivedataid")
DBFMLiveDataList.Attributes.AddRange("new_dbfmlivedataid")
DBFMLiveDataList.Values.AddRange(SQLReader.GetString(1).ToString)
Dim ReturnedDBFMLiveDataList AsEntityCollection = service.RetrieveMultiple(DBFMLiveDataList)
ForEach ReturnedDBFMLiveData In ReturnedDBFMLiveDataList.Entities
DBLMLiveDataid = DirectCast(DirectCast(ReturnedDBFMLiveData.Attributes("new_dbfmlivedataid"), AliasedValue).Value, EntityReference).Id
Next
Dim UpdateDBFMLiveDate AsNewEntity("new_dbfmlivedata")
UpdateDBFMLiveDate.Id = DBLMLiveDataid
UpdateDBFMLiveDate("new_statementidid") = DBFMProcessingGuid
UpdateDBFMLiveDate("new_processing") = True
UpdateDBFMLiveDate("new_processeddate") = Date.Now()
service.Update(UpdateDBFMLiveDate)
Dim DBLMLiveDataid As Guid Dim DBFMLiveDataList As New QueryByAttribute("new_dbfmlivedata") DBFMLiveDataList.ColumnSet = New ColumnSet("new_dbfmlivedataid") DBFMLiveDataList.Attributes.AddRange("new_dbfmlivedataid") DBFMLiveDataList.Values.AddRange(SQLReader.GetString(1).ToString) Dim ReturnedDBFMLiveDataList As EntityCollection = service.RetrieveMultiple(DBFMLiveDataList) For Each ReturnedDBFMLiveData In ReturnedDBFMLiveDataList.Entities DBLMLiveDataid = DirectCast(DirectCast(ReturnedDBFMLiveData.Attributes("new_dbfmlivedataid"), AliasedValue).Value, EntityReference).Id Next Dim UpdateDBFMLiveDate As New Entity("new_dbfmlivedata") UpdateDBFMLiveDate.Id = DBLMLiveDataid UpdateDBFMLiveDate("new_statementidid") = DBFMProcessingGuid UpdateDBFMLiveDate("new_processing") = True UpdateDBFMLiveDate("new_processeddate") = Date.Now() service.Update(UpdateDBFMLiveDate)