none
Update an entity in c

    General discussion

  • I have an entity (new_test),  I'm trying to update from SQLCLR. ( c or VB )

    If I have the primary key for the 'record' to be updated what would be the best way to go, say for instance I wanted to update new_disc to a value of "hello"


    Dont ask me .. i dont know

    Tuesday, September 10, 2013 2:25 PM

All replies

  • The easiest way to create an on demand workflow on new_test entity for update. Select the records which you want to update using advanced find. Select the records and apply the workflow on those records.

    Regards Faisal


    • Edited by Faisal Fiaz Tuesday, September 10, 2013 2:46 PM
    Tuesday, September 10, 2013 2:46 PM
  • This requirement is only part of a SQLCLR stored procedure.

    I have come up with the following but this returns no records. The problem I think is that Licence is a lookup on accounts.

     If RecordId.Value IsNot Nothing Then
                        Dim updaterecord As New new_facilitiesmanagement_processing()
                        Dim _QueryAttr As New QueryByAttribute()
                        _QueryAttr.EntityName = EntityName.new_facilitymanagementprocessinglist.ToString
                        Dim _columns As New ColumnSet()
                        _columns.Attributes = New String() {"new_facilitymanagementprocessinglistid"}
                        _QueryAttr.ColumnSet = _columns
                        _QueryAttr.Attributes = New String() {"new_name", "new_licence"}
                        _QueryAttr.Values = New String() {weeklyStatement.Value, Licence.Value}
                        Dim LookupResultSet As BusinessEntityCollection = crmService.RetrieveMultiple(_QueryAttr)
                        For Each FMList As new_facilitymanagementprocessinglist In LookupResultSet.BusinessEntities
                            Dim NewLookup As New Lookup()
                            NewLookup.Value = New Guid(FMList.new_facilitymanagementprocessinglistid.Value.ToString)
                            NewLookup.type = EntityName.new_facilitymanagementprocessinglist.ToString
                            updaterecord.new_statementid = NewLookup
                            crmService.Update(updaterecord)
                            Exit For
                        Next
                    End If


    Dont ask me .. i dont know

    Tuesday, September 10, 2013 4:13 PM
  • if licence is a lookup then the schema name should be "new_licenceid". CRM enjoys adding 'id' at the end of llokup field whenever it is created.

    Regards Faisal

    Tuesday, September 10, 2013 4:26 PM
  • Took a bit of time but its sorted now

    thanks for the help


    Dont ask me .. i dont know

    Tuesday, September 10, 2013 9:15 PM