Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Passing lookup value to custom workflow

Posted on by 1,695

I am passing a lookup value to a custom workflow 

        <Input("SourceOriginatingaccount")>
        <ReferenceTarget("new_originatingaccounts")>
        Public Property SourceOriginatingaccount() As InArgument(Of EntityReference)
            Get
                Return m_SourceOriginatingaccount
            End Get
            Set
                m_SourceOriginatingaccount = Value
            End Set
        End Property
        Private m_SourceOriginatingaccount As InArgument(Of EntityReference)


when trying 

                Dim LookupOriginatingAccount As QueryExpression = New QueryExpression With {.EntityName = "new_originatingaccounts", .ColumnSet = New ColumnSet("new_sun", "new_sortcode", "new_accountnumber", "new_accountname"), .Criteria = New FilterExpression()}
                LookupOriginatingAccount.Criteria.AddCondition("new_originatingaccountsid", ConditionOperator.Equal, SourceOriginatingaccount.[Get](Of EntityReference)(executionContext))
                Try

                    Dim OriginatingAccountCollection As EntityCollection = service.RetrieveMultiple(LookupOriginatingAccount)
                    If OriginatingAccountCollection.Entities.Count > 0 Then
                        _strOrigSUN = CType(OriginatingAccountCollection.Entities(0).Attributes("new_sun"), String)
                        _strOrigSortCode = CType(OriginatingAccountCollection.Entities(1).Attributes("new_sortcode"), String)
                        _strOrigAccountNumber = CType(OriginatingAccountCollection.Entities(2).Attributes("new_accountnumber"), String)
                        _strOrigAccountName = CType(OriginatingAccountCollection.Entities(3).Attributes("new_accountname"), String)
                    End If
                Catch ex As Exception
                    Using Errorprocessing As StreamWriter = File.AppendText("C:\Logs\ERROR.txt")
                        Errorprocessing.WriteLine(ex.Message.ToString)
                    End Using
                End Try

I get the error 
Condition for attribute 'new_originatingaccounts.new_originatingaccountsid': expected argument(s) of type 'System.Guid' but received 'Microsoft.Xrm.Sdk.EntityReference'.

I am at a loss

*This post is locked for comments

  • Verified answer
    Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: Passing lookup value to custom workflow

    An entity reference is an object that consists of the logicalname of the entity it belongs to (say account) and the guid of the entity.

    new_originatingaccounts.new_originatingaccountsid.Id will give you the Guid within the entity reference

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans