Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Workflow lookup

Posted on by 1,695

I have a custom entity  new_originatingaccounts with a string field new_sun

Account entity has a 1 to N relationship to new_originating accounts (new_licenceid)

I'm trying to return new_originatingaccounts.new_licenceid as a string.

I know that it's probably not the done thing but I need it for two reasons;

1. I can check if it is a null value, ie the new_originating account does not exist

2 I can check a custom status field in the accounts entity

                    Dim LicenceID As String = String.Empty

                    Dim SUNList As New QueryByAttribute("new_originatingaccounts")
                    SUNList.ColumnSet = New ColumnSet("new_licenceid")
                    SUNList.Attributes.AddRange("new_sun")
                    SUNList.Values.AddRange(sun)
                    Dim ReturnedLicenceidList As EntityCollection = service.RetrieveMultiple(SUNList)
                    For Each ReturnedLicenceid In ReturnedLicenceidList.Entities
                        LicenceID = ReturnedLicenceid.Attributes("new_licenceid").Tostring
                    Exit For
                    Next

*This post is locked for comments

  • Verified answer
    shivaram Profile Picture
    shivaram 3,315 on at
    RE: Workflow lookup

    Hi,

    Try this.

    LicenceID  = ReturnedLicenceid.Attributes.Contains("new_licenceid") ? ReturnedLicenceid.GetAttributeValue<EntityReference>("new_licenceid").Id.ToString() : null;

    [This line is related to c#, Please convert it to VB.Net]. I will help you little related to Vb

    LicenceID  = If(ReturnedLicenceid.Attributes.Contains("new_licenceid"), ReturnedLicenceid.GetAttributeValue(Of EntityReference)("new_licenceid").Id.ToString(), Nothing)

    Hope it helps you.

    Thanks,

    Shivaram.

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