Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get option set value from fetch XML in a custom work flow

(1) ShareShare
ReportReport
Posted on by 12,077 Super User 2024 Season 1

Hi all

I have below code.

string MarketingListQuery = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='list'>" +
" <attribute name='createdfromcode' />" +
" <attribute name='listid' />" +
" <attribute name='aw_mailchimmarkettinglistid' />" +
" <order attribute='createdfromcode' descending='true' />" +
" <link-entity name='aw_mailchimp' from='aw_mailchimpid' to='aw_mailchimmarkettinglistid' alias='ac'>" +
" <filter type='and'>" +
" <condition attribute='aw_mailchimpid' operator='eq' uiname='test' uitype='aw_mailchimp' value='" + MailChimpId + "' />" +
" </filter>" +
" </link-entity>" +
" </entity>" +
"</fetch>";

EntityCollection MarketingListresult = service.RetrieveMultiple(new FetchExpression(MarketingListQuery));

foreach (var ColumnsMarketingList in MarketingListresult.Entities)
{
Entity contacttt = new Entity("contact");
contacttt["firstname"] = "Test";
contacttt["emailaddress1"] = "e@gmail.com";

var MarketingListMemberType = ColumnsMarketingList.GetAttributeValue < OptionSetValue > ("createdfromcode").ToString();
contacttt["lastname"] = MarketingListMemberType.ToString();
Guid contactIdddd = service.Create(contacttt);
if (MarketingListMemberType == "4")
{

}
}

My code does not giving me option set value. My code giving me this Microsoft.Xrm.Sdk.OptionSetValue. Where am I wrong? How can I get option value?

Thank You

*This post is locked for comments

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,077 Super User 2024 Season 1 on at
    RE: Get option set value from fetch XML in a custom work flow

    Hi Nithya Gopinath

    I use this and it is working.

    var MarketingListMemberType= ColumnsMarketingList.FormattedValues("createdfromcode");

    Thank You very much my friend.

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Get option set value from fetch XML in a custom work flow

    Hi Abdul,

    Please try the following codes.

    var MarketingListMemberType = ColumnsMarketingList.GetAttributeValue < OptionSetValue > ("createdfromcode").Value();
    

                                                                                                     OR

    var MarketingListMemberType= ColumnsMarketingList.FormattedValues("createdfromcode");

    Please refer the following thread.

    https://community.dynamics.com/crm/f/117/t/113879

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans