CRM2016
I have a custom entity new_Headers which has a lookup to a custom entity new_originatingaccounts
The lookup field on new_headers is new_oaccountid
I an trying to retrieve the value from new_originatingaccounts for the field new_sun
my code below is not returning any record although I know the record exists
Try ' Need to Lookup SUN Dim strSUN As String = String.Empty If entity.Contains("new_oaccountid") Then Dim serviceFactory As IOrganizationServiceFactory = DirectCast(serviceProvider.GetService(GetType(IOrganizationServiceFactory)), IOrganizationServiceFactory) Dim service As IOrganizationService = Nothing service = serviceFactory.CreateOrganizationService(context.UserId) Dim req As New RetrieveRequest() req.ColumnSet = New ColumnSet(New String() {"new_sun"}) req.Target = New EntityReference("new_originatingaccounts", DirectCast(entity.Attributes("new_originatingaccountsId"), EntityReference).Id) Dim resp As RetrieveResponse resp = service.Execute(req) strSUN = DirectCast(resp.Entity.Attributes("new_sun"), String) End If Catch ex As Exception Throw New InvalidPluginExecutionException("Error looking up SUN - " & ex.Message.ToString) End Try
Dont ask me .. i dont know