Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6978483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:45:47+00:00 2026-05-27T17:45:47+00:00

I have several of these instances I have to call to pull down data

  • 0

I have several of these instances I have to call to pull down data from a crm server.

RetrieveAttributeRequest request = new RetrieveAttributeRequest();
request.EntityLogicalName = "opportunity";
request.LogicalName = "new_businessunit";
RetrieveAttributeResponse response = (RetrieveAttributeResponse)lService.Execute(request);
PicklistAttributeMetadata picklist = (PicklistAttributeMetadata)response.AttributeMetadata;

RetrieveAttributeRequest requestsource = new RetrieveAttributeRequest();
requestsource.EntityLogicalName = "opportunity";
requestsource.LogicalName = "new_sourcepick";
RetrieveAttributeResponse responsesource = (RetrieveAttributeResponse)lService.Execute(requestsource);
PicklistAttributeMetadata picklistsource = (PicklistAttributeMetadata)responsesource.AttributeMetadata;

Dictionary<int?, string> BusinessUnits = new Dictionary<int?, string>();
foreach (OptionMetadata option in picklist.OptionSet.Options)
    {
        string picklistlabel = option.Label.UserLocalizedLabel.Label.ToString();
        businessid = option.Value;
        BusinessUnits.Add(businessid, picklistlabel);
    }
Dictionary<int?, string> MarketSegment = new Dictionary<int?, string>();
foreach (OptionMetadata option in picklistmarket.OptionSet.Options)
    {
        string picklistlabel = option.Label.UserLocalizedLabel.Label.ToString();
        marketid = option.Value;
        MarketSegment.Add(marketid, picklistlabel);
    }

So basically I pull the data down and then build a dictionary to hold the data. I have a lot of these so I would like to make a method where I just pass the EntityLogialName and the LogicalName. So instead of having all that I could do something like:

loadlist(opportuniuty, new_businessunit)

But I’m not really sure how to make the method to handle it. Any ideas on how I would do the method?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:45:48+00:00Added an answer on May 27, 2026 at 5:45 pm
    public IDictionary<int?, string> LoadFromCRM(string entityName, string logicalName)
    {
        var request = new RetrieveAttributeRequest();
        request.EntityLogicalName = entityName;
        request.LogicalName = logicalName;
        var response = (RetrieveAttributeResponse)lService.Execute(request);
        var picklist = (PicklistAttributeMetadata)response.AttributeMetadata;
    
        return picklist.OptionSet.Options.ToDictionary(o => o.Value, o => o.Label.UserLocalizedLabel.Label.ToString());
    }
    
    // Usage
    var businessUnits = LoadFromCRM("opportunity", "new_businessunit");
    var marketSegment = LoadFromCRM("opportunity", "new_sourcepick");
    

    Encapsulate the loading of any data within a method, and call it twice (once for each set of data you’re interested in). The above uses LINQ to translate the Options into a Dictionary using the ToDictionary extension method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have several cron jobs that ftp proxy logs to a centralized server. These
I have several instances in my application. Each of these instances have a Timer
i have some Orders that can have several Items and these Items have an
I have seen several sites where these social share buttons looks perfectly horizontal aligned.
i have several classes with members called 'Id'. Originally i wanted to store these
I have several articles on a Joomla (1.5) site. These articles are public --
I have several divs that share a common class. If one of these divs
I have several classes such as Order, Customer, etc. These classes serve for holding
I have several methods that have a return type IEnumerable<T> . These methods are
Suppose I have several services represented by classes ServiceA, ServiceB, ServiceC etc. These services

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.